fix(stripe): disable adaptive pricing when modal checkout omits country#296
Open
rbcorrales wants to merge 2 commits into
Open
fix(stripe): disable adaptive pricing when modal checkout omits country#296rbcorrales wants to merge 2 commits into
rbcorrales wants to merge 2 commits into
Conversation
Co-authored-by: Codex <noreply@openai.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents WooCommerce Stripe “Adaptive Pricing” from breaking Newspack modal checkout flows when the site’s configured Reader Revenue billing fields omit billing_country, by automatically disabling Adaptive Pricing in that scenario.
Changes:
- Adds a
wp_loadedguard that disables Adaptive Pricing only during modal checkout requests (viaModal_Checkout::is_modal_checkout()). - Adds a
woocommerce_stripe_updatedhook handler to immediately revert Stripe’s 10.8+ migration default that enables Adaptive Pricing, when modal checkout can’t provide country.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
WooCommerce Stripe 10.8 enables Adaptive Pricing by default for eligible existing stores via a one-time migration (woocommerce/woocommerce-gateway-stripe#5492). With Adaptive Pricing active, the Stripe Checkout Sessions confirmation requires a billing country, but the Newspack modal checkout can be configured (Reader Revenue billing fields) to omit that field. On those sites, one-time donations and modal purchases fail with
Missing value for confirm: billingAddress.address.country.This PR adds a guard in the WooCommerce Gateway Stripe integration that disables Adaptive Pricing when the configured billing fields omit
billing_country:wp_loaded, usingModal_Checkout::is_modal_checkout()), so the fix lands on the same request that renders or processes the checkout.woocommerce_stripe_updated), so the 10.8 default-on flip is reverted immediately on the request that performs it.Sites that collect the country field, use the default billing fields (which include country), or check out via My Account (where the country field is rendered) are not affected.
How to test the changes in this Pull Request:
billing_country.adaptive_pricingtoyesin thewoocommerce_stripe_settingsoption).adaptive_pricingflips tono, the checkout iframe shows no Adaptive Pricing currency selector, a one-time donation completes without the missing country error, and the change is logged.billing_countryto the billing fields. Confirm modal checkout leaves the setting enabled.wp eval "do_action( 'woocommerce_stripe_updated' );"). Confirm the setting flips tonowithout a modal checkout request.Other information: