mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-18 16:57:22 +02:00
🐛 Ensure we access latest subscription object
This commit is contained in:
parent
77dab8f0d6
commit
f10fd919c7
1 changed files with 6 additions and 2 deletions
|
@ -68,7 +68,9 @@ export default async function handler(
|
||||||
case "customer.subscription.deleted":
|
case "customer.subscription.deleted":
|
||||||
case "customer.subscription.updated":
|
case "customer.subscription.updated":
|
||||||
case "customer.subscription.created":
|
case "customer.subscription.created":
|
||||||
const subscription = event.data.object as Stripe.Subscription;
|
const { id } = event.data.object as Stripe.Subscription;
|
||||||
|
|
||||||
|
const subscription = await stripe.subscriptions.retrieve(id);
|
||||||
|
|
||||||
// check if the subscription is active
|
// check if the subscription is active
|
||||||
const isActive = subscription.status === "active";
|
const isActive = subscription.status === "active";
|
||||||
|
@ -103,7 +105,9 @@ export default async function handler(
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Unexpected event type
|
// Unexpected event type
|
||||||
console.error(`Unhandled event type ${event.type}.`);
|
res.status(400).json({
|
||||||
|
error: "Unhandled event type",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
res.end();
|
res.end();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue