Skip to content

fix(stripe): disable adaptive pricing when modal checkout omits country#296

Open
rbcorrales wants to merge 2 commits into
mainfrom
fix/stripe-adaptive-pricing-modal-checkout
Open

fix(stripe): disable adaptive pricing when modal checkout omits country#296
rbcorrales wants to merge 2 commits into
mainfrom
fix/stripe-adaptive-pricing-modal-checkout

Conversation

@rbcorrales

@rbcorrales rbcorrales commented Jun 12, 2026

Copy link
Copy Markdown
Member

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:

  • On modal checkout requests (wp_loaded, using Modal_Checkout::is_modal_checkout()), so the fix lands on the same request that renders or processes the checkout.
  • Right after WooCommerce Stripe runs its update migrations (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:

  1. On a site with WooCommerce and WooCommerce Stripe 10.8+, configure Reader Revenue billing fields (Audience > Donations) to a custom set that does not include billing_country.
  2. Enable Adaptive Pricing in WooCommerce > Settings > Payments > Stripe > advanced settings (or set adaptive_pricing to yes in the woocommerce_stripe_settings option).
  3. Load a regular article page and confirm Adaptive Pricing stays enabled (the guard must not run outside modal checkout).
  4. Open a donation modal checkout. Confirm adaptive_pricing flips to no, the checkout iframe shows no Adaptive Pricing currency selector, a one-time donation completes without the missing country error, and the change is logged.
  5. Re-enable Adaptive Pricing and add billing_country to the billing fields. Confirm modal checkout leaves the setting enabled.
  6. Re-enable Adaptive Pricing and clear the billing fields option (default field set). Confirm modal checkout leaves the setting enabled.
  7. Re-enable Adaptive Pricing and trigger the post-migration hook (e.g. wp eval "do_action( 'woocommerce_stripe_updated' );"). Confirm the setting flips to no without a modal checkout request.
  8. Deactivate newspack-blocks (or the Stripe gateway) and confirm checkout requests cause no errors (guards bail silently).

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Co-authored-by: Codex <noreply@openai.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 12, 2026 21:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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_loaded guard that disables Adaptive Pricing only during modal checkout requests (via Modal_Checkout::is_modal_checkout()).
  • Adds a woocommerce_stripe_updated hook 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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@rbcorrales rbcorrales marked this pull request as ready for review June 12, 2026 21:48
@rbcorrales rbcorrales requested a review from a team as a code owner June 12, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants