#salem-react-native
1 messages · Page 1 of 1 (latest)
const { confirmPayment, loading } = useConfirmPayment();
const handlePayPress = async () => {
//1.Gather the customer's billing information (e.g., email)
if (!cardDetails?.complete || !email) {
Alert.alert("Please enter Complete card details and Email");
return;
}
const billingDetails = {
email: email,
};
//2.Fetch the intent client secret from the backend
try {
const { clientSecret, error } = await fetchPaymentIntentClientSecret();
//2. confirm the payment
if (error) {
console.log("Unable to process payment");
} else {
const { paymentIntent, error } = await confirmPayment(clientSecret, {
type: "Card",
billingDetails: billingDetails,
});
if (error) {
alert(Payment Confirmation Error ${error.message});
console.log(error.message)
} else if (paymentIntent) {
alert("Payment Successful");
console.log("Payment successful ", paymentIntent);
}
}
} catch (e) {
console.log(e);
}
//3.Confirm the payment with the card details
};
https://github.com/nathvarun/Expo-Stripe-Tutorial is the one im copying
Let me TAL
The code above
const { paymentIntent, error } = await confirmPayment(clientSecret, {
type: "Card",
billingDetails: billingDetails,
});
is a bit different to your code, as it uses confirmPayment. Your original code is using useConfirmPayment.confirmPayment. Which one are you using?
confirmPayment
the former or the latter?
without useConfirmPayment.
const { confirmPayment, loading } = useConfirmPayment();
and then later, the part of actually using it, are you calling this?
useConfirmPayment.confirmPayment(clientSecret, {
type: "Card",
billingDetails: billingDetails,
});
const { paymentIntent, error } = await confirmPayment(clientSecret, {
type: "Card",
billingDetails: billingDetails,
});
Okie I see. I was a bit confusing as in your original code you mentioned useConfirmPayment.confirmPayment, not confirmPayment directly like that. Just another confirmation, what version of expo and what version of Stripe SDK are you using?
Okay I understand it now. Unfortunately Expo 42 only supports Stripe SDK version 0.1.4. You would either wait for Expo to support the newer versions, or downgrade stripe SDK to use with Expo
ive tried to do that but when i hit the pay button it crashes my app after i downgrade, its possible that its a quirk in my system tho. in any case ill try again and see if thats still the case
ye i downgrading to 0.1.4 without changing any code. It closes the app in an android emulator and physical device without giving an error warning
Um that's a different problem. Any crash message/error?
none, just closes expo go and the app without any msg
Is that crash on start? or on some particular screen?
works fine until i press the pay button
then crashes after a slight delay
i checked the server side of things and the only thing that might be the problem is this : status: 'requires_payment_method', from const paymentIntent = await stripe.paymentIntents.create({
amount: 1099, //lowest denomination of particular currency
currency: "usd",
payment_method_types: ["card"], //by default
});
That looks correct to me
Is there any message on your IDE? like after the crash happened?
nothing and my phone thinks the app is still running but the app is gone
That's so weird... Btw Can you try this official sample: https://snack.expo.dev/@charliecruzan/stripe-react-native-example
I am sorry that I can't figure it our either. Going with SDK 0.1.4 is the right direction while you are using Expo 42. For the crash, please fill an issue here: https://github.com/stripe/stripe-react-native/issues with a screen recording the crash, and your code accordingly
alright thanks for trying, much appreciated. btw the official example uses version 0.1.1 and at least some of them seem to be working fine so ill try that