#yogeshInvideo
1 messages ยท Page 1 of 1 (latest)
๐ happy to help
you can use https://stripe.com/docs/api/subscription_schedules/create#create_subscription_schedule-start_date to backdate the 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.
Some Context:
We're trying to migrate subscriptions from different payment gateway to stripe.
And we're stuck with one case where Customer's Invoice is in dunning state and we want to migrate that state into Stripe.
Currently, When I add a Start date it back dates subscription create date correctly but that Invoice is generated not correct neither the subscription cycle.
For Example.
If the Subscription start date is 5th March then I've set the start_date to 5th March which works correctly.
But next invoice date shows 28th Apr which is next month from Today.
It should be 5th Apr according to Monthly billing cycle.
And Also the amount Invoice is also generated with prorated amount from 5th March.
What we want to achieve is to create a Invoice which charges for current billing cycle (5th March - 5th Apr).
And Next invoice should be generated on 5th Apr.
please bear with me will get back to you shortly
Hi there. This is a bit of a tricky scenario. One way to achieve this without a subscription schedule would be to combine billing_cycle_anchor: https://stripe.com/docs/api/subscriptions/create#create_subscription-billing_cycle_anchor with backdate_start_date: https://stripe.com/docs/api/subscriptions/create#create_subscription-backdate_start_date. This will allow you to backdate the subscription to March 5th and also anchor the subscription to April 5th. The tricky thing is this will generate a prorated invoice by default for that first partial month. To get around this, I recommend setting proration_behavior to none in order to prevent charging a partial amount for that first month: https://stripe.com/docs/api/subscriptions/create#create_subscription-proration_behavior. Then, you can create an invoice separately for the full amount of the first month
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Let me run a quick test to confirm this will work for you though
Oh so slight correction here. I did a strikethrough above for the part that wasn't correct
If you pass backdate_start_date, billing_cycle_anchor, and proration_behavior as instructed above, it will achieve exactly what you want. The first invoice on the sub will be the full amount for March 5-April 5th
So no need to create an invoice separately at all
into Subscription API or Subscription Schedule API?
Schedule API doesn't take Unix time as billing cycle anchor.
Regular subscription api is all you need
Oh let me test it then
Hey, This kind of worked for what I was expecting except for one thing is that the subscription is created with the incomplete state rather than the active state because I've set the failed card as default.
And also if the payment didn't go through for this user in 24hrs then it will expire which is not ideal dunning cycle.
You could change payment_behavior to allow_incomplete: 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.
That's exactly I've set
params := &stripe.SubscriptionParams{
Customer: stripe.String(payload.CustomerId),
BillingCycleAnchor: stripe.Int64(nextRenewalDate),
BackdateStartDate: stripe.Int64(startDate),
ProrationBehavior: stripe.String("always_invoice"),
Currency: stripe.String("usd"),
}
subscriptionItems := []*stripe.SubscriptionItemsParams{
{
Plan: stripe.String(planId),
},
}
params.Items = subscriptionItems
params.PaymentBehavior = stripe.String("allow_incomplete")
Ah got it. Sorry just learning about this behavior
Unfortunately there's just not a way to avoid it: https://stripe.com/docs/billing/subscriptions/overview#payment-window
You would just need to create the sub again if customer doesn't correct the issue
To be clear, this just applies to that first sub payment
Is it not possible to set the Subscription state to past_due so the Stripe dunning process can take over the retries?
Hmm, If I create a subscription schedule with free trial? Will it behave as dunning for Next Invoice?
I'm not sure off-hand, but I don't think so. Recommend giving it a go in test mode to see
Can use test clocks too if you want to speed up the process
The reason for this behavior is:
This window exists because your customer usually makes the first payment for a subscription while on-session. If the customer returns to your application after 23 hours, create a new subscription for them.
So really just recommend creating a new sub if they don't pay within the first day
Well, with free trial it put the subscription to overdue state which I believe the dunning state.