#gecko - update price
1 messages · Page 1 of 1 (latest)
taking a look here, give me a second please
can I edit it, by adding a billing cycle anchor to it?
stripe CLI or something equivalent
So via the update prices API, I'm afraid this is not possible: https://stripe.com/docs/api/prices/update
Are yo able to add more context into what you're really trying to do?
i created a subscription price. I've subsequently learned that in order for me to specify the recurring day it issues, I need to use this parameter
so my question is can I edit an existing one, or I have to create new?
clearer?
@charred pulsar when you create the subscription you pass the billing_cycle_anchor you want along with the price ID for the subscription
so what I've done before is create my prices via the website, and there's just a "recurring" menu pull down, but not the anchor as an additinoal option. So....this would be a first for me @oblique fern ...I create a price first ,and then a subscription from the priceID that's first created? if so, can I just use existing price ID's and not create a new one?
Yeah so prices only have a period, you can set it to monthly, yearly, etc. It has no effect on the day that the subscription will actually bill, and you can't set the billing_cycle_anchor on the price itself.
Create the price with the term you want (assuming monthly)
Then when you create the subscription, you will pass that price, along with the billing_cycle_anchor (https://stripe.com/docs/api/subscriptions/create#create_subscription-billing_cycle_anchor) which will be a timestamp representing the date you want the billing day to be
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
So let's say you create a subscription today, but you want it to bill on the first of the month every month. You'd pass billing_cycle_anchor=1651363200
(1651363200 is the UTC timestamp for May 1 @ 12 AM)
Spot on Nick!
It's also possible to move the billing_cycle_anchor for existing subscriptions, but it's a bit more tedious. You can read more about that here:
https://stripe.com/docs/billing/subscriptions/billing-cycle#changing
so here's my simple case....I have a $5 price. I want to offer a $5/monthly subscription. (I have a subscription already created for this, but without the anchor)
so, I would delete/archive the existing subscription, and create a new one, or modify the existing one....
i have no customers on this subscription, so it seems like I could just use the API to modify the existing subscription. right?
To create a subscription you'd need a customer, https://stripe.com/docs/api/subscriptions/create. For a subscription that is already created, you can either move the billing_cycle_anchor, https://stripe.com/docs/billing/subscriptions/billing-cycle#changing as stated above. Or your approach of deleting the subscription and recreating it could work.
I'm confused by this. I have to create a product. set a price. then a customer will buy this product at this price.
the price, when I set it up, can be a single point purchase only, or a recurring purchase.
price_1KNrHxDeb8L7gMecCehwwS9o
this is an example, of what I setup as a recurring price, and there were no customers before hand...that seems chicken and egg to me
so...can I just modify this price and move the anchor?
You cannot modify the price with billing_cycle_anchor as that is not a parameter for updating a price. You would create the price and when you're creating the subscription with billing_cycle_anchor you'd use that price. The billing_cycle_anchor is a parameter on the subscription and not set on the price. So to directly answer your question, no.
To learn how these objects interact, please visit: https://stripe.com/docs/billing/subscriptions/overview
So what exactly is that price then I provided? It was setup as a recurring price. That’s not a subscription
Correct, that is not a subscription. Rather a recurring price.
To create a subscription, you'd leverage that price
So previously I exposed a recurring price, to a customer and they did a checkout on it. It set up a recurring billing. Was a subscription object then created automatically?
Yes, that is correct
and thus...you're saying that the subscription is the only place to set the anchor...and thus I need to handle customer subscription creation events, and change the anchor, to the day I want, for each and every customer, and not something I can setup specific to the product/price. correct?
That is correct.
ok...and if I get the event, which I believe is, "subscription_schedule.created"....then I simply modify the anchor to be the next cycle date in the future (like May 1 as the example from Nick above)...and I do this once, and not every cycle (monthly in my case)...right?
your docs seem clear on this, so yes I think I'm right
With this approach, you most likely want the default behavior of setting proration_behavior to create_prorations—as in the code sample—so the customer isn’t overcharged for unused time in the previous cycle.
i don't want a proration for the current cycle. how to ensure this default behavior is not enabled?
'none'?
Jumping in as my teammate needs to step away soon. It doesn't sound like you're working with Subscription Schedules (those are different objects than Subscriptions) so I don't think that's the event you want. Instead you'd want to look for customer.subscription.created events.
Once a Subscription has been created you can directly set the billing_cycle_anchor but the only acceptable value at that point is now, which will set to the anchor to the current time rather than one you specify. You can see this mentioned in the API reference for the "Update a subscription" endpoint.
https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_cycle_anchor
To shift the billing_cycle_anchor to a specific date/time, you'll need to update the subscription with a trial period as mentioned in the documentation that I linked earlier.
the flow I understand: I have a product with a price. customer goes to checkout and selects recurring price. that creates a customer subscription object. (event customer.subscription.created)
You'll also need to keep in mind that you need to continually calculate what the billing_cycle_anchor should be set to as you'll run into problems if you try to use a date that's in the past.
I can, at that point, edit the subscription?
Correct.
yes I understand I need to be future looking on the epoch calc
🙂
thanks
as for trial, I don't want a trial
if they sign up some time in the month, I want the full bill immediately, regardless of when in the month
what to do about the trial you say is mandatory?
So if you don't set the trial initially, then the checkout session will charge for a full period immediately. The trial is added afterwards behind the scenes to move the billing_cycle_anchor, though you will want to play with the various prorations settings to ensure you find the setting that matches your desired flow.