stripe-react-native: [Trying to add a subscription] This package or the Stripe doc is not correct.
I’m trying to add Stripe and allow users to first give their payment info on the Payment Element sheet, then click on the subscribe button to start their subscription (with a free trial).
I am following a tutorial from the Stripe docs and at this step (https://stripe.com/docs/payments/accept-a-payment-deferred?platform=react-native&type=payment#initialize-paymentsheet), they provide a code snippet that calls initPaymentSheet(…) without a client secret.
const { error } = await initPaymentSheet({
merchantDisplayName: "Example, Inc.",
intentConfiguration: {
mode: {
amount: 6099,
currencyCode: 'USD',
},
confirmHandler: handleConfirmation
}
});
And when I use the their code, I got the error: You must provide either paymentIntentClientSecret or setupIntentClientSecret.
The tutorial from the Stripe doc doesn’t mention to add a secret client at this step but mention it only after so I don’t undestand why I got this error.
Is something missing in the Stripe docs? Is it this package? Or should I never touch a keyboard again?
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Comments: 18
Hi @YoucefBen47 @samvoults In this case you should defer the subscription creation.
payment_method
payment_method
to your backend and use it as thedefault_payment_method
when creating a subscription.Hi @samvoults I saw an inconsistency where you are using PaymentMode at the client side, but your backend creates a SetupIntent. You should always use
SetupMode
with SetupIntent, orPaymentMode
with PaymentIntent.There’s a dedicated integration guide for Subscription integration that I strongly recommend you to go through. Although it’s not tailored for react-native, the basic idea here is to use a
PaymentMode
PaymentSheet to pay the first invoice generated by the subscription.Feel free to let me know if you have any other questions.
Thanks for the feedback, I’d ask the docs team to fix it. Let me know if you have any other questions.
Hi @samvoults This flow requires a more recent version of
stripe-react-native
SDK. Can you update to the latest version and try again?