Created
January 11, 2025 07:39
-
-
Save mihaiandrei97/e9405555cb42e573c2c411056dc10a2c to your computer and use it in GitHub Desktop.
Create checkout with dynamic product
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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