#Sam_Praveen-plans-subscriptions

1 messages · Page 1 of 1 (latest)

vital folio
#

Do you have a request ID?

mint bough
#

Here is the req ID: req_7ocBRJgCLvUtN7

vital folio
#

So in your request you're updating the billing_cycle_anchor, but it's being set to a time outside of the current billing cycle. What are you trying to do specifically?

mint bough
#

Well I am creating a subscription for an existing Customer that must start from a specific date.

#

I am providing the Date in UNIX Timestamp in billing_cycle_anchor.

#

Here is my Request:

{
"customer": "cus_Lh9M2HZDp3zJHc",
"default_payment_method": "card_1LEGnMGvtfUGWiicRoh8iCXP",
"billing_cycle_anchor": "1658275200",
"proration_behavior": "none",
"items": {
"0": {
"plan": "plan_M0d64Wu5rLXXDO"
}
}
}

vital folio
#

Right. But the Plan you're using has a weekly billing cycle, and you're setting the subscription billing_cycle_anchor to a time that is more than a week away.

#

The date for billing_cycle_anchor on a new weekly subscription cannot be more than a week away

mint bough
#

Ohh I see.. So Can we create a Plan that matches to the Future Subscription Date?

#

For example: If I want to create a Subscription for next 20th July so Can we create a Plan for same date as well before creating a subscription?

#

Here is my request for creating a Plan:

{
"amount": "500",
"currency": "USD",
"interval": "week",
"product": "prod_M0d65UlEO7trIy"
}

vital folio
#

You would need to use a trial on the subscription to give the customer a free period that ends on the date that they should be billed for, then update the billing_cycle_anchor to the day of the week in which you'd like them to be billed.

So, for a Subscription that's to be started and billed on July 20th, you would set the trial to end on that day and then update the billing_cycle_anchor to July 6th (since July 20th is a Wednesday, and July 6th is the Wednesday within the current billing cycle)

mint bough
#

Ok so as per my understanding, If the Customer wants to start his New Subscription from a future date (For Example 15th July - Friday) so, I will need to create a Subscription like this where trial_end is 15th July and billing_cycle_anchor is 8th July as 8th and 15th both comes on FRIDAY:

{
"customer": "cus_Lh9M2HZDp3zJHc",
"default_payment_method": "card_1LEGnMGvtfUGWiicRoh8iCXP",
"trial_end": '1657907396',
"billing_cycle_anchor": "1657302596",
"proration_behavior": "none",
"items": {
"0": {
"plan": "plan_M0d64Wu5rLXXDO"
}
}
}

#

Please correct me if I am wrong or missing something here!

vital folio
#

From first glance that appears correct. Have you been able to create a test subscription using the above? If so, does everything appear correct in the Dashboard when you look up the newly created subscription?

mint bough
#

Let me check this scenario and create a subscription with these values.

#

I tried this but I got this Error:
Trial end (1657907396) cannot be after billing_cycle_anchor (1657302596).

It means, Trial End (15th July) cannot be after billing_cycle_anchor (8th July)!!!

#

Here is the Request ID: req_1aCfWydN9rU2OU

vital folio
#

Does it work if you set billing_cycle_anchor to July 15th?

#

Alongside the trial? I'm confused by this default behavior, as I thought you could

mint bough
#

I will need to check it.. let me try this

#

Now I got this error:

When billing_cycle_anchor follows a trial, the anchored invoice must be prorated. For a longer free period, use a longer trial.

Req ID: req_m5yvxdiqCcSuEX

#

What does it mean by Longer Trial here?

vital folio
#

Can you add proration_behavior: "create_prorations"?

mint bough
#

What does it mean? Will it charge the customer before the Subscription Start date?

vital folio
#

I don't think so, because the end of the trial and the billing_cycle_anchor should be the same. I think the API just requires it in order to make sure any difference in time does not go unbilled. You can test the default behavior with Stripe's test clocks to make sure it's working as expected though:

https://stripe.com/docs/billing/testing/test-clocks

Learn how to move Billing objects through time in test mode.

mint bough
#

So should I set the Trial End and Anchor Timestamp values exact same or the Anchor value should be atleast few seconds or minutes greater than the Trial End value?

vital folio
#

I'm not sure if you can set them for the exact some time. I would try that first

mint bough
#

ok

#

please let me know the result you will get!

vital folio
#

I don't have a way to test this right now. Can you try submitting the above mentioned request with identical timestamps for both billing_cycle_anchor and trial_end?