Skip to content

Commit

Permalink
stripe update
Browse files Browse the repository at this point in the history
  • Loading branch information
fac3m4n committed Apr 14, 2024
1 parent d6125e5 commit 571961a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions StripeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ export class StripeService {
mode: "payment",
success_url: `${process.env.FRONTEND_URL}?success=true`,
cancel_url: `${process.env.FRONTEND_URL}?canceled=true`,
metadata: {
userId: userId,
},
});

await this.pool.query(
"update credits set credits = credits + 10 where userId = $1",
[userId]
);

return stripePromise.url || "";
}

Expand All @@ -61,10 +63,6 @@ export class StripeService {
if (event.type === "checkout.session.completed") {
const session = event.data.object;
console.log("Fulfilling order", session);
await this.pool.query(
"update credits set credits = credits + 10 where userId = $1",
[session.metadata!.userId]
);

console.log("Order fulfilled successfully"); // Log when the order is fulfilled successfully
return { statusCode: "200", body: "Order fulfilled" };
Expand Down

0 comments on commit 571961a

Please sign in to comment.