#refikimi_billing-anchor-reset

1 messages · Page 1 of 1 (latest)

quasi swanBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1252644643229929572

📝 Have more to share? Add details, code, screenshots, videos, etc. below.

storm capeBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

vestal moss
#

Hi there 👋 bill the Customer for what? I'm not sure what you want to charge them for if they're still in a trial period, can you help me understand that part of your scenario?

brittle flume
#

Sure, hi Toby, sorry for missing introduction

#

Basically we are offering site protection service that we sell. And we added a few days trial since it is a tailored package for this customer. So we created a few trial days via our site that automatically creates the customer and then he subscribed to it. Customer is using it. Now we would like to charge him for this month since he used it, and reset the billing cycle to the 1st of each month.

#

So my idea was to Update the subscription with: 0 Free trial days and tick the option: Reset billing cycle This will generate an invoice immediately

and then to execute the following code for the given customer:
import stripe
stripe.api_key = "sk_test_•••RSVr"

stripe.Subscription.create(
customer='{{CUSTOMER_ID}}',
items=[{"price": '{{PRICE_ID}}'}],
billing_cycle_anchor_config={"month": 7, "day_of_month": 1},
)

vestal moss
#

For an existing Subscription, you can only change billing_cycle_anchor to now:
https://docs.stripe.com/api/subscriptions/update#update_subscription-billing_cycle_anchor
as discussed here:
https://docs.stripe.com/billing/subscriptions/billing-cycle#changing

What I think you'll want to do, but please try this in testmode first and make sure it accomplishes what you're hoping, is to make two updates to the Subscription. One to set the billing_cycle_anchor to now to charge the Customer for one billing period, which can be done by updating the Subscription directly:
https://docs.stripe.com/api/subscriptions/update

Then you'll need to make another request, or set of requests, to change the billing anchor to be the 1st of the month. For that you can either:

brittle flume
#

since this is for a single account, customer, I can charge him now and repeat the same step on the 1st of the next month, and then it will automatically charge him on the 1st every next month

vestal moss
#

I believe so, but we are less familiar with the dashboard flows for this (our team specializes in helping with our API and SDKs), so I'd recommend testing to be sure. You can use Test Clocks to simulate the full lifecycle of the Subscription and make sure your changes do exactly what you're hoping:
https://docs.stripe.com/billing/testing/test-clocks

brittle flume
#

perfect, thank you Toby. I will test it first on our own test env

vestal moss
#

👍 any time!

quasi swanBOT
#

refikimi_billing-anchor-reset

brittle flume
#

thanks mate