DEV Community

Working with Stripe Payment Intents and Next.js

Jamie Barton on March 18, 2020

On September 14, 2019, Stripe introduced a API for handling payments to comply with new European legislation. If you are already using Stripe, you'...
Collapse
 
notrab profile image
Jamie Barton

Another important factor to remember is the Idempotencey Key you can send with the payment intent. This typically would be an ID for the cart/checkout you want to pay for. This means the same cart/checkout can't be paid for twice with Stripe.

Collapse
 
tesshsu profile image
tess hsu

Hi Jamie,
I had install the code package from github, and replace my strip security and public key in test mode, it's working to send payment ( incomplete ) in strip dashboard

But once I click button "Pay now"
show error : Cannot read property 'status' of undefined

I had looking for this error in strip or doc but nothing to find out
Do you have clue ? I do like your tutorial in localhost:3000/checkout

Collapse
 
tesshsu profile image
tess hsu

Sorry Jamie
problem resolved, I missing zip code which I do not fill in, sorry being bother

Collapse
 
jai_type profile image
Jai Sandhu

This was amazing to read, thank you so much! What would be the best way to update a paymentId? In the example it's hard-coded, I see from the stripe documentation it is:

const paymentIntent = await stripe.paymentIntents.update(
'pi_1Iqi23IWWEwahlPoqvpAjRHr',
{metadata: {order_id: '6735'}}
);

Could I grab stripe using the useStripe hook and update the payment intent using it's id?

Collapse
 
wyjbuss profile image
Wyatt Bussell

Is there a preferred way of keeping track of inventory and showing what items were purchased? I also need information such as location to ship to and email of customer. I saw Itempotencey ID in the comments. Im using a mongo database as well. Would the best way to do this be creating a customer in stripe before they pay?