accounts/**

This commit is contained in:
Karol Wypchlo 2021-02-25 11:19:12 +01:00
parent 0996f9f265
commit 8e5e564158
1 changed files with 11 additions and 3 deletions

View File

@ -24,9 +24,6 @@ export default async (req, res) => {
return res.status(StatusCodes.BAD_REQUEST).json({ error: { message: "Missing 'price' attribute" } }); return res.status(StatusCodes.BAD_REQUEST).json({ error: { message: "Missing 'price' attribute" } });
} }
console.log(req.header);
console.log(req.headers);
// Create new Checkout Session for the order // Create new Checkout Session for the order
// Other optional params include: // Other optional params include:
// [billing_address_collection] - to display billing address details on the page // [billing_address_collection] - to display billing address details on the page
@ -34,6 +31,17 @@ export default async (req, res) => {
// [customer_email] - lets you prefill the email input in the form // [customer_email] - lets you prefill the email input in the form
// For full details see https://stripe.com/docs/api/checkout/sessions/create // For full details see https://stripe.com/docs/api/checkout/sessions/create
try { try {
const authorization = req.headers.authorization; // authorization header from request
const user = await got(`${process.env.SKYNET_DASHBOARD_URL}/user`, { headers: { authorization } });
if (!user.stripeCustomerId) {
const customer = await stripe.customers.create();
console.log(customer);
const user = await got.put(`/user`, { json: { stripeCustomerId } });
console.log(user);
}
const stripeCustomerId = "cus_J09ECKPgFEPXoq"; const stripeCustomerId = "cus_J09ECKPgFEPXoq";
const session = await stripe.checkout.sessions.create({ const session = await stripe.checkout.sessions.create({
mode: "subscription", mode: "subscription",