From 4dee4b5037a8f1689711f349ea082c187a75a4b4 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Thu, 25 Feb 2021 11:45:57 +0100 Subject: [PATCH] accounts/** --- .../dashboard/src/pages/api/stripe/activeSubscription.js | 2 +- .../dashboard/src/pages/api/stripe/createCheckoutSession.js | 2 +- packages/dashboard/src/pages/api/stripe/customerPortal.js | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/dashboard/src/pages/api/stripe/activeSubscription.js b/packages/dashboard/src/pages/api/stripe/activeSubscription.js index 10c787f1..f5a87e99 100644 --- a/packages/dashboard/src/pages/api/stripe/activeSubscription.js +++ b/packages/dashboard/src/pages/api/stripe/activeSubscription.js @@ -7,7 +7,7 @@ const stripe = new Stripe(process.env.STRIPE_SECRET_KEY); export default async (req, res) => { try { const authorization = req.headers.authorization; // authorization header from request - const { stripeCustomerId } = await got("http://accounts:3000/user", { headers: { authorization } }); + const { stripeCustomerId } = await got("http://accounts:3000/user", { headers: { authorization } }).json(); const stripeCustomer = await stripe.customers.retrieve(stripeCustomerId); const { subscriptions } = stripeCustomer; diff --git a/packages/dashboard/src/pages/api/stripe/createCheckoutSession.js b/packages/dashboard/src/pages/api/stripe/createCheckoutSession.js index a3dc0698..b2819fdd 100644 --- a/packages/dashboard/src/pages/api/stripe/createCheckoutSession.js +++ b/packages/dashboard/src/pages/api/stripe/createCheckoutSession.js @@ -30,7 +30,7 @@ export default async (req, res) => { // For full details see https://stripe.com/docs/api/checkout/sessions/create try { const authorization = req.headers.authorization; // authorization header from request - const user = await got("http://accounts:3000/user", { headers: { authorization } }); + const user = await got("http://accounts:3000/user", { headers: { authorization } }).json(); const customer = await getStripeCustomer(user.stripeCustomerId); if (!user.stripeCustomerId) { diff --git a/packages/dashboard/src/pages/api/stripe/customerPortal.js b/packages/dashboard/src/pages/api/stripe/customerPortal.js index d43983a6..0d7c0516 100644 --- a/packages/dashboard/src/pages/api/stripe/customerPortal.js +++ b/packages/dashboard/src/pages/api/stripe/customerPortal.js @@ -7,10 +7,9 @@ const stripe = new Stripe(process.env.STRIPE_SECRET_KEY); export default async (req, res) => { try { const authorization = req.headers.authorization; // authorization header from request - const user = await got("http://accounts:3000/user", { headers: { authorization } }); - console.log(user); + const { stripeCustomerId } = await got("http://accounts:3000/user", { headers: { authorization } }).json(); const session = await stripe.billingPortal.sessions.create({ - customer: user.stripeCustomerId, + customer: stripeCustomerId, return_url: `${process.env.SKYNET_DASHBOARD_URL}/payments`, });