accounts/**
This commit is contained in:
parent
80fe23b1cb
commit
4dee4b5037
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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`,
|
||||
});
|
||||
|
||||
|
|
Reference in New Issue