#paulkani_31213

1 messages ยท Page 1 of 1 (latest)

tepid rapidsBOT
calm bough
#

๐Ÿ‘‹ How can I help?

slow holly
#

i am getting this error

#

When updating an existing subscription, billing_cycle_anchor must be either unset, 'now', or 'unchanged'

#

when update subscription time

calm bough
#

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?

slow holly
#

I am already subscribed one plan

#

then again change another plan that means plan update

calm bough
slow holly
#

ok i will check

pastel arch
#

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?

calm bough
#

@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.

pastel arch
#

yes, we are in same team

#

we are workign together

calm bough
#

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

pastel arch
#

ok will check and let you know

tepid rapidsBOT
karmic dock
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

pastel arch
#

ok

#

which API to use to update/switch the subscription plan without chaning billing_cycle_anchor ?

karmic dock
pastel arch
#

$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 ?

karmic dock
#

please remove the secret key from your message

pastel arch
#

its a example from your documentation

karmic dock
#

is this your test mode secret key?

karmic dock
pastel arch
#

$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?

karmic dock
#

I'm not sure why do you need

'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent'],
pastel arch
#

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'],
]);

karmic dock
#

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

pastel arch
#

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?

karmic dock
#

no just in the update

pastel arch
#

ok

#

'payment_behavior' => 'default_incomplete',

#

is this needed?

#

in udpate case

karmic dock
#

yes because it's not saved as a default value for all updates

#

when creating the subscription

pastel arch
#

ok

tepid rapidsBOT
pastel arch
#

pls wait for some more time

molten sentinel
#

This thread may be closed due to inacitivty, please feel free to open new one in the main channel if so.

pastel arch
#

ok

pastel arch
molten sentinel
#

How are you loading that js script ?

tepid rapidsBOT