#maufcost-react-native

1 messages · Page 1 of 1 (latest)

tame hull
#

Hi there!

formal glade
#

Hey! 🙂

tame hull
#

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?

formal glade
tame hull
#

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

formal glade
#

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

tame hull
#

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

formal glade
#

Yep.

I get the confirm hook from: const { confirmPayment } = useStripe()

And confirm as such:
const { paymentIntent, error } = await confirmPayment(clientSecret, {
paymentMethodType: 'Card',
paymentMethodData: { billingDetails },
})

tame hull
#

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

formal glade
#

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

tame hull
#

Can you share your full client-side code?

#

And have you added logs to each step?

formal glade
formal glade
#

And the import and the hook respectively come from:
import { CardField, useStripe } from '@stripe/stripe-react-native';

#

const { confirmPayment } = useStripe()

tame hull
#

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

formal glade
#

Is this because I'm using the 424242... card with my live keys?

tame hull
#

You need to use your test secret and publishable keys here

#

Yep

formal glade
#

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?

tame hull
#

Yes, however testing in live mode is against card network regulations so I can't recommend that you do that.

formal glade
#

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?

tame hull
#

Yep

formal glade
#

Dude. This is awesome. Thanks for the very prompt help. You guys rock.