#abhishekashyap_code
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1314287679789072385
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
On mobile vs on web
This is the payment methods i'm getting in payment intent response
Hi ๐
Okay so it looks like you are using the Payment Element on the Web and the Payment Sheet in mobile, correct?
Okay, and are you using the same code we show here to initialize the Payment Sheet?
https://docs.stripe.com/payments/accept-a-payment?platform=react-native#react-native-collect-payment-details
Yes, this is exactly how I'm using it. Only ephemeralKey is missing from this
So you are using
allowsDelayedPaymentMethods: true,
?
Yes
const { error: errorInInitialization } = await initPaymentSheet({
merchantDisplayName: Constants.BOOKING_SCREEN_MERCENT_NAME,
paymentIntentClientSecret: client_secret,
allowsDelayedPaymentMethods: true
});
Okay, that was my first concern.
Can you try adding an ephemeral key to your integration?
That will take some time as it will require backend changes as well. My concern is that it s working correct for the web with same config, is there some issue with react-native sdk that im missing
Can you share the code you are using the initialize the Payment Element in your web UI?
const initializeStripeScript = async (
setClientSecret: (clientSecret: string) => void,
setPaymentState: (paymentState: string) => void,
paymentData: any,
) => {
const data = {
payment: {
state: "initiated",
new_payment_flow: "true",
automatic_payment_methods_enabled: "true",
gateway_details: {
...paymentData?.gateway_details,
type: "session",
},
},
};
try {
const response = await updatePaymentHelper(paymentData.token, data);
setPaymentState(paymentStates.INIT);
if (response?.data?.intent_details?.client_secret) {
setClientSecret(response?.data?.intent_details?.client_secret);
} else {
setPaymentState(paymentStates.FAILED);
}
} catch (error) {
if (typeof window !== undefined && typeof window.Sentry !== "undefined") {
window.Sentry.captureException(`Payment Intent update api -> ${error} `, {
extra: { request: JSON.stringify(data), response: error },
});
}
// @ts-ignore
if (error?.body?.message) {
setPaymentState(paymentStates.FAILED);
} else {
setPaymentState(paymentStates.FAILED);
}
}
};
Okay, maybe I'm missing something but I'm looking for the parameters you pass when initializing Stripe elements and the Payment Element specifically:
https://docs.stripe.com/js/elements_object/create
https://docs.stripe.com/js/elements_object/create_payment_element
I don't see those here
The main gist is in:
const stripePromise = loadStripe(config.STRIPE_API_KEY);
const options = {
clientSecret,
appearance: {
theme: "stripe",
rules: rulesForStripeOptions,
},
};
return (
<Elements options={options} stripe={stripePromise}>
<PaymentSummaryChild
isNewLeadFormFlow={isNewLeadFormFlow}
isMobile={!isDesktop}
paymentData={paymentData}
tncLink={tncLink}
isPaymentFormWithAccommodationCard={isPaymentFormWithAccommodationCard}
/>
</Elements>
)
Ah, prefect
the clientSecret is what I'm getting from the backend after creating an intent
The creation of intent has all the necessary values like currency, amout etc
Is it possible to share two Payment Intent IDs
- One created for your mobile app
- One created for your website
I'm just trying to rule things out
No