#krishna008
1 messages ยท Page 1 of 1 (latest)
Hello! We'll be with you shortly. 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.
- krishna008, 1 hour ago, 22 messages
- krishna008, 6 hours ago, 61 messages
hi there!
I'm not sure I understand your question. can you clarify with a concrete example?
I am using customer.subscription.updated webhook but first time I am alredy saving data to db from another enpoint & second time I want to save data using webhook but webhook is hitting first time also
I want to apply condition that code inside webhook should not run for firt cycle
In Razorpay there is key paid_count for each cycle so there I have alreadly applied condition but in Stripe there is no such filed.
you can store the Subscription ID in your own database. so when you receieve a webhook event for a Subscription you've already processed, you can run a different code
is subscription id different for each cycle?
no it's the same ID
How can I differentiate first,second, third.... cycles?
this info is not directly available in the Stripe API. but like I said, you could store that info in your own database
or count the number of invoice in the subscription with https://stripe.com/docs/api/invoices/list
or maybe check the invoice number: https://stripe.com/docs/api/invoices/object#invoice_object-number
I think this logic will not work.
I am already saving data to database before webhook hit (for first cycle)
So same webhook is hitting for first time also.
I have code to save data from second cycle only.
I don't want to run specific code for first cycle because there is already data saved from another endpoint.
So it it important to diffrentiate which cycle it is.
like I said at the beginning, why don't you store in your own database the cycle number? and then use this in your webhook event code.
Okay I got one logic for that. I think that will work.
I have another question: is there any unique id for each subscription cycle?
the Subscription ID stays the same for each cycle. But each cycle should generate a new invoice ID
Is subscription.update evnet proivide invoice id?
yes, you'll get a Subscription object, which contains latest_invoice with the Invoice ID: https://stripe.com/docs/api/subscriptions/object#subscription_object-latest_invoice
happy to help ๐
Have a nice day ๐