#teddy06894

1 messages · Page 1 of 1 (latest)

upper ravineBOT
#

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.

rustic beacon
#

Sure, just what events to listen to overall? Or something else?

chrome violet
#

Hi!

#

Right now I am listening the following events:

  • customer.created -> To create the relationshipf between the stripe customer and my user in the database
  • customer.subscription.created -> To create the subscription for the user in my database
  • customer.subscription.deleted -> To cancel the subscription for a user in my database
  • invoice.paid -> depending on the billing_reason I have to implement the logic for a new subscription and a renew
#

With these events I have the full control for the new subscriptions and also for the cancellation but I think I will have problems for the renewals

rustic beacon
#

invoice.paid will also cover renewals, the billing_reason will be subscription_cycle I believe

chrome violet
#

Yeah, but I don't have the new current_period_start and current_period_end for the subscription, not?

#

Becase the event if an Invoice, not the subscription

rustic beacon
#

I think the invoice has info on the cycle that it is for, double checking

#

Otherwise you would either retrieve the subscription or start listening to customer.subscription.updated which will have the cycle info

chrome violet
#

If I listen to the customer.subscription.updated event I do get the new dates, but the status is still active with an invoice in draft.

#

What is the best way to implement the renewals? I mean, the best way for Stripe jeje

rustic beacon
#

To use some combination of these events and API calls

#

I thought invoice.paid also had some info on the billing period but I am not seeing it now

#

To clarify, this is expected behavior, the subscription's cycle does change when the draft invoice is created, and when the invoice is paid it will continue to be active for that full cycle

chrome violet
#

Yes, I have reviewed it and the event has the period_end and period_start

#

So, probably I can listen to the customer.subscription.updated change the current_period_start and the current_period_end

#

Keep the status of the subscription "active"

#

And if I receive a invoice.paid for this subscription with the status=paid everything would be okey

rustic beacon
#

Yep that sounds sensible to me

chrome violet
#

Perfect

#

Thanks!