#patriciar5425-sub-coupon

1 messages · Page 1 of 1 (latest)

calm craneBOT
dire creek
#

Hi! Let me help you with this.

#

By "client" you mean Customer?

quick bramble
#

yes

dire creek
#

What is the expected behaviour? Do you want the amount paid for the first month be partly refunded?

quick bramble
#

No. So I meant if the customer does not pay for the subscription after i create the subscription element without coupon and goes back to apply a coupon, when he pays he is charged the initial price without discount.
I would like to be able to apply the coupon to the current payment even if the subscription element was created already

#

this is my flow: select plan + add coupon -> register -> pay. I want the user to be able to return from payment -> select plan and apply coupon -> back to pay updated subscription

dire creek
#

How do you apply the coupon?

quick bramble
#

this.stripe.subscriptions.update(id, {
promotion_code: promotionCode,
});

#

on the server side

#

using "stripe": "^8.193.0"

#

and I create the subscription like this:
const subscription = await this.stripe.subscriptions.create({
customer: customer.id,
items: [{
price: priceId,
}],
payment_behavior: 'default_incomplete',
payment_settings: { save_default_payment_method: 'on_subscription' } as any,
expand: ['latest_invoice.payment_intent'],
promotion_code: promotionCode,
metadata: {
internal_id: user.internal_id,
firebase_id: user.uid,
subscription_type: subscriptionType,
},
});

dire creek
#

You can try to apply the invoice to the latest_invoice instead, I see it's a one-time discount, correct?

quick bramble
#

yes, it should be one-time

#

So i should update the invoice and not the subscription?

dire creek
#

Please try to see if it works in your case.

quick bramble
#

I will! thanks

lapis carbon
#

Hi there 👋 jumping in as my teammate needs to step away. If the Invoice is finalized at that point, you may not be able to update it. The coupon will need to be applied before the invoice is finalized and gets locked.

#

patriciar5425-sub-coupon

quick bramble
#

Working on it! It will take me a bit because I need to add the update invoice method on the server and then use it on the frontend

quick bramble
#

I will go offline now, and get back to this on monday, I don't think it will work with updating the invoice

#

subscription is sub_1NTlx7Bn4amlqukbyE5sf5jH

lapis carbon
#

Ah, that's what I was afraid of. I think if the Subscription has already been created, then there won't be a way to apply a Coupon that impacts the first payment. You would need to cancel the existing Subscription and create a new one with the Coupon.

quick bramble
#

got it

#

I though that will probably be the last solution

#

thank you so much for the help, i will try to create new ones