Skip to content

[WEB-4304] fix: Force billing address collection in Express Checkout element#891

Merged
vicfergar merged 1 commit into
mainfrom
WEB-4304-force-billing-address-collection-for-apple-pay-tax-cases
May 28, 2026
Merged

[WEB-4304] fix: Force billing address collection in Express Checkout element#891
vicfergar merged 1 commit into
mainfrom
WEB-4304-force-billing-address-collection-for-apple-pay-tax-cases

Conversation

@vicfergar

@vicfergar vicfergar commented May 27, 2026

Copy link
Copy Markdown
Contributor

Motivation / Description

We want to always collect the billing address in the Express Checkout element, regardless of whether tax collection is currently enabled for the merchant. The reasoning:

  • Forcing billing address collection has no visible impact on the user-facing UI of the Express Checkout wallets (Apple Pay, Google Pay, etc.).
  • It lets us calculate and collect taxes correctly on renewal if tax collection gets enabled for the merchant after the initial checkout, without having to re-prompt the user or fall back to a non-taxable flow.

Previously, billingAddressRequired was wired through the component chain and toggled based on taxCalculationStatus / brandingInfo.gateway_tax_collection_enabled. That meant merchants with tax collection disabled at render time would not get a billing address, even if it later became relevant.

Changes introduced

  • Removed the billingAddressRequired prop from the component chain so the Express Checkout element always requests the billing address:
    • payment-entry-page.svelte: no longer computes/passes billingAddressRequired={taxCalculationStatus !== "disabled"}.
    • express-purchase-button.svelte: no longer passes billingAddressRequired={brandingInfo?.gateway_tax_collection_enabled}.
    • stripe-elements.svelte and stripe-express-checkout-element.svelte: drop the prop and stop forwarding it to StripeService.createExpressCheckoutElement.

Linear ticket (if any)

WEB-4304

Additional comments

  • No user-facing UI change is expected; the Express Checkout wallets do not visibly differ when billingAddressRequired is on vs. off.
  • Worth a quick manual smoke test with Apple Pay / Google Pay on both tax-enabled and tax-disabled merchants to confirm nothing regresses.

Summary by CodeRabbit

  • Refactor
    • Standardized billing-address behavior for express checkout (billing address no longer configurable per-invocation).
  • New Features
    • Express checkout now reports readiness to improve wallet availability detection.

Review Change Stack

@vicfergar vicfergar requested a review from a team May 27, 2026 17:16
@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

StripeService now always sets billingAddressRequired: true; UI components remove the billingAddressRequired prop from Props/destructuring and from the options passed to StripeService; call sites stop passing the prop and express-purchase-button adds an onReady handler to report wallet availability.

Changes

Remove billingAddressRequired from checkout

Layer / File(s) Summary
Stripe service: hard-code billingAddressRequired
src/stripe/stripe-service.ts
createExpressCheckoutElement signature drops the billingAddressRequired parameter and composes options with billingAddressRequired: true.
Core component contract and wiring updates
src/ui/molecules/stripe-express-checkout-element.svelte, src/ui/molecules/stripe-elements.svelte
Remove billingAddressRequired from Props, component destructuring, and from options passed to StripeService.createExpressCheckoutElement; ExpressCheckoutElement no longer receives that prop.
Remove prop at call sites and add readiness callback
src/ui/express-purchase-button/express-purchase-button.svelte, src/ui/pages/payment-entry-page.svelte
Call sites stop passing billingAddressRequired; express-purchase-button additionally wires an onReady handler (onExpressCheckoutElementReady) to report wallet availability.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • tonidero

"I hopped through code with nimble feet,
Removed a prop and kept the beat,
Wallets whisper when they're ready to pay,
Billing flags folded gently away,
A rabbit's cheer for a leaner display."

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: forcing billing address collection in the Express Checkout element.
Description check ✅ Passed The description comprehensively covers motivation, changes introduced, and includes the Linear ticket reference and additional comments as required by the template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch WEB-4304-force-billing-address-collection-for-apple-pay-tax-cases

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vicfergar vicfergar force-pushed the WEB-4304-force-billing-address-collection-for-apple-pay-tax-cases branch from befdc6a to 5ab4952 Compare May 27, 2026 17:23
@vicfergar vicfergar force-pushed the WEB-4304-force-billing-address-collection-for-apple-pay-tax-cases branch from 5ab4952 to 76ab7a2 Compare May 28, 2026 15:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/stripe/stripe-service.ts (1)

