#andrea-skuola-subscriptions
1 messages ยท Page 1 of 1 (latest)
yes
then you can use the cancel_at https://stripe.com/docs/api/subscriptions/create#create_subscription-cancel_at and set it to the date of the last cycle of your subscription
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 did this but there was a problem: if the subscription is created today, as the payment is monthly, it will renew on Aug 7, so cancel_at I set it to Aug 7 +7 days to make sure that the subscription does not expire before the last installment is paid (I had a case of a user who did not pay the last installment because the subscription had expired earlier) and allow the user to manage any payment errors (for example insufficient funds). Since I added these 7 days, the last installment is less than the others because for the system only 7 days of subscription remain and not the whole month, so last invoice he pays only last 7 days
that's not good
do you understand?
last time you colleague tell me someting built in for installments
that i could set the number of installment i want on subscription
this is called subscription schedules
or I think you can also take a look at the scheduled payments https://stripe.com/docs/invoicing/hosted-invoice-page/scheduled-payments
this is I think even better for your case
when I use subscription schedules do I have to set the price currency monthly or is just needed to set subscription schedules iterations field to the number of installments?
iterations is the way to go for installments
what does the end_behiavor field do?
i don't understand
in subscription schedules
Behavior of the subscription schedule and underlying subscription when it ends. Possible values are release and cancel.
https://stripe.com/docs/api/subscription_schedules/object#subscription_schedule_object-end_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.
yes i don't understand what release and cancel values do
If cancel, the underlying subscription would be cancelled when all phases are complete
If release, then the subscription would just go on following the natural billing cycle (monthly, etc)
oh ok, and when is set to cancel there is no hard delete right? The subscription will always be visible in dashboard even if canceled
Correct yes, they're not deleted. Just in a terminal state (can't be reactivated)
subscription schedules don't return a client secret?
before to create a subscription I used $subscription = $stripe->subscriptions->create([...]) and in $subscription I had the object
now with $subscription = $stripe->subscriptionSchedules->create([..]) this don't return anything
sorry it return somenting different
Yes, the schedule just facilitates creating a subscription object (where payment is facilitated) according to the specified schedule
But i need a client_secret to generate payment element, where to get it?
From the initial invoice of the generated subscription
sorry, i don't want to refactor all my system with subscription schedules
Now i use subscription with currency monthly and cancel_at field based on number of installments I decide.
So if customer has 2 installments and the fist has been paid on subscription creation I set cancel_at field of his subscription at today's date +1 month, so the system can automatically charge only one more installment. It's happened that some subscription ended before the last installment has been paid, so i added +1 week to cancel_at field to all subscriptions. Now the problem is that Stripe in automatic calculates that the last installment is only for 1 week because from last installment date to cancel_at date the time remaining is 1 week so customer only pays for this 1 week and not the complete price of the installment. What can I do to make customers pay all installments the same price?
tell me if it's clear
Yep, you should use subscription schedules really. It's the best approach for instalments like this
Otherwise you'll be wrestling with dates going forward
but now i use $subscription = $stripe->subscriptions->create([...]), if i replace it with $subscription = $stripe->subscriptionSchedules->create([..]) it's not the same thing
the last method don't generate payment_intent and client_secret
Correct, it doesn't. Those would still exist on the subscription (invoice, really) that the schedule creates
so for getting payment_intent and client_secret i need to pick sub_id returned by subscriptionSchedules and get the subscription object via API?