Skip to content

Conversation

daledupreez
Copy link
Contributor

Fixes STRIPE-659

Changes proposed in this Pull Request:

The underlying driver for this PR is that the original code that made customer validation stricter, #4464, always required all fields. We previously shipped #4489 to relax those restrictions when users are adding payment methods. This PR refactors some of the code from #4489 to be a bit more generic so we can identify specific contexts in which we expect a smaller set of customer details to be available. The PR also relaxes customer validation for the "Pay for order" page, making it possible for manually entered orders to be handled with limited customer information.

At a technical level, the changes in this PR are as follows:

  • Change a number of functions to accept a nullable $current_context string parameter instead of a $is_add_payment_method_page boolean parameter.
    • The changes include a normalization step for all public method so callers of the previous API get the same behaviour.
      • This was only released in 9.7.1, but I still want to avoid unnecessary breakages
  • Update WC_Stripe_Customer->get_create_customer_required_fields() to require only an email address when we are on the pay for order page in addition to the case for adding a payment method.
  • Updating the two callers to specify the appropriate context string.

Testing instructions

  • Run a current version of the plugin (e.g. from 9.7.1, 9.8.0, or `develop)
  • Ensure Stripe is connected in test mode and you have at least one product
  • Navigate to WooCommerce -> Orders and then click on the "Add order" button
  • Add some line items to the order
  • For the billing details, enter only the user's email address
  • Save the order
  • Once the order is saved, find the "Customer payment page" link in the General section of the order details and copy the link
  • In an incognito window or different browser window, navigate to that link
  • Try to make payment
  • You should get a validation error
  • Now switch to this branch, and re-submit the payment
  • The payment should now be processed and you should be redirected to the order received page

  • Covered with tests (or have a good reason not to test in description ☝️)
  • [N/A] Tested on mobile (or does not apply)

Changelog entry

  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Comment

Comment

Post merge

@daledupreez daledupreez requested review from a team and Copilot August 12, 2025 14:13
@daledupreez daledupreez self-assigned this Aug 12, 2025
@daledupreez daledupreez requested review from malithsen and wjrosa and removed request for a team August 12, 2025 14:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes address validation issues for manually entered orders by relaxing customer validation requirements on the "pay for order" page. Previously, strict validation prevented orders with minimal customer information (e.g., email only) from being processed.

  • Refactors validation context parameters from boolean flags to string-based contexts
  • Allows minimal customer details (email only) for both "add payment method" and "pay for order" pages
  • Maintains backward compatibility with existing API callers

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
includes/class-wc-stripe-customer.php Core changes to validation logic, adding context-aware customer field requirements and parameter normalization
includes/payment-methods/class-wc-stripe-upe-payment-gateway.php Updates customer creation call to pass "pay_for_order" context
includes/class-wc-stripe-intent-controller.php Updates setup intent creation to use new string-based context parameter
readme.txt Adds changelog entry for the fix
changelog.txt Adds changelog entry for the fix

Copy link
Contributor

@wjrosa wjrosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is good and works as expected! Left some optional suggestions

Screenshot 2025-08-12 at 16 41 21

Copy link
Contributor

@malithsen malithsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and tests well

@daledupreez
Copy link
Contributor Author

I've reviewed the E2E failures, and it looks like the Default failures are already being addressed in #4592, and the issues with the Optimized Checkout tests seem to be unrelated to this PR.

@daledupreez daledupreez merged commit 0d08dd6 into develop Aug 14, 2025
38 of 40 checks passed
@daledupreez daledupreez deleted the fix/address-validation-for-manually-entered-orders branch August 14, 2025 16:10
diegocurbelo pushed a commit that referenced this pull request Aug 14, 2025
* Allow minimal customer details on pay for order page
* Changelog
* Add normalization for existing boolean flag
* Remove trailing quotes from changelog
* Add constants for strings
* Make constant public; update unit tests
* Remove double period
@freedjack
Copy link

freedjack commented Aug 18, 2025

I have been seeing this issue on a wp/woocommerce/civicrm instance. I have created a small plugin that solves the address issue for us and may be of use to someone while this issue is being resolved.
https://github.com/freedjack/woocommerce-stripe-address-fix

@diegocurbelo diegocurbelo added this to the 9.8.1 milestone Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants