Skip to content

Conversation

@daledupreez
Copy link
Contributor

@daledupreez daledupreez commented Nov 28, 2025

Fixes STRIPE-824
Fixes #4819

Changes proposed in this Pull Request:

This PR implements a new wc_stripe_express_checkout_normalize_address filter that runs as part of our existing wc_stripe_normalize_address AJAX action that normalizes addresses for express checkout. This will allow for additional normalization of address data for express checkouts.

Testing instructions

Start with inspection. You can also verify that the hook is running and would be used by doing the following:

  • Set up a Stripe test site using the code from this branch
  • Ensure that you have an express checkout payment method enabled
  • Ensure that logging for Stripe is enabled
  • Add the following snippet to log the data from the filter:
function test_express_checkout_address_filter( $normalized_data, $original_data ) {
	WC_Stripe_Logger::debug( 'debug address filter', [ 'normalized_data' => $normalized_data, 'original_data' => $original_data ] );
	return $normalized_data;
}
add_filter( 'wc_stripe_express_checkout_normalize_address', 'test_express_checkout_address_filter', 10, 2 );
  • Add a product to your cart and use an express checkout method to make the purchase
  • After completing the purchase, verify that you're getting the data in your debug log from the filter

Note: I tried to write unit tests, but the fact that ajax_normalize_address() uses filter_input() means we can't mock the data in $_POST.


  • 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

Copy link
Contributor

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 adds a new WordPress filter wc_stripe_express_checkout_normalize_address that allows developers to customize address normalization for express checkout payment methods (Apple Pay, Google Pay, etc.). The filter is applied after WooCommerce Stripe's built-in normalization logic, enabling additional address data transformations as needed by merchants or extensions.

  • Introduces the wc_stripe_express_checkout_normalize_address filter in the AJAX address normalization handler
  • Provides access to both normalized and original address data for flexible customization
  • Updates changelog and readme to document the new filter

Reviewed changes

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

File Description
includes/payment-methods/class-wc-stripe-express-checkout-ajax-handler.php Adds the new filter after existing normalization methods, providing normalized and original address data as parameters
readme.txt Documents the new filter addition in the changelog section
changelog.txt Documents the new filter addition in the current version's changelog

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@daledupreez daledupreez marked this pull request as ready for review November 28, 2025 19:40
@daledupreez daledupreez requested review from a team, diegocurbelo and wjrosa and removed request for a team November 28, 2025 19:41
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.

Looks good to me! I would consider Copilot's suggestion

Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

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

LGTM, and it tests as indicated.

@daledupreez daledupreez merged commit a316aab into develop Dec 4, 2025
40 checks passed
@daledupreez daledupreez deleted the add/filter-to-hook-into-express-checkout-normalize-address-processing branch December 4, 2025 13:57
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.

Allow filtering the address on "normalize_address" from express payments

4 participants