Fix javascript missing let
[stripe_example_site.git] / create-checkout-session.html.jst
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')
5
6 return async env => {
7   let config = await env.site.get_json('/_config/config.json')
8
9   let stripe_inst = stripe(config.secret_key)
10   let session = await stripe_inst.checkout.sessions.create(
11     {
12       line_items: [
13         {
14           // Provide the exact Price ID (for example, pr_1234) of the product you want to sell
15           price: config.price_id,
16           quantity: 1,
17         },
18       ],
19       mode: 'payment',
20       success_url: `${config.your_domain}/success.html`,
21       cancel_url: `${config.your_domain}/cancel.html`,
22     }
23   )
24
25   env.response.setHeader('Location', session.url)
26   env.site.serve(env, 303, Buffer.alloc(0), 'create-checkout-session.html.jst')
27 }