#Osiris

1 messages · Page 1 of 1 (latest)

pallid bronzeBOT
dawn iron
#

Have you tried immediately making the calls to finalize and attempt payment on the invoice? I think that would make the subscription go to what you have this set to in your settings

fiery kernel
#

I thought of this but can't think of a reliable trigger. What do you suggest ?

dawn iron
#

The invoice.created event should be sent every time this happens

#

Or customer.subscription.updated which may be better if you are asking specifically about doing this when they leave a trialing state. You can check the invoice's previous status (if it has changed) in the previous_attributes property on the event

fiery kernel
#

yeah but its still not reliable as the invoice may have been paid.

#

will have to fetch latest_invoice's payment status

#

its create_invoice on missing payment method. if payment method is there, it would charge it automatically

dawn iron
#

I may not be picturing this right. So you have a trialing subscription, it's trial ends and it goes to some price that requires payment

#

And then you are calling create invoice to double check the default payment method is chargable?

#

Or is create invoice for something else?

fiery kernel
#

I am creating checkout link from following settings:

subscription_data: {
                trial_settings: {
                    end_behavior: { missing_payment_method: 'create_invoice' }
                },
                trial_period_days:7

            },
#

sorry edited.

#

so when trial ends after 7 days, if payment-method is missing it creates invoice otherwise just charges the pm

#

above aside, finalising invoice didn't charge the customer as there is no pm and it says retry in 1 hour ?

pallid bronzeBOT
raw jacinth
#

👋 stepping in

#

Not sure I understand the question here

fiery kernel
#

wait lets restart

raw jacinth
#

Yes it will behave as you described if there is no PaymentMethod collected... an Invoice will be created and attempt to charge

fiery kernel
#

I need a way to move subscription to non-terminal state (not cancelled) when payment-collection isn't possible. immediately not after being active for 1 hour

raw jacinth
#

It shouldn't move to canceled until all of your retries are expired

fiery kernel
#

I am talking about trial to active transition not recurring

#

we have some restrictions in place for trialing status compared to active in our product. Now the main issue is just after trial ends, for 1 hour atleast subscriptions remain active ! And during this window people get free-reign

raw jacinth
#

It shouldn't be active? It should move to past_due, no?

#

Can you share an example Subscription ID that I can look at?

fiery kernel
#

sub_1Mr0ciLJhqt57ntnCLqSAKoq

#

at exactly 8:39IST this moved to active from trialing and a draft invoice was created. I tried to fail the invoice by manually finalizing it via api. Its finalized now but will be charged in 1 hour remained.

raw jacinth
#

Looking

#

Looks like you finalized the invoice yourself instead of letting the Subscription cycle as normal?

#

Ah sorry

#

I see what you are saying

#

So what you want to do then is listen for customer.subscription.updated for when a Sub moves from trialing --> active

#

If you just finalize it will still wait an hour to charge

fiery kernel
#

hmm ok. So

  • check for trialing -> active
  • check whether latest invoice was created within last few minutes and unpaid.
  • pay immediately
raw jacinth
#

Yep pretty much

fiery kernel
#

cool thanks I was missing the pay part. Still lot of work for just marking a subscription overdue/past_due

raw jacinth
#

Well it would be marked past_due automatically in 1 hour when the automatic payment fails

#

But if you don't want to provision for this one hour then you have to handle that yourself

fiery kernel
#
trial_settings: {                end_behavior: { missing_payment_method: 'cancel' }
},

This should support past_due maybe.(personal opinion) There is no point in creating invoice when payment-method is absent ?

#

anyways no point in discussing unsupported feature. Thanks for help !

#

wait, @raw jacinth pay doesn't work when method is absent ! The api failed.

raw jacinth
#

Right that should happen and move the Sub to past_due, no?

fiery kernel
#

oh right it moved. My bad. had to refresh, it was cached