Skip to content

Commit

Permalink
🐛 Fix lifetime rank purchase with promo code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nachwahl committed Aug 16, 2024
1 parent 472c352 commit 2fdc962
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/controllers/PaymentController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,34 @@ class PaymentController {
}
});
this.syncRoles(user.id);
break;
case 'checkout.session.completed':
const session = event.data.object;
// get checkout session
this.core.stripeClient.checkout.sessions.retrieve(session.id).then(async session => {
// get if lifetime plus is in session
if (session.line_items.data.some(item => item.price.id === process.env.STRIPE_PRICE_ONETIME)) {
const user = await this.core.prisma.user.findUnique({
where: {
id: session.metadata.userId
}
});
if (!user) {
response.status(400).send({error: 'User not found'});
return;
}
await this.core.prisma.user.update({
where: {
id: user.id
},
data: {
plus: true
}
});
this.syncRoles(user.id);
}
});
break;

}
response.send({received: true});
Expand Down

0 comments on commit 2fdc962

Please sign in to comment.