#romerocox-Subscription
1 messages ยท Page 1 of 1 (latest)
Hello! I think you're looking for invoice.upcoming: https://stripe.com/docs/api/events/types#event_types-invoice.upcoming
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
But it could also be the trial will end, depending on what you mean by "expiring".
I'm monitoring the trial_end, so I wanted to be notified when the subscription is 3 days from ending
Hi @errant sapphire then you can listen to customer.subscription.trial_will_end https://stripe.com/docs/api/events/types#event_types-customer.subscription.trial_will_end
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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?
You will receive a customer.subscription.updated event. The easiest way to try it out yourself is to using the test clocks https://stripe.com/docs/billing/testing/test-clocks
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?
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?
No apologies needed ๐
How should I approach this? Is it possible to get that invoice link and send it to the Customer using my own method?
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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
and by using the customer_id I should be able to match them right?
every time a trial_ends, will this invoice be created?
Yes you can check the invoice's customer to know which customer is this invoice issued to
great
after X days if the invoice is not paid, then the subscription gets an update as well, right?
Yes, and based on the settings (https://stripe.com/docs/billing/subscriptions/overview#settings) subscription's status will be canceled, unpaid or past_due .
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
]);```
Set the subscription's collection_method to send_invoice
What about the payment methods? Would the payment method type do the trick for that too? Or do I need an extra parameter?
You can set the payment_method_types if you want your customer to use a specific set of payment methods. But I'd suggest you to leave this param and use the invoice settings instead https://dashboard.stripe.com/settings/billing/invoice
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Thanks
is it possible to get the previous status of a sub before an update?
If you are listening to webhook events, you can get the previous attributes of the event object.
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
Did you set the collection_method to send_invoice ?
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.
Use default_incomplete to create Subscriptions with status=incomplete when the first invoice requires payment, otherwise start as active.
ok, what is happening here is the following:
Details is here https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_behavior
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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