payments
This commit is contained in:
parent
932a7f10a8
commit
5ce0f73293
|
@ -31,20 +31,21 @@ 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 } }).json();
|
||||
const customer = await getStripeCustomer(user);
|
||||
// const customer = await getStripeCustomer(user);
|
||||
|
||||
if (!user.stripeCustomerId) {
|
||||
await got.put(`http://accounts:3000/user`, {
|
||||
headers: { authorization },
|
||||
json: { stripeCustomerId: customer.id },
|
||||
});
|
||||
}
|
||||
// if (!user.stripeCustomerId) {
|
||||
// await got.put(`http://accounts:3000/user`, {
|
||||
// headers: { authorization },
|
||||
// json: { stripeCustomerId: customer.id },
|
||||
// });
|
||||
// }
|
||||
|
||||
const session = await stripe.checkout.sessions.create({
|
||||
mode: "subscription",
|
||||
payment_method_types: ["card"],
|
||||
line_items: [{ price, quantity: 1 }],
|
||||
customer: customer.id,
|
||||
customer: user.stripeCustomerId,
|
||||
customer_email: user.stripeCustomerId ? undefined : user.email,
|
||||
client_reference_id: user.id,
|
||||
// ?session_id={CHECKOUT_SESSION_ID} means the redirect will have the session ID set as a query param
|
||||
success_url: `${process.env.SKYNET_DASHBOARD_URL}/payments?session_id={CHECKOUT_SESSION_ID}`,
|
||||
|
|
Reference in New Issue