#ayushh_webhooks
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1346333274959515659
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- ayushh_webhooks, 3 days ago, 53 messages
- ayushh_webhooks, 3 days ago, 13 messages
hello! you mention :
At the first, the subscription status is active but then another webhook event gets triggered which makes it incomplete.
What webhook event are you listening for, and triggering against to update the subscription tier of your user?
case "customer.subscription.created":
subscription = event.data.object;
status = subscription.status;
const metadata = event.data.object.metadata;
console.log("Subscription created: ", subscription);
// Store the new subscription
await storage.updateUserSubscription(
metadata.userId,
subscription.id,
status,
"seasdf",
);
break;
if the customer is new then this
case "customer.subscription.updated":
subscription = event.data.object;
status = subscription.status;
console.log("Subscription Update: ", subscription);
// Update subscription status
await storage.updateUserSubscription(
subscription.customer as string,
subscription.id,
status,
);
break;
if he updates/cancel his subscription plan then this
I believe I am missing a few keys too but first make sure that the creation works
const session = await stripe.checkout.sessions.create({
billing_address_collection: "auto",
line_items: [
{
price: priceId,
quantity: 1,
},
],
mode: "subscription",
subscription_data: {
metadata: {
userId,
},
},
allow_promotion_codes: true,
success_url: `${req.protocol}://${req.get("host")}/?success=true&session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${req.protocol}://${req.get("host")}/?canceled=true`,
});
I am passing metadata through the subscription_data
but I think it is missing
I do see the metadata in both events
this is the subscription.created event : https://dashboard.stripe.com/test/events/evt_1QymjUKvfF85f0JWG6w6Ge6M
this is the subscription.updated event : https://dashboard.stripe.com/test/events/evt_1QymjUKvfF85f0JWSfTbafjP
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
oh
Stripe does not guarantee the order of delivery : https://docs.stripe.com/webhooks#event-ordering, which means that events may not be delivered in sequence. What's likely happening for you, is that you're receiving the customer.subscription.updated webhook first, and then you're receiving the customer.subscription.created. It mostly looks like you're just updating the subscription details in your database for both the webhooks, in which case, you may want to consider simply making another API request to retrieve the latest state of the subscription