280-292: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

billingAddressRequired is still overrideable by caller options.

Line 291 can overwrite Line 281, so this doesn’t truly force billing address collection. Make billingAddressRequired: true the last-assigned property (or strip it from expressCheckoutOptions) so callers can’t disable it.

Suggested fix
-    const options = {
-      billingAddressRequired: true,
-      emailRequired: true,
-      ...(forceEnableWalletMethods
-        ? {
-            paymentMethods: {
-              applePay: "always",
-              googlePay: "always",
-            },
-          }
-        : {}),
-      ...(expressCheckoutOptions ? expressCheckoutOptions : {}),
-    } as StripeExpressCheckoutElementOptions;
+    const options = {
+      emailRequired: true,
+      ...(forceEnableWalletMethods
+        ? {
+            paymentMethods: {
+              applePay: "always",
+              googlePay: "always",
+            },
+          }
+        : {}),
+      ...(expressCheckoutOptions ? expressCheckoutOptions : {}),
+      billingAddressRequired: true,
+    } as StripeExpressCheckoutElementOptions;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/stripe/stripe-service.ts` around lines 280 - 292, The options object
currently sets billingAddressRequired: true but then spreads
expressCheckoutOptions afterwards, allowing callers to override it; update the
construction of options (the variable named options in stripe-service.ts) so
billingAddressRequired: true is applied after spreading expressCheckoutOptions
(or remove billingAddressRequired from expressCheckoutOptions before the spread)
to ensure billingAddressRequired cannot be disabled by callers; keep the
existing forceEnableWalletMethods handling intact so only billingAddressRequired
is enforced last.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/stripe/stripe-service.ts`:
- Around line 280-292: The options object currently sets billingAddressRequired:
true but then spreads expressCheckoutOptions afterwards, allowing callers to
override it; update the construction of options (the variable named options in
stripe-service.ts) so billingAddressRequired: true is applied after spreading
expressCheckoutOptions (or remove billingAddressRequired from
expressCheckoutOptions before the spread) to ensure billingAddressRequired
cannot be disabled by callers; keep the existing forceEnableWalletMethods
handling intact so only billingAddressRequired is enforced last.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c72ea90e-c82f-4dc5-8317-1babb6842293

📥 Commits

Reviewing files that changed from the base of the PR and between befdc6a and 76ab7a2.

📒 Files selected for processing (5)
  • src/stripe/stripe-service.ts
  • src/ui/express-purchase-button/express-purchase-button.svelte
  • src/ui/molecules/stripe-elements.svelte
  • src/ui/molecules/stripe-express-checkout-element.svelte
  • src/ui/pages/payment-entry-page.svelte
💤 Files with no reviewable changes (4)
  • src/ui/molecules/stripe-elements.svelte
  • src/ui/molecules/stripe-express-checkout-element.svelte
  • src/ui/express-purchase-button/express-purchase-button.svelte
  • src/ui/pages/payment-entry-page.svelte

@vicfergar vicfergar merged commit 8d9cf08 into main May 28, 2026
7 checks passed
@vicfergar vicfergar deleted the WEB-4304-force-billing-address-collection-for-apple-pay-tax-cases branch May 28, 2026 16:49
RCGitBot added a commit that referenced this pull request Jun 4, 2026
**This is an automatic release.**

## RevenueCat SDK
### ✨ New Features
* Add presented offering context to paywall events (#818) via Rick
(@rickvdl)
### 🐞 Bugfixes
* [WEB-4304] fix: Force billing address collection in Express Checkout
element (#891) via Víctor Ferrer García (@vicfergar)

### 🔄 Other Changes
* Bump jwt from 2.10.2 to 2.10.3 (#895) via dependabot[bot]
(@dependabot[bot])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants