stripe / stripe-terminal-react-native

React Native SDK for Stripe Terminal
https://stripe.com/docs/terminal/payments/setup-integration?terminal-sdk-platform=react-native
MIT License
104 stars 50 forks source link

ERROR: You must provide paymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent. #786

Open a-eid opened 4 weeks ago

a-eid commented 4 weeks ago

Describe the bug We're getting this error: You must provide paymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent., from the method collectPaymentMethod, even thou the passed paymentIntent is returned from the retrievePaymentIntent method call.

To Reproduce Steps to reproduce the behavior:

// 1- collection client secret.
const clientSecret = await api.post("endpoing", { amount });
// 2- retrievePaymentIntent from stripe 
const { paymentIntent, error } = retrievePaymentIntent(clientSecret);
// 3- collect payment method 
const { error: collectPaymentMethodError } = await collectPaymentMethod({
   paymentIntent,
   skipTipping: true,
});

// ERROR: `You must provide paymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent.`

Expected behavior for collectPaymentMethod to accept the paymentIntent returned from retrievePaymentIntent

Stripe Terminal React Native SDK version

a-eid commented 2 weeks ago

any idea what this issue be, judging by the lack of comments I assume this is an issue on our part. any idea where could it be ?

danmofo commented 1 week ago

any idea what this issue be, judging by the lack of comments I assume this is an issue on our part. any idea where could it be ?

Maybe because you are missing the await keyword on this line?

const { paymentIntent, error } = retrievePaymentIntent(clientSecret);

vs

const { paymentIntent, error } = await retrievePaymentIntent(clientSecret);
nabilfreeman commented 22 hours ago

We are experiencing this on beta 20 which I just upgraded to. Downgrading to beta 19 makes this error go away.

We had a stable implementation in production prior to the upgrade, so I don't think it is a syntax issue in our case.

Update: This is actually because v20 changes the parameters of confirmPaymentIntent to be an object of parameters rather than just a payment intent.

So my code was this:

await confirmPaymentIntent(paymentIntent)

And I changed to this:

await confirmPaymentIntent({ paymentIntent })