1 // This is a public sample test API key.
2 // To avoid exposing it, don't submit any personally identifiable information through requests with this API key.
3 // Sign in to see your own test API key embedded in code samples.
4 let stripe = require('stripe')
7 let config = await env.site.get_json('/_config/config.json')
9 let stripe_inst = stripe(config.secret_key)
10 let session = await stripe_inst.checkout.sessions.create(
14 // Provide the exact Price ID (for example, pr_1234) of the product you want to sell
15 price: config.price_id,
20 success_url: `${config.your_domain}/success.html`,
21 cancel_url: `${config.your_domain}/cancel.html`,
25 env.response.setHeader('Location', session.url)
26 env.site.serve(env, 303, Buffer.alloc(0), 'create-checkout-session.html.jst')