#arielbo-subscription-webhooks

1 messages · Page 1 of 1 (latest)

wind forge
#

Hey there 👋 what is it you're looking for help with?

torn yarrow
#

hello toby

#

I want to understand how the logic of the first, second and subsequent payments with subscriptions works, I am using the invoice.payment.succeeded event, what I do not understand is how I will know if it is a new payment

#

?

hexed saddle
#

What do you mean here by "new payment"?

#

The reason will be subscription_create if this is the first payment and subscription_cycle for renewal payments

torn yarrow
#

In my database I am saving the subscription id and I can use that data to identify the event (invoice.payment.succeeded) when they send it to me but I would like to know if they will also send me the new subscription start and end dates

torn yarrow
hexed saddle
#

The billing_reason will be subscription_cycle if this is payment is to renew the subscription

torn yarrow
#

well you say that when I receive the event invoice.payment.succeeded i need to read billing_reason and if this is in subscription_cycle this is a renew payment? right

hexed saddle
#

Yes that sounds right

#

Also we typically recommend listening to invoice.paid for this

#

That event is triggered every time invoice.payment.succeeded is triggered and it also includes out of band payments

torn yarrow
#

you advise me for listen renews use invoice.paid more than invoice.payment.succeeded?

hexed saddle
#

Yes

torn yarrow
#

and inside the event invoice.paid use billing_reason for?

hexed saddle
#

Check if invoice.billing_reason == 'subscription_cycle'

#

If so then this invoice was generated for a renewal

torn yarrow
#

let me test

#

Pompey is correct that the first invoice.billing_reason is "billing_reason": "subscription_create", ?

#

how can I testing one renew payment to check invoice.billing_reason == 'subscription_cycle' ?

frozen wharf
torn yarrow
#

thank you, please how can I trigger one renew payment?

frozen wharf
#

it's explained in details on that doc

#

you can't fast forward time, so the only way is to change the billing cycle, it's similar to the payment failure example

#

1/ Create a subscription with a short trial period, or billing_cycle_anchor a few minutes in the future
2/ Wait for the period or the trial to end
3/ New cycle starts, invoice.created is sent, as you needed

torn yarrow
#

let me see