mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-07-28 05:38:38 -05:00
Moved webhook timestamp check to after PNID check
This commit is contained in:
parent
885e4d7b17
commit
f2115f2ba4
14
src/util.js
14
src/util.js
|
|
@ -263,13 +263,6 @@ async function handleStripeEvent(event) {
|
|||
const pid = Number(customer.metadata.pnid_pid);
|
||||
const pnid = await database.PNID.findOne({ pid });
|
||||
|
||||
const latestWebhookTimestamp = pnid.get('connections.stripe.latest_webhook_timestamp');
|
||||
|
||||
if (latestWebhookTimestamp && latestWebhookTimestamp > event.created) {
|
||||
// Do nothing, this webhook is older than the latest seen
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pnid && subscription.status !== 'canceled' && subscription.status !== 'unpaid') {
|
||||
// PNID does not exist. Abort and refund!
|
||||
logger.error(`PNID PID ${pid} does not exist! Found on Stripe user ${customer.id}! Refunding order`);
|
||||
|
|
@ -294,6 +287,13 @@ async function handleStripeEvent(event) {
|
|||
return;
|
||||
}
|
||||
|
||||
const latestWebhookTimestamp = pnid.get('connections.stripe.latest_webhook_timestamp');
|
||||
|
||||
if (latestWebhookTimestamp && latestWebhookTimestamp > event.created) {
|
||||
// Do nothing, this webhook is older than the latest seen
|
||||
return;
|
||||
}
|
||||
|
||||
const currentSubscriptionId = pnid.get('connections.stripe.subscription_id');
|
||||
const discordId = pnid.get('connections.discord.id');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user