#mamidd
1 messages · Page 1 of 1 (latest)
Hi! Let me help you with this.
i wouldnt expect this behaviour because the item with month interval has quantity 0
Are you following a particular guide from Stripe docs?
the little guide about pending update process, let me find it
The new Subscription Item should have the same item ID, but with different price. Then you will not get the error.
OLD_SUBSCRIPTION
item with month interval with quantity 1
NEW_SUBSCRIPTION
item (with the same id value) with year interval with quantity 1
Yes
ok and how can you manage this scenario:
OLD_SUBSCRIPTION
- item1 with month interval with quantity 1
- item2 with month interval with quantity 1
NEW_SUBSCRIPTION
- item1 (with the same id value) with year interval with quantity 1
in this scenario the customer has a subscription with two items monthly and want change his subscription to only 1 item yearly
you create a new Price object price_xxxx for the yearly price and then make the API call at https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#changing to change the item to the new price.
you also need to pass an item with deleted:true to remove the other item if that's the goal
all this is compatible with pending_if_incomplete? because for my ecommerce logics i need the pending_if_incomplete method
not sure if it's compatible, you'd have to test it
see https://stripe.com/docs/billing/subscriptions/pending-updates-reference#supported-attributes for what might not be supported. Unfortunately the pending update feature doesn't support everything so in many cases it's not an option to use
my thread starter from this point. why stripe give me a mismatch interval in a subscription if i have an item with quantity 0 monthly and an item with quantity 1 yearly?
it's not the expected behaviour
you can't have a subscription that is subscribed to both a monthly and a yearly plan at the same time
if you were trying to change from a monthly to a yearly a plan, then you made the API call incorrectly. Often people forget to pass the id of the item, so you're actually adding a new item. I'd need to see you exact code and request IDs req_xxx to say more.
where can i get the req_xxx?
ok found, i reproduce the error and i give you the req_id
req_rU6Sf4vKvrNDbJ
in that request you are adding a new Price price_1NAZg8F83rF8iubkeud5BUKT, and you are changing the quantity of an existing item to 0.
is that what you wanted to do?
and this is the other use case: req_uCJdNqAQanrWwc
yes it's what i wanted
but you can't since the subscription has a monthly item already.
how can i manage this scenario with this payment_behavior?
the subscription currently exists as
- item si_NzOsGIYRTmMqWo — monthly plan 15/month
-item si_NzOi8WsUrCm0Vd - monthly plan 29/month
yes
your update call is trying to change it to
- item si_NzOsGIYRTmMqWo — monthly plan 15/month
- delete item si_NzOi8WsUrCm0Vd
- add new item yearly plan
i would substitute all items with an item with price price_1NAZg8F83rF8iubkeud5BUKT
and you can't do that since you are adding a yearly plan when it already has a monthly plan.
ok try to see this request instead: req_uCJdNqAQanrWwc
in this request i managed both items to quantity zero
adding the new price yearly
well try deleting them properly
i.e. do {id:"si_xxx", deleted:true}
instead of the weird setting quantity to 0
i cant use the deleted:true in prending_if_incomplete
the API says me that is unsupported
then like I said, Unfortunately the pending update feature doesn't support everything so in many cases it's not an option to use
i need to use pending_if_incomplete because for my ecommerce logic
i need to "try" the update of a subscription waiting for customer payment
if payment suceed so my ecommerce should apply the new features
if payment fails i need to cancel the update
one of the scenario is if user use 3DS required cards
all others payment_behavior didnt manage properly async payments like 3DS
like I said the pending updates feature doesn't work for every use case, I'm sorry, I wish it did
so you have to handle this in different ways like manually rolling the subscription back to its previous state if the payment attempt fails, or doing a separate payment instead and doing the update to the subscription only if that succeeds
how can i do a separate payment and after manager the subscription update? what apis should i use?
i could follow this solution but i need that the update of subscription won't charge again the customer. is it possible?
you could create a separate PaymentIntent or a one-off Invoice. And then you do a Subscription Update call with proration_behavior:none (to avoid possibly creating an new invoice or charge) to make a change to the subscription when it succeeds. It needs lots of testing.
uhm ok
but sorry, with proration_behavior:none strippe will charge with the full price the customer
it doesnt' avoid charging the user
did you test that and see it be the case?
yes i tested an update of subscription with proration_behavior:none and it charged the customer
Can you share the requestId of the update request ?
req_uCJdNqAQanrWwc
This is a failed request, and you passed proration_behavior:always_invoice and not none