#nahoor_api
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/1359131837137682643
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
are you following this guide https://docs.stripe.com/payments/accept-a-payment?platform=react-native ?
you need to use initPaymentSheet
https://docs.stripe.com/payments/mobile/finalize-payments-on-the-server?platform=react-native&type=payment&integration=paymentsheet-flowcontroller i am following this
would you mind sharing your code then?
This is my initializePaymentSheet :
const initializePaymentSheet = async () => {
const { error } = await initPaymentSheet({
// customFlow: true,
merchantDisplayName: 'Example .inc',
intentConfiguration: {
mode: {
amount: (bookingPrices.totalPrice * 100),
currencyCode: 'gbp',
},
confirmHandler,
},
defaultBillingDetails: {},
googlePay: {
merchantCountryCode: 'GB',
testEnv: true, // use test environment
},
applePay: {
merchantCountryCode: 'GB',
},
});
if (error) {
console.error('โ PaymentSheet init error:', error);
} else {
console.log('โ
PaymentSheet initialized successfully!');
}
};
you're not passing the confirmHandler here
const confirmHandler = async (paymentMethod: any, intentCreationCallback: any) => {
const orderReference = `${bookingLoadData?.loadId}`;
console.log('orderReference', orderReference);
setLoading(true);
try {
const response = await axios.post(
`{API_URL}/Stripe/confirm-payment-intent`,
{
paymentMethodId: paymentMethod.id,
currency: 'gbp',
amount: bookingPrices.totalPrice,
orderReference,
description: `${bookingLoadData?.from?.postcode} - ${bookingLoadData?.to?.postcode} / ${bookingLoadData?.minVehicleSize}`,
isMobile: true,
// should_save_payment_method: shouldSavePaymentMethod,
},
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
},
}
);
console.log('โ
confirmHandler API Response:', response.data);
const client_secret = response.data?.data?.clientSecret;
if (client_secret) {
console.log('client_secret', client_secret);
intentCreationCallback({ clientSecret: 'your_client_secret' });
} else {
throw new Error('Client secret not found in response');
}
} catch (error: any) {
const errorMsg2 = error.response || error.message || 'Unknown error occurred';
console.error('โ Error in confirmHandler:', errorMsg2);
intentCreationCallback({ error: errorMsg }); // Pass error to Stripe to reject flow
} finally {
setLoading(false);
}
}; and my confirm handler
well this is showing me my paymentMethod showing me in console in here
you need to pass to intentConfiguration the confirmHandler
u mean i need to do like this :
merchantDisplayName: 'Intercargo Logistics',
intentConfiguration: {
mode: {
amount: (bookingPrices.totalPrice * 100),
currencyCode: 'gbp',
},
confirmHandler: confirmHandler,
},
yes
const confirmHandler = async (paymentMethod, shouldSavePaymentMethod, intentCreationCallback) => {
// explained later
}
you're missing the shouldSavePaymentMethod param of the confirmHandler
the intentCreationCallback is the 3 param
is shouldSavePaymentMethod necessary?
and you're using the second one instead
no it's not but the order should be preserved