From 4ed19f6535a54e62b7447341e84ecbb72d4a5e61 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Thu, 25 Feb 2021 11:33:57 +0100 Subject: [PATCH] accounts/** --- packages/dashboard/src/pages/api/stripe/activeSubscription.js | 3 ++- packages/dashboard/src/pages/api/stripe/customerPortal.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/dashboard/src/pages/api/stripe/activeSubscription.js b/packages/dashboard/src/pages/api/stripe/activeSubscription.js index 8f7a4e1e..815355d7 100644 --- a/packages/dashboard/src/pages/api/stripe/activeSubscription.js +++ b/packages/dashboard/src/pages/api/stripe/activeSubscription.js @@ -5,7 +5,8 @@ const stripe = new Stripe(process.env.STRIPE_SECRET_KEY); export default async (req, res) => { try { - const stripeCustomerId = "cus_J09ECKPgFEPXoq"; + const authorization = req.headers.authorization; // authorization header from request + const { stripeCustomerId } = await got("http://accounts:3000/user", { headers: { authorization } }); const stripeCustomer = await stripe.customers.retrieve(stripeCustomerId); const { subscriptions } = stripeCustomer; diff --git a/packages/dashboard/src/pages/api/stripe/customerPortal.js b/packages/dashboard/src/pages/api/stripe/customerPortal.js index 836ad173..6e55bdb3 100644 --- a/packages/dashboard/src/pages/api/stripe/customerPortal.js +++ b/packages/dashboard/src/pages/api/stripe/customerPortal.js @@ -5,7 +5,8 @@ const stripe = new Stripe(process.env.STRIPE_SECRET_KEY); export default async (req, res) => { try { - const stripeCustomerId = "cus_J09ECKPgFEPXoq"; + const authorization = req.headers.authorization; // authorization header from request + const { stripeCustomerId } = await got("http://accounts:3000/user", { headers: { authorization } }); const session = await stripe.billingPortal.sessions.create({ customer: stripeCustomerId, return_url: `${process.env.SKYNET_DASHBOARD_URL}/payments`,