#romerocox-Subscription

1 messages ยท Page 1 of 1 (latest)

sturdy forge
narrow frigate
#

But it could also be the trial will end, depending on what you mean by "expiring".

errant sapphire
#

I'm monitoring the trial_end, so I wanted to be notified when the subscription is 3 days from ending

sturdy forge
errant sapphire
#

I saw that the subscription_schedule.expiring will be triggered 7 days away, right?

#

Perfect!

#

that is exactly what I was looking for! Thank you!

#

Guys, if the trial ends is there another event triggered?

sturdy forge
errant sapphire
#

Yeah, I'm working on that, the only thing is that I'd love to differentiate a trial_end from a "paid" subscription that wasn't renewed

#

One other question, I noticed that I can send the payment link once the trial has ended, is it possible to get that link from the trigger event and send it using my own method?

sturdy forge
#

What do you mean by trial_end from a paid subscription? Your customer doesn't need to pay if the subscription is in trial.

#

By payment link do you mean invoice?

errant sapphire
#

Yes, sorry!

#

lets tackle one at a time ๐Ÿ˜„ my bad

sturdy forge
#

No apologies needed ๐Ÿ™‚

errant sapphire
#

How should I approach this? Is it possible to get that invoice link and send it to the Customer using my own method?

sturdy forge
#

You can listen to invoice.finalized event (https://stripe.com/docs/api/events/types#event_types-invoice.finalized) and get the URL from the hosted_invoice_url property https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url

errant sapphire
#

and by using the customer_id I should be able to match them right?

#

every time a trial_ends, will this invoice be created?

sturdy forge
#

Yes you can check the invoice's customer to know which customer is this invoice issued to

errant sapphire
#

great

#

after X days if the invoice is not paid, then the subscription gets an update as well, right?

sturdy forge
errant sapphire
#

great, thanks!

#

how do I create a subscription with "send invoice after trial" instead of charge default payment ?

#

This is my sub creation:

            'customer' => $customer_id,
            'items' => [[
                'price' => $price_id,
            ]],
            'payment_behavior' => 'default_incomplete',
            'payment_settings' => ['save_default_payment_method' => 'on_subscription', 'payment_method_types'=>['card']],
            'expand' => ['pending_setup_intent'],
            "metadata" => ["cliente_id" => $membro->memberID],
            "trial_end"=> $unix
            
        ]);```
sturdy forge
#

Set the subscription's collection_method to send_invoice

errant sapphire
#

What about the payment methods? Would the payment method type do the trick for that too? Or do I need an extra parameter?

sturdy forge
errant sapphire
#

Thanks

errant sapphire
#

is it possible to get the previous status of a sub before an update?

sturdy forge
#

If you are listening to webhook events, you can get the previous attributes of the event object.

errant sapphire
#

I'm listening to the invoice.created but it seems like as soon as the invoice is created, it automatically updates the sub to active until the past_due date

#

Yeah, even before creating the invoice, the subscription is being updated to active

#

Not sure if this is only because I'm using the test clock

#

or if this is a default behavior and can be changed somewhere

sturdy forge
#

Did you set the collection_method to send_invoice ?

errant sapphire
#

Yes

#

Oh, it should be the default_incomplete parameter?

#

'payment_behavior' => 'default_incomplete',

#

Or this has nothing to do?

#

I'm still using this, not sure if I should remove it, or if it wouldn't make any difference.

sturdy forge
#

Use default_incomplete to create Subscriptions with status=incomplete when the first invoice requires payment, otherwise start as active.

errant sapphire
#

ok, what is happening here is the following:

sturdy forge
errant sapphire
#

The subscription gets created the way I want, no problem there.

When the trial ends, Stripe creates an invoice, and automatically updates the sub to active.
Then, Stripe waits for the amount of days I've chosen by default.

Because of this behavior, I cannot identify if the invoice was created for a subscription that was on trial or not.

#

Let me know if you understood my scenario please

#

As soon as the trial_ends the subscription becomes active.

#

I think that is whats happening