#Rob.Clayton
1 messages · Page 1 of 1 (latest)
Can you share the request ID (req_xxx) where you faced the error? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
req_wxXuat6YBeoNUF
basically I'm trying to import our existing subscriptions, and we will be asking the customer to renew before the cancel date (I'm going to add a subscription schedule that cancels at the end of their subscription period).
However they have already paid for their full year contract with us.
so I want to add the subscription, but not charge them in stripe
and they don't have payment methods or anything setup, because they are also new customers
This is my actual code:
Thanks for sharing. Looking into it now
Thanks
In your request, you should also set when the next time that the customer should be charged with billing_cycle_anchor: https://stripe.com/docs/billing/subscriptions/backdating?dashboard-or-api=api#backdating-billing-cycle
Otherwise, Stripe will create a new invoice to charge from the timestamp of the request till the next cycle
ah, thanks river, will try that
No problem! Happy to help 😄
oh, while I've got you ...
and that's working by the way, thanks.
How do I create a subscription schedule for the above subscription that cancels the subscription at a given date?
If I set a cancel_at field in the subscription create call ... does that actually create a subscription schedule behind the scenes?
There are two possible ways to cancel the subscription on a given date:
- Set
cancel_aton Subscription directly: https://stripe.com/docs/api/subscriptions/create#create_subscription-cancel_at - Create a Subscription Schedule from existing Subscription (https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#existing-subscription), then update Subscription Schedule's end_date or iteration of the phase with
end_behaviorascancel
Is there any difference in the behavior of the two methods?
There is no difference, but item (1) should be easier
thanks
If I did the second option, would I do something like this?
step 1:
schedule = stripe.SubscriptionSchedule.create(
from_subscription=subscription.id, api_key=self.api_key
)
so there's a phase that is I assume the same as whatever is in the subscription
step 2 ??? -
then do I ADD a second phase to start and end at the same time as the end of the first phase, and for the end_behavior to be "cancel"?
You can update the end_date of first phase with end_behaviour with cancel
how would I update the first phases end behavior with my code sample above?
When I create a subscription, and then create a schedule from the subscription there appear to be two phases created
this is my actual code:
There is no cancel_at in the Subscription Schedule. cancel_at is only available in normal Subscription. For Subscription Schedule, end_date should be updated instead: https://stripe.com/docs/api/subscription_schedules/update#update_subscription_schedule-phases-end_date
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
right, that makes sense ...
just wondering why two phases are create if I just create a schedule based on subscription create example above?
I'd have to look at the sub_sched_xxx itself to say but maybe it's to do with using backdate_start_date and that leads to a previous phase being created that represents that when converted to a Schedule
ah, makes sense
so I assume actually all I need to do is set the end_behavior to be "cancel" with subscription schedule modify?
that could work yes, you can use that to say "after all the phases I've defined have ended, cancel the subscription"
hmmm ... no, so at the moment, if I create a subscription as described, if I then call subscriptionschedule.create(from_subscription=my_sub_id)
it creates the first phase to start today, and the end to be the end date I set, then there is a second phase which is for the following year
and that's not what you want?
again it would be easer if you could share an example sub_sched_xxx I could look at in parallel
This is my schedule create code.
start_date = '2023-06-11 06:30:30'
end_date = '2024-06-12 14:00:00'
the item is for a product billed yearly
easier to look at the specific sub_sched_xxx object you created in test mode for example, do you have the ID
this is the subscription id just created: sub_1NISRlLlJAiubLi9ploMAxD0
here's the schedule sub I just made:
sub_sched_1NIST9LlJAiubLi9fyur9hQa
thanks
so sure, you have a subscription that has a billng anchor set to 2024-06-12 14:00:00 next year with some backdating, so it creates a Schedule that represents the current state of the sub, which is one phase from the time the subscription was created today until that 2024 date, and then a next phase that starts at that date and ends a year later(since it's a yearly Price) and recurs forever beyond that (since it's end_behaiour:release)
so what do you want to do next
ahhhh, so the second state is the state that will be followed on going
got it
I want to actually cancel at the billing_cycle end date I set
I know I can set a cancel_at with the subscription, but was wondering how to do it with a schedule
you want it to cancel at that 2024-06-12 14:00:00 date?
yes