Skip to content

Instantly share code, notes, and snippets.

@tanvirstreame
Last active April 3, 2021 19:15
Show Gist options
  • Select an option

  • Save tanvirstreame/f783f41923079427656bbd3fa8acc1a1 to your computer and use it in GitHub Desktop.

Select an option

Save tanvirstreame/f783f41923079427656bbd3fa8acc1a1 to your computer and use it in GitHub Desktop.
const stripe = require('stripe')((process.env.STRIPE_PRIVATE_SECRET));
productList.forEach(element => {
line_items.push({
price_data: {
currency: 'usd',
product_data: {
name: element?.name,
},
unit_amount: Math.ceil((finalPrice / 85) * 100 ), // If bangladeshi currency
},
quantity: 1,
})
});
const session = await stripe.checkout.sessions.create({
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
payment_method_types: ['card'],
line_items,
mode: 'payment',
client_reference_id: "You can use order id here"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment