Skip to content

Commit

Permalink
update stripe
Browse files Browse the repository at this point in the history
  • Loading branch information
fac3m4n committed Apr 14, 2024
1 parent acfb5f8 commit d6125e5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions StripeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ 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 @@ -63,6 +61,10 @@ 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 d6125e5

Please sign in to comment.