#_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always 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/1402295558034554880
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- _webhooks, 4 days ago, 8 messages
Hello, one idea that comes to mind is scheduling the original subscription to cancel at its period end and creating a second subscription via a schedule. I have a feeling we may raise the multicurrency customer error there as well. In which case unfortunately I think the only way to do that automatically would be to schedule a job on your side and backdate the subscription start date by a couple seconds so the dates line up
Yeah, I've manually updated a subscription to end at the end of the cycle and tried creating the new sub.. but I don't know if I did it correctly..
This is the text I did on the workbench shell :
stripe subscription_schedules create --start-date="1757081722" --from-subscription="sub_1Rsl79RHtdZpYxj3kGgUpF5G" -d "phases[0][items][0][price]=price_1RW1HZRHtdZpYxj34DXbEnqg" -d "phases[0][items][0][quantity]=1" -d "phases[0][currency]=cad"
{
"error": {
"message":
"You cannot set `start_date` if `from_subscription` is set.",
"message_code":
"invalid_subscription_schedule_create_from_subscription_params",
"request_log_url":
"https://dashboard.stripe.com/test/logs/req_5L2emlCsxN9oSJ?t=1754403421",
"type":
"invalid_request_error",
},
}
and also got the error.. but is it done "correctly" on my side?
my test sub is currently like this :
and if I remove that start_dateand do :
stripe subscription_schedules create --from-subscription="sub_1Rsl79RHtdZpYxj3kGgUpF5G" -d "phases[0][items][0][price]=price_1RW1HZRHtdZpYxj34DXbEnqg" -d "phases[0][items][0][quantity]=1" -d "phases[0][currency]=cad"
I get this error:
{
"error": {
"message":
"You cannot set `phases` if `from_subscription` is set.",
"message_code":
"invalid_subscription_schedule_create_from_subscription_params",
"request_log_url":
"https://dashboard.stripe.com/test/logs/req_TYsur71wQRRsvq?t=1754404670",
"type":
"invalid_request_error",
},
}
so I'm not sure how can I change the currency if I cannot really create that sched
You cannot set
phasesiffrom_subscriptionis set.",
This error is happening because we expect you to break this into two API calls. One creating the schedule withfrom_subscriptionand the next adding the actual phases of the schedule
if I try to create from the customer directly.. with this:
I also get the
{
"error": {
"message":
"You cannot combine currencies on a single customer. This customer has an active subscription, subscription schedule, discount, quote, or invoice item with currency usd.",
"message_code":
"customer_single_currency_required",
"request_log_url":
"https://dashboard.stripe.com/test/logs/req_sPoGDP1LMN4YTi?t=1754404795",
"type":
"invalid_request_error",
},
}
oh ok.. let me try to do that
with a sched create and an update
so, by doing that.. I would need to update with 1 single phase or with 2? (being the first the actual sub and the second the new one under the new currency)
What I did :
1:
stripe subscription_schedules create --from-subscription="sub_1Rsl79RHtdZpYxj3kGgUpF5G"
2:
Got this with the update:
"error": {
"message":
"You cannot combine currencies on a single customer. This customer has an active subscription, subscription schedule, discount, quote, or invoice item with currency usd.",
"message_code":
"customer_single_currency_required",
"request_log_url":
"https://dashboard.stripe.com/test/logs/req_KGExq3WE1MqQg1?t=1754405021",
"type":
"invalid_request_error",
},
}```
Gotcha, I think this error is just always going to happen because we don't check if the existing subscription on the other currency will still exist in future. So I can put in a feature request for this, but for the time being I think the only way to do this would be to schedule a job on your side to create this subscription.
Oh or you could do something like set cancel_at_period_end on the existing subscription along with metadata about a new currency to create a subscription in. Then when you get the customer.subscription.deleted event you could use that as a signal to create the new subscription and pass a backdate_Start_date and billing_cycle_anchor so that the timestamps line up with the old subscription.
gotcha, so at the hook implementation we already have in place, we could check that metadata and create a new one with the new currency.. did I get it correctly?
just to be sure.. given that I filtered a call that had the "currency update metadata" .. will I be able to see at this hook call directly the start date and the billing cycle anchor of the cancelling subscription or should I make a subsequent call in order to retrieve such data and create my new sub?
The metadata and current cycle info should all be in that deleted event without needing to retrieve the subscription
sounds like a good workaround
also, for the feature request you've mentioned, is there a place we can check it and monitor on our side to use it once implemented ?
Also something that may be helpful here is that we have this param for setting billing cycle anchors now. So you can just set what time of month you want something to cycle rather than calculating a timestamp in the future that may be variable based on how many days are in the current month https://docs.stripe.com/api/subscriptions/create?api-version=2025-07-30.preview#create_subscription-billing_cycle_anchor_config
No good place to follow it unfortunately
Not sure if we can do this.. but..
I also had a previous thread that got locked before I provided the answer from my tests.. haha
https://discord.com/channels/841573134531821608/1400576686705217676
Can I talk with you in here about that?
Absolutely
ok, well, what I was trying to do, basically, was to have objects instead of "having fun" with dynamic objects, when it comes to PreviousAttributes within the hook calls
The "main object" from the hook is easily converted to an object, but I wasn't being able to make it work for the PreviousAttributes, even seeing the property that described the object type
After the initial discussion on that other thread, I made it work with:
var jsonSerializer = JsonSerializer.CreateDefault();
var previousPrice = jsonSerializer.Deserialize<Price>(new JsonTextReader(new StringReader(previousAttributes.plan.ToString())));
This way I could get my previous price converted as an object correctly
But what I would like to know was if there's a way to know which objects can be present on the previous attributes for a subscription hook call
Cause, sometimes, if we talk about customer.subscription.updated hook call
Not always I will have the price object, cause sometimes, was something else that was updated
And those calls that are not a price change could be ignored on my actual handler, cause I want only to filter price changes
I know it would work for sure if I do something like :
return false;
But I would like to know if there's something more "elegant" or correct to check it
Otherwise, I'd still be digging on dynamic properties
Cool to know that that deserialization works!
I am honestly not fully wrapping my head around the next step. Can you tell me what this would ideally look like if you could get it to work that way?
Basically, when we receive a customer.subscription.updated call, we do some checks in our side based on your previous and actual price to ensure that you have access to everything you are allowed in our saas app.
For example, we work with dashboards, and for a given Stripe product you have access to a specific amount of dashboards. A stripe product for us is normally composed of 2 prices (for diff recurring periods, we can use monthly and yearly as an example)
When we handle the hook call, we need to see if you still have access to your perks and how many dashboards we can allow you to create (there's a link between a stripe product and amount of dashboards on our side). So, if your subscription update was because you went from plan A to plan B and with this change you increased the amount of dashboards you'll have (so.. you upgraded) we have to do a couple internal stuff, but if you reduced your amount of dashboards (downgraded) we need to do some other type of internal checks
(Yeah it's a little confuse our flow)
So, TLDR, we need to retrieve your finishing product (from previous attributes) and your brand new product (from your subcription), to do our checks internally, see if it is an upgrade or downgrade and proceed with our internal routine
That said, if the customer.subscription.updated was triggered by something else than a price change, we can simply ignore it.
And so far.. the way I'm checking it is based on that dynamic prop that can or cannot be present on the previousAttributes
if (previousAttributes.plan == null)
But if possible, I'd like to do it "more professionaly" instead of trying to guess if a dynamic prop exists or not
Gotcha, unfortunately I don't think there is a more elegant way of doing that. The structure will always be the same for the same API version, so you could write a wrapper function to make that simpler and easier to update but I don't think there is anything build in to our SDK objects here that would help you.