payments
This commit is contained in:
parent
c8c9d216ee
commit
220c68d196
|
@ -30,10 +30,10 @@ 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 { stripeCustomerId } = await got("http://accounts:3000/user", { headers: { authorization } }).json();
|
||||
const customer = await getStripeCustomer(stripeCustomerId);
|
||||
const user = await got("http://accounts:3000/user", { headers: { authorization } }).json();
|
||||
const customer = await getStripeCustomer(user.stripeCustomerId);
|
||||
|
||||
if (!stripeCustomerId) {
|
||||
if (!user.stripeCustomerId) {
|
||||
await got.put(`http://accounts:3000/user`, {
|
||||
headers: { authorization },
|
||||
json: { stripeCustomerId: customer.id },
|
||||
|
@ -45,6 +45,7 @@ export default async (req, res) => {
|
|||
payment_method_types: ["card"],
|
||||
line_items: [{ price, quantity: 1 }],
|
||||
customer: customer.id,
|
||||
customer_email: user.email,
|
||||
// ?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}`,
|
||||
cancel_url: `${process.env.SKYNET_DASHBOARD_URL}/payments`,
|
||||
|
|
Reference in New Issue