#maufcost-react-native
1 messages · Page 1 of 1 (latest)
Hey! 🙂
As the error states, you haven't collected a PaymentMethod yet so you can't confirm the PaymentIntent to create a charge.
What are you using on your front end?
Payment Sheet?
Card Form?
Correct. I'm using only the card form on the tutorial here: https://stripe.com/docs/payments/accept-a-payment?platform=react-native&ui=custom
Great
So as those docs point out, you don't pass confirm: true on your server.
You create the PaymentIntent on your server and then pass the client secret to your client.
From there you use confirmPayment() on your client to actually confirm the PaymentIntent and create the charge
I removed the confirm prop from the server side now. I'm already sending the client secret to the client. I'm going to run it without the confirm prop now. 1 sec
Ok. The payment intent is created, but the payment intent is not confirmed.
It says: The PaymentIntent requires a payment method
Correct.
Now you collect the PaymentMethod on the client via Card Form.
Then when the customer hits your "pay" button you call const {paymentIntent, error} = await confirmPayment(clientSecret, { paymentMethodType: 'Card', paymentMethodData: { billingDetails, }, });
Yep.
I get the confirm hook from: const { confirmPayment } = useStripe()
And confirm as such:
const { paymentIntent, error } = await confirmPayment(clientSecret, {
paymentMethodType: 'Card',
paymentMethodData: { billingDetails },
})
Yep all is correct then
So hook that up to your pay button
And then once you click "pay" you will see a successful PaymentIntent
That's so weird. It's already hooked up. I can see the function being called, but the payment intent is just created and not confirmed
Yes.
I can share some snippets. 1 sec
And the import and the hook respectively come from:
import { CardField, useStripe } from '@stripe/stripe-react-native';
const { confirmPayment } = useStripe()
Okay let's add a log for clientSecret right before confirmPayment()
Also what are you seeing in Metro?
Oh wait
You aren't logging paymentIntent or error
Okay yeah
So after confirmPayment log out error
There you go
So you are using the wrong keys
Is this because I'm using the 424242... card with my live keys?
Oh gotcha. I was using the 4242 card because I wanted to test if processing payments with the live keys would work
So, to really test the production keys, I need to use an actual card, right?
Yes, however testing in live mode is against card network regulations so I can't recommend that you do that.
Got it. So you can say that if processing payments works successfully with the test keys, it will work with the live keys just as fine with real cards?
Yep
Dude. This is awesome. Thanks for the very prompt help. You guys rock.