accounts/**

This commit is contained in:
Karol Wypchlo 2021-02-25 11:45:57 +01:00
parent 80fe23b1cb
commit 4dee4b5037
3 changed files with 4 additions and 5 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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`,
});