mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-04-26 10:04:25 -05:00
Handle PNID not found error on all subscription types
This commit is contained in:
parent
f2115f2ba4
commit
9efb061a7e
|
|
@ -263,8 +263,10 @@ async function handleStripeEvent(event) {
|
|||
const pid = Number(customer.metadata.pnid_pid);
|
||||
const pnid = await database.PNID.findOne({ pid });
|
||||
|
||||
if (!pnid && subscription.status !== 'canceled' && subscription.status !== 'unpaid') {
|
||||
// PNID does not exist. Abort and refund!
|
||||
if (!pnid) {
|
||||
// PNID does not exist
|
||||
if (subscription.status !== 'canceled' && subscription.status !== 'unpaid') {
|
||||
// Abort and refund!
|
||||
logger.error(`PNID PID ${pid} does not exist! Found on Stripe user ${customer.id}! Refunding order`);
|
||||
|
||||
await stripe.subscriptions.del(subscription.id);
|
||||
|
|
@ -283,6 +285,9 @@ async function handleStripeEvent(event) {
|
|||
} catch (error) {
|
||||
logger.error(`Error sending email | ${customer.id}, ${customer.email} | - ${error.message}`);
|
||||
}
|
||||
} else {
|
||||
logger.error(`PNID PID ${pid} does not exist! Found on Stripe user ${customer.id}!`);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user