Skip to content

Stripe setup future usage mismatch#3690

Merged
rasbhat merged 2 commits intot/team404/sfp-on-pwafrom
rvishwanathbhat/stripe-setup-future-usage-mismatch
Mar 2, 2026
Merged

Stripe setup future usage mismatch#3690
rasbhat merged 2 commits intot/team404/sfp-on-pwafrom
rvishwanathbhat/stripe-setup-future-usage-mismatch

Conversation

@rasbhat
Copy link

@rasbhat rasbhat commented Feb 25, 2026

Send setupFutureUsage to the backend and set paymentIntent.setup_future_usage only when the user is registered and opts to save; otherwise omit it so the PI is created and confirmed without setup_future_usage, removing the mismatch.

Description

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • (change1)

How to Test-Drive This PR

  • (step1)

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@rasbhat rasbhat requested review from a team as code owners February 25, 2026 09:46
@salesforce-cla
Copy link

Thanks for the contribution! It looks like @rvishwanathbhat is an internal user so signing the CLA is not required. However, we need to confirm this.

@cc-prodsec
Copy link
Collaborator

cc-prodsec commented Feb 25, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

[customer, paymentConfig]
)
// Stable key so we only re-init when SPM list actually changes.
const savedPaymentMethodsKey = useMemo(
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we can call this with [savedPaymentMethods] in the dependency array, then wouldn't that mean we can add savedPaymentMethods to the below useEffect where you added savedPaymentMethodsKey?

Copy link
Author

Choose a reason for hiding this comment

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

savedPaymentMethods is an array, so whenever the array changes (even with customer/paymentConfig and no changes in the list of SPMs), the component reinits again.
But savedPaymentMethodsKey is a string, so when savedPaymentMethods gets a new reference, the useMemo for savedPaymentMethodsKey does run again, but gets the same string if SPMs remains unchanged. if previous and current string values are the same, it does not re run, unlike the array.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this the only case in the app where an array is hashed like this to create a stable key? If yes, we're probably doing something else wrong.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, seems this is the only place. Finding it a bit tricky to refetch SPM even if the checkout component waits. I reverted these changes and created another WI to track this bug so that the stripe future use bug can be checked in first.

@rasbhat rasbhat closed this Feb 25, 2026
@rasbhat rasbhat force-pushed the rvishwanathbhat/stripe-setup-future-usage-mismatch branch from 9980e57 to a159589 Compare February 25, 2026 20:04
@rasbhat rasbhat reopened this Feb 25, 2026
} from '@salesforce/retail-react-app/app/components/shared/ui'
import {useToast} from '@salesforce/retail-react-app/app/hooks/use-toast'
import {useShopperBasketsV2Mutation as useShopperBasketsMutation, useCustomerType} from '@salesforce/commerce-sdk-react'
import {

Choose a reason for hiding this comment

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

is this formatting change a lint fix or something? I assume we dont need to mess with one-click in general

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it was just a lint fix. Trying to reduce failing tests.

@rasbhat rasbhat merged commit 3caabb1 into t/team404/sfp-on-pwa Mar 2, 2026
12 of 16 checks passed
@rasbhat rasbhat deleted the rvishwanathbhat/stripe-setup-future-usage-mismatch branch March 2, 2026 18:58
rasbhat added a commit that referenced this pull request Mar 5, 2026
…/stripe-setup-future-usage-mismatch

Stripe setup future usage mismatch
rasbhat added a commit that referenced this pull request Mar 5, 2026
…/stripe-setup-future-usage-mismatch

Stripe setup future usage mismatch
rasbhat added a commit that referenced this pull request Mar 5, 2026
…/stripe-setup-future-usage-mismatch

Stripe setup future usage mismatch
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.

4 participants