bones225
bones225

Reputation: 1728

What Stripe webhook is used to capture subscription renewal when invoicing outside of Stripe?

I created a customer and subscription directly in the Stripe dashboard, as the customer is paying by check + invoicing outside of Stripe.

Stripe has been sending webhooks every month similarly to a normal credit card subscription, specifically the invoice webhooks (invoice.updated, invoice.finalized, invoice.sent), as well as customer.subscription.updated.

My app looks for the following webhooks to connect the billing events / actually upgrading the client's account:

customer.created
customer.subscription.created
customer.subscription.updated
customer.subscription.deleted
charge.succeeded

charge.succeeded has always been my go-to webhook to alert my app to update the client's account (e.g. supply the monthly benefit). My problem is that with invoicing, actually marking the invoice as "paid" lags 7-14 days behind the invoice generation and when the account is supposed to renew, so I can't use a invoice.paid as an equivalent to charge.succeeded.

I am trying to figure out what webhook is sent on the subscription renewal for a payment by check customer. customer.subscription.updated does happen upon subscription renewal, however that could be triggered on plan change. Same thing with invoice.sent -- that also could happen upon plan change.

Is there a webhook specifically for "this client's subscription just renewed, regardless of whether they paid already or not"?

Upvotes: 4

Views: 2657

Answers (2)

Check out this answer from here. It basically answers your question about stripe renewal webhook.

https://stackoverflow.com/a/54165193

Basically you can use the webhook 'invoice.payment_succeeded' and in its response look out for billing_reason.

If billing_reason == 'subscription_cycle' the webhook is for a subscription renewal.

If billing_reason == 'subscription_create' the webhook is for a brand new subscription.

Upvotes: 0

koopajah
koopajah

Reputation: 25552

There is no event specifically for the renewal. What you should do is listen for customer.subscription.updated events and then look at the data that changed to assess whether it's a renewal or not. The idea is to look inside data[previous_attributes] (doc) on the Event and check whether the current_period_start and current_period_end properties have changed which would indicate a renewal (or a billing cycle change).

Upvotes: 6

Related Questions