--- /dev/null
+{
+ "secret_key": "sk_test_wsFx86XDJWwmE4dMskBgJYrt",
+ "your_domain": "http://localhost:8080",
+ "price_id": "{{PRICE_ID}}"
+}
// This is a public sample test API key.
// To avoid exposing it, don't submit any personally identifiable information through requests with this API key.
// Sign in to see your own test API key embedded in code samples.
-const stripe = require('stripe')('sk_test_wsFx86XDJWwmE4dMskBgJYrt')
-
-const YOUR_DOMAIN = 'http://localhost:8080'
+let stripe = require('stripe')
return async env => {
- const session = await stripe.checkout.sessions.create(
+ let config = await env.site.get_json('/_config/config.json')
+
+ stripe_inst = stripe(config.secret_key)
+ let session = await stripe_inst.checkout.sessions.create(
{
line_items: [
{
// Provide the exact Price ID (for example, pr_1234) of the product you want to sell
- price: '{{PRICE_ID}}',
+ price: config.price_id,
quantity: 1,
},
],
mode: 'payment',
- success_url: `${YOUR_DOMAIN}/success.html`,
- cancel_url: `${YOUR_DOMAIN}/cancel.html`,
+ success_url: `${config.your_domain}/success.html`,
+ cancel_url: `${config.your_domain}/cancel.html`,
}
)