Integrate Stripe Checkout to Purchase Products in Next.js with Stripe @stripe/stripe-js Cl

InstructorColby Fayock

Share this video with your friends

Send Tweet

Now that we have an app and our products configure in Stripe, it's time to connect the two and give people a way to purchase our products.

Using Stripe's API, we can initiate a new instance of the Stripe Checkout flow with a simple click of a button.

We'll create an initiateCheckout function that handles this flow for us. After loading stripe through @stripe/stripe-js we'll await a stripePromise that will allow us to redirect to stripes checkout flow. You'll notice that we will need to pass in line items with the price id and quantity.

Navneet Kumar Sharma
~ 4 years ago

can you please share your vscode editor settings (font-family)?

Navneet Kumar Sharma
~ 4 years ago

which extension shows the import library size?

Colby Fayockinstructor
~ 4 years ago

can you please share your vscode editor settings (font-family)?

Font family is VS Code default Menlo, Monaco, 'Courier New', monospace Theme is Night Owl https://marketplace.visualstudio.com/items?itemName=sdras.night-owl

which extension shows the import library size?

Extension is https://marketplace.visualstudio.com/items?itemName=wix.vscode-import-cost

~ 3 years ago

Could you explain the following error message I return when I click the 'Buy Now!' button? :

Client-only Checkout does not support prices with usage_type=metered in items[0].

Colby Fayockinstructor
~ 3 years ago

Could you explain the following error message I return when I click the 'Buy Now!' button? :

Client-only Checkout does not support prices with usage_type=metered in items[0].

That looks like a Stripe error, I'm not sure about that. It seems that you may be trying to use "metered" billing that's not supported with the client-only checkout.

Aryan Raj Sinha
~ 3 years ago

Hi! I did all the things you are doing, and added lineItems too. There's still an error that's coming both after deployment and on localhost.

It says this - "v3:1 Uncaught (in promise) IntegrationError: stripe.redirectToCheckout: successUrl must start with either http:// or https://."

I went over to network and searched stripe, then reloaded it too. I'm not sure what's happening.

Kindly help!

HUgo
~ 3 years ago

Hello, I'm around 4:20 and when I click on the button the error i have is this

v3:1 Uncaught (in promise) IntegrationError: The domain (http://localhost:3000/) that redirected to Checkout is not enabled in the dashboard. Add this domain at https://dashboard.stripe.com/account/checkout/settings. at rn (v3:1) at e._handleMessage (v3:1) at e._handleMessage (v3:1) at v3:1

I did try to enable it in the dashboard, but the problem is that I can't enable localhost3000, it doesn't let me do so.

Jose Paitamala
~ 3 years ago

Hi, Having the same problem as Hugo, v3:1 Uncaught (in promise) IntegrationError: The domain (http://localhost:3000/) that redirected to Checkout is not enabled in the dashboard. Add this domain at https://dashboard.stripe.com/account/checkout/settings.

Even though I am in Test mode in stripe. Any help please?

Jose Paitamala
~ 3 years ago

Hi again, it seems I was using the Stripe API key for live and not for test mode, I have put the test mode API key in .env.local and also in Vercel environment variable, I also made sure that the product price IDs where the ones from test mode and not from live mode, cause it seems they are different. Now all seems to work.

~ 2 years ago

I'm getting this error when clicking on Buy Button

IntegrationError: Invalid value for stripe.redirectToCheckout: lineItems.0.price should be a string. You specified: 1

Lucas Minter
~ 2 years ago

I would start by double-checking your code. Here is the start of the next lesson for the index.js file and here is the start for the payments.js file.