#MYoussef-invoice-paid-diff

1 messages ยท Page 1 of 1 (latest)

frail temple
#

Hello ๐Ÿ‘‹
I can surely look into it.
Do you have any example event IDs available for these by any chance?

#

Wait found it

chrome rune
#

this is a test id "evt_1KlJ8EGjZDiWw2MlnVSBlr56"

when trigger customer.subscription.created

and in my webhook, i am trying to use this code to listen

if(stripeEvent.Type == Events.InvoicePaid)
{
// code to renew customer subscription in my site database

//NOTE: i want this function to be implemented only when subscription renewed not created
}

frail temple
#

It would say subscription_create for a new subscription
and say subscription_update if created by an update to a subscription

chrome rune
frail temple
#

do you have the event ID for when you trigger customer.subscription.updated?

chrome rune
#

evt_1KlJGWGjZDiWw2MlkQIaEkDK

frail temple
#

are these events for two different subscriptions?

chrome rune
#

yes, and for your information i am trying to do it from stripe cli

frail temple
#

so you're using stripe trigger customer.subscription.updated and looking at the invoice.paid event?

chrome rune
#

yes

frail temple
#

This creates a new subscription every time hence the invoice.paid event on it would say subscription_create.
I haven't tested this but you should be able to do this via the dashboard. You can update a subscription with proration which should create an invoice which once paid should show the correct reason there.

chrome rune
#

is there any chance to test it locally

#

?

frail temple
#

let me quickly check something

#

Yeah I don't think CLI can support this by default unless you build your own fixture.

chrome rune
#

if i update it from dashboard, will it hit the local webhook, or it is a must to use a public url ?

frail temple
#

You should be able to listen to it locally

chrome rune
#

got it

#

i found that there is subscription_cycle

#

should i use it in my code or subscription_update is the proper one

#

i update my webhook like that

if (event.type == invoice.paid && event.billing_reason == "subscription_update" ){

// update my database with renewal

}

#

is that code logic correct or i should use subscription_cycle

#

?

frail temple
#

If you're checking for renewal you should use subscription_cycle

#

I've got to hop off now but @rotund spoke should be able to help you if you have any follow up questions ๐Ÿ™‚

#

Good luck

chrome rune
#

Thanks

#

@rotund spoke as per henzo recommendation i should check if billing reason = subscription_cycle for subscription renewal in webhook

if i create subscription with 1 year trail, after 1 year and when the customer auto-charged for the new year after trial (will billing_reason = subscription_cycle also)

#

?

rotund spoke
#

correct that should be the case

#

for the after-trial payment

chrome rune
#

so in renewal and after trial to update my site database by webhook, the below code logic is correct?

if (event.type == invoice.paid && event.billing_reason == "subscription_cycle" ){

// update my database with renewal or renewal after-trial

}

#

?

rotund spoke
#

yes correct