'How to create a stripe checkout session React native
I'm trying to set up my payment method using StripeCheckout. I'm not too sure how to create the checkout session ID because of this the checkout won't render and is stuck on loading.
import StripeCheckout from 'react-native-stripe-checkout-webview';
<StripeCheckout
stripePublicKey="pk_test_51KoT8PHUiHbP1Rg8YM69Pysn..."
checkoutSessionInput={{
sessionId: CHECKOUT_SESSION_ID,
}}
onSuccess={({ checkoutSessionId }) => {
console.log(`Stripe checkout session succeeded. session id: ${checkoutSessionId}.`);
}}
onCancel={() => {
console.log(`Stripe checkout session cancelled.`);
}}
/>
Solution 1:[1]
Recommend you just use a webivew and create the CheckoutSession on your server (I'm not familiar with the package you are using).
Make an HTTP request from your ReactNative app to your backend server and create the CheckoutSession on your server. It has a url field, return that to your ReactNative app.
Your ReactNative app then needs to just redirect to a webview to that url field returned from your backend server.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | hmunoz |
