#salem-react-native

1 messages · Page 1 of 1 (latest)

mortal haven
#

Hello, how are you initializing that useConfirmPayment ?

nocturne coyote
#

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
};

mortal haven
#

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?

nocturne coyote
#

confirmPayment

mortal haven
#

the former or the latter?

nocturne coyote
#

without useConfirmPayment.

#

const { confirmPayment, loading } = useConfirmPayment();

mortal haven
#

and then later, the part of actually using it, are you calling this?

useConfirmPayment.confirmPayment(clientSecret, {
    type: "Card",
    billingDetails: billingDetails,
});
nocturne coyote
#

const { paymentIntent, error } = await confirmPayment(clientSecret, {
type: "Card",
billingDetails: billingDetails,
});

mortal haven
#

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?

nocturne coyote
#

sry about that

#

"expo": "~42.0.1",

#

"@stripe/stripe-react-native": "^0.2.0",

mortal haven
#

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

nocturne coyote
#

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

mortal haven
#

Um that's a different problem. Any crash message/error?

nocturne coyote
#

none, just closes expo go and the app without any msg

mortal haven
#

Is that crash on start? or on some particular screen?

nocturne coyote
#

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
});

mortal haven
#

That looks correct to me

#

Is there any message on your IDE? like after the crash happened?

nocturne coyote
#

nothing and my phone thinks the app is still running but the app is gone

mortal haven
nocturne coyote
#

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