Skip to content

Instantly share code, notes, and snippets.

@mihaiandrei97
Created January 11, 2025 07:39
Show Gist options
  • Save mihaiandrei97/e9405555cb42e573c2c411056dc10a2c to your computer and use it in GitHub Desktop.
Save mihaiandrei97/e9405555cb42e573c2c411056dc10a2c to your computer and use it in GitHub Desktop.
Create checkout with dynamic product
return stripe.checkout.sessions.create({
mode: 'subscription',
customer: stripeCustomerId,
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: 'usd',
unit_amount: productPrice,
product_data: {
name,
description,
images: [image],
},
recurring: {
interval: input.interval,
},
},
quantity: 1,
},
],
success_url: `${baseUrl}/payment/success`,
cancel_url: `${baseUrl}/payment/cancel`,
allow_promotion_codes: true,
automatic_tax: {
enabled: true,
},
customer_update: {
address: 'auto',
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment