#krishna008

1 messages ยท Page 1 of 1 (latest)

desert siloBOT
#

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.

errant gull
#

hi there!

#

I'm not sure I understand your question. can you clarify with a concrete example?

small canyon
#

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.

errant gull
#

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

small canyon
#

is subscription id different for each cycle?

errant gull
#

no it's the same ID

small canyon
#

How can I differentiate first,second, third.... cycles?

errant gull
#

this info is not directly available in the Stripe API. but like I said, you could store that info in your own database

small canyon
#

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.

errant gull
#

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.

small canyon
#

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?

errant gull
#

the Subscription ID stays the same for each cycle. But each cycle should generate a new invoice ID

small canyon
#

Is subscription.update evnet proivide invoice id?

errant gull
small canyon
#

Yes got it sir.

#

Thank you .

errant gull
#

happy to help ๐Ÿ™‚

small canyon
#

Have a nice day ๐Ÿ™‚