#Suren-subscriptions

1 messages · Page 1 of 1 (latest)

unborn shadow
#

hello @keen nimbus! do you have an example subscription id which we can look at?

keen nimbus
#

sub_1Jydx7BfTh1Z0SMkM6EJ8twL

#

the problem is that only after an hour does past_due become

unborn shadow
#

Most invoices generated for a subscription have a one hour period before finalization where changes can be made.

This behavior applies to all invoices except for the first invoice generated for a subscription where collection_method: charge_automatically.

For charge_automatically, the invoice only becomes past_due when payment is attempted and fails.

If you want the invoice to be paid immediately, you can use the API to finalize [0] and pay [1] the invoice after you receive the invoice.created event

[0] https://stripe.com/docs/api/invoices/finalize
[1] https://stripe.com/docs/api/invoices/pay

keen nimbus
#

If I use this, the subscription status will not be active if there is no payment?

unborn shadow
#

are you referring to the first payment?

keen nimbus
#

Well, my problem now is that after the end of the cycle, the status becomes active and I need to immediately send past_due instead

#

that is, I expect that the active status becomes after a successful payment

#

just want to understand if i set collection_method: 'charge_automatically' subscription status will not be active if no payment has been made

#

I just think that there is default to set this flag

unborn shadow
#

as you've already noticed, there's probably going to be a short period of time that the subscription is still active when the invoice has been created, but not yet finalized. You can minimize this time by using the API to immediately finalize and attempt payment. If the attempted payment fails, the subscription will change to past_due - this behaviour is applicable for charge_automatically

#

there are two options for collection_method : charge_automatically and send_invoice. As send_invoice implies, it will send your customer an invoice for them to fill up their payment details. I don't think this is what you'd want since it's completely different from charging automatically

keen nimbus
#

I understand so I can't achieve this result right?

#

I just don't want the stripe to send me the active status at all if there was no payment

#

because when the active status is sent to me, I think that the payment has been made

unborn shadow
#

no, you can't achieve this result. But why would receiving this status update be an issue?

#

ideally, the system would see that the status is active, and do nothing, since the previous status was also active

keen nimbus
#

the fact is that I confirm the payment through the subscription status

#

yes I thought so too

#

but in such a case how to check whether the payment was made or not

unborn shadow
#

Stripe will determine if the payment is made or not and update the subscription status accordingly. It would be easier for you to turn on/off your service based off the subscription status. If you want to also store the payment in your DB, then you can listen for the invoice.paid webhook event instead

keen nimbus
#

Will invoice.paid work after every subscription payment?

unborn shadow
#

out of curiosity, are you determining whether you should stop providing the service based on whether the user has completed payment?

keen nimbus
#

yes, only there if the payment is not made there I will post a retry

unborn shadow
#

sorry i didn't understand only there if the payment is not made there I will post a retry, could you maybe try to rephrase?

keen nimbus
#

I mean Payment retries

#

so i stuck to the view that i can listen to invoice.paid for love subscription

unborn shadow
#

is there a reason why you're not using automatic payment retries? there is a setting in the Dashboard for this

keen nimbus
#

and for update too?

unborn shadow
#

what do you want to update?

keen nimbus
#

i just want to understand invoice.paid will work for both subscription create and subscription update

unborn shadow
#

yes invoice.paid will generate for both subscription create and subscription update

keen nimbus
#

and i will get metadata what i passed to subscription

#

inside invoice.paid

unborn shadow
#

no, the invoice will not contain the subscription metadata

keen nimbus
#

in such a case, how to determine who paid?

#

or what is paid for

unborn shadow
keen nimbus
#

which means I have to send a request to get a subscription

unborn shadow
#

that's one option, or you can also store whatever data you need in your own database to be retrieved based off the subscription id or customer id

keen nimbus
#

so I listen to invoice.paid then I will find the subscription id there and for this id I can already get the metadata of this subscription

unborn shadow
#

yes, if that's the way you want to handle it

keen nimbus
#

I'm just looking at the subscription id there now

#

there is only a subscription without an id

unborn shadow
#

can you share the object id which you're looking at?

keen nimbus
unborn shadow
#

that's an example, it's possible that an invoice is created without a subscription as well. If you want to check how the event would look like, i would suggest using the events generated on your own Dashboard instead

keen nimbus
#

aaaa yes you are right thank you very much