#paulkani_31213
1 messages ยท Page 1 of 1 (latest)
๐ How can I help?
i am getting this error
When updating an existing subscription, billing_cycle_anchor must be either unset, 'now', or 'unchanged'
when update subscription time
This is expected. billing_cycle_anchor can only be unset, 'now', or 'unchanged' on existing subscription. Can you share what you would like to achieve here?
I am already subscribed one plan
then again change another plan that means plan update
To change the billing cycle on existing subscription, it can only be done via adding trial. Here's the guide for more details: https://stripe.com/docs/billing/subscriptions/billing-cycle#add-a-trial-to-change-the-billing-cycle
ok i will check
yes, our subscription set/starts 1st day of each month and using "billing_cycle_anchor " to calculate price if user is subscribing in between the month so remaining days only gets charged in intial month and from next month onwards full amount on 1st day of each month
there is also possibility that user can switch the plan with higher or lower prices so we tried to update subcription but it gives Subscription Error When updating an existing subscription, billing_cycle_anchor must be either unset, 'now', or 'unchanged'
we want to update plan without chaning 1st day of each month billing cycle
how to achive this?
@pastel arch are you in the same company / team with @slow holly? If you are not, please post your question in the main channel #dev-help and we will create a thread specifically for you. This thread is meant for Paulkani.
Thanks for sharing! When the subscription is updated with the price plan change only, the billing cycle anchor won't be changed
You shouldn't need to set billing_cycle_anchor in such a case
I'd recommend giving a try in test mode
ok will check and let you know
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
ok
which API to use to update/switch the subscription plan without chaning billing_cycle_anchor ?
https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_cycle_anchor you can use unchanged
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
$stripe = new \Stripe\StripeClient('sk_test_tR3PYbcVNZZ796tH88S4VQ2u');
$stripe->subscriptions->update(
'sub_1MowQVLkdIwHu7ixeRlqHVzs',
['metadata' => ['order_id' => '6735']]
);
which more params needs to set with this update request ?
please remove the secret key from your message
its a example from your documentation
is this your test mode secret key?
you need to add the 'billing_cycle_anchor' => 'unchanged' as I shared earlier
$subscription = $stripe->subscriptions->update($subscriptiondata['stripe_subscription_id'],[
'items' => [[
'price' => $stripePriceId,
]],
'metadata' => $metaData,
'billing_cycle_anchor'=>'unchanged'
'payment_behavior' => 'default_incomplete',
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent'],
]);
is this fine or need to remove /add any more params?
I'm not sure why do you need
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent'],
it was used in create subscription call
is it not needed?
$subscription = $stripe->subscriptions->create([
'customer' => $stripeCustomerId,
'items' => [[
'price' => $stripePriceId,
]],
'billing_cycle_anchor' => $billingCycleAnchor, //Set billing cycle 1st day of next month
'metadata' => $metaData,
'payment_behavior' => 'default_incomplete',
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent'],
]);
no not really here
because you're not collecting a new payment method and in all cases there won't be a new invoice. it will be generated on the next billing_cycle
ok then I will remove
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent'],
in both create and udpate calls right?
no just in the update
yes because it's not saved as a default value for all updates
when creating the subscription
ok
pls wait for some more time
This thread may be closed due to inacitivty, please feel free to open new one in the main channel if so.
ok
https://js.stripe.com/v3/
do we need to add version to not to cache in client browser?
something like work?
https://js.stripe.com/v3/?ver=1.01
How are you loading that js script ?