#t90

1 messages · Page 1 of 1 (latest)

pseudo yachtBOT
sharp yew
#

Interesting, looking in to this. Did you apply some discount to this subscription when it was created? I don't think it would need to be reapplied if it was still in effect but will have to double check

cobalt quartz
#

Yes, the discount was applied by the customer through the checkout.

sharp yew
#

Also I see that the price itself has "(20% Discount)" in its name. Is the price already discounted?

cobalt quartz
#

That's just the name.

Subsequently when the user adds a new seat and we update the subscription quantity, the invoice gets regenerated but without the original discount applied.

We asked tech support about this and they said we need to send the discount with the subscription update request but there is no parameter for it.

sharp yew
#

You are right that that subscription item update call doesn't have a parameter for promotion codes. I think you would need to shift to using the subscription update call and apply a discount when making that call. One moment as I find the docs

#

Basically you would make an update call and include the coupon that you want in the coupon parameter.
https://stripe.com/docs/api/subscriptions/update#update_subscription-coupon
You can do that call, and then your subscription item update call, though you can also update subscription items when adding the coupon as well. You would just include one subscription items that you want to update in the items array and make sure to specify the ID of the specific item you want to modify
https://stripe.com/docs/api/subscriptions/update#update_subscription-items-id

cobalt quartz
#

Ah okay cool, so we're currently using the subscriptionItems call.

When the subscription is created, we need to save the coupon code (not the discount ID?).

Instead of using the subscriptionItems.update call to update the quantity we use the subscriptions.update call

return this.stripe.subscriptions.update(subscriptionId, { proration_behavior: interval === 'month' ? 'create_prorations' : 'always_invoice', coupon: couponId, items: [{ id: subscriptionItemId, quantity: users.length, }] });

#

Does that look correct

sharp yew
#

Yes that code looks correct from what I can see here. If you run it in test mode it should change the subscription properly