stripe-react-native icon indicating copy to clipboard operation
stripe-react-native copied to clipboard

feat: :zap: Update payment details after calling initPaymentSheet

Open minawalphonce opened this issue 1 year ago • 2 comments

Summary

  • created a new function "updatePaymentSheet" which updates the intent config info (e.g. amount) after payment sheet is initialized

Motivation

updating payment sheet intent config, is needed for payment methods that requires second level of authentication. so the amount can be displayed correctly on the 3rd party authentication. the functionality already exists in IOS and android native code. the PR is to expose the same in react native sdk.

Testing

  • [X] I tested this manually
  • [ ] I added automated tests

Documentation

new screen updated in the example app to test the scenario.

step 1

in your component, use the hook useStripe to retrieve the new "updatePaymentSheet" function.

const {
    updatePaymentSheet,
  } = useStripe();

step2

call the updatePaymentSheet with the PaymentSheet.IntentConfiguration object containing all the params

const { error, paymentOption } = await updatePaymentSheet({
        confirmHandler:  ...,
        mode: {
          amount: amount,
          currencyCode: 'SEK',
        },
      });

NOTE: the function replace the entier block, so be aware if you remove an attribute it will be removed.

Select one:

  • [X] I have added relevant documentation for my changes.
  • [X] This PR does not result in any developer-facing changes.

minawalphonce avatar May 04 '24 11:05 minawalphonce

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 04 '24 11:05 CLAassistant

Any update on this pr pls ?

alexdieudonne avatar Oct 24 '24 10:10 alexdieudonne