#default_user_Bq67qllUp5l4mHuk0ao

1 messages · Page 1 of 1 (latest)

daring pastureBOT
brave niche
#

Interesting, so you are saying that if they put in the code, close checkout, and put in the code again they will get an error that the code is not valid?

opaque coral
#

yes -

#

also the return we get form the post - after applying it the first time will be invalid

#

(even though code is indeed taking into cosidartaion in the final payment

brave niche
#

What POST call are you making once the card has been put in to the form?

opaque coral
#

in order to add the promo
await stripe.customers.update(
customer.stripeId,
{ promotion_code: promotionCode.id },
);

#

im setting the promo on customer

brave niche
#

I think I am unclear on the intended flow that you want. Can you tell me what steps are involved here?

#

Is it something like:

  1. You generate a Checkout Session
  2. On the Session's page, the user adds a promo code
  3. You are listening for some webhook, when you hear it you apply the same coupon to the customer?
opaque coral
#
  1. user start checkout session
  2. user tries to add promo code to
  3. a post request is send to validate the added promo
  4. if the promo exist and active: add to customer (customer.update)
  5. send the response of the customer update to the frontend - where the name of the coupon will be presented instaed of the promo code
#

thanks

#

so the reponse fro update customer is that the coupon is not valid

brave niche
#

Ah so this is your own custom page

#

Looking in to how you may be able to do this on a custom page...

opaque coral
#

my question is essentialy why when adding promom code to customer the coupon is not valid?

brave niche
#

Adding it to the customer is redeeming it. I think you want to save that step until the payment is actually being submitted. So maybe when they input the code you just need to check if it is a valid code.

#

Though that would mean we would have the same problem if the user added the code, tried to pay but got declined, closed the tab, and returned later to try again

opaque coral
#

agreed

brave niche
#

I think you may need some custom code on side to make up the gap

#

I think you would have to get rid of our max_redemptions param and enforce that limit yourself, only updating after a successful transaction from the user with that coupon code.

#

I can put in feedback that outlines the flow that you are going for. I definitely get that usecase. Though I can't guaruntee if/when it would be added so a workaround will be needed

opaque coral
#

from stripe?

#

how can i get rid of max_redempation from the coupon config?

brave niche
#

Yes, that parameter is optional so you can choose not to provide it when making the coupon.

#

Though on second thought, if this is a customer level coupon, maybe it is fine to apply it to the customer and the second time they load the page you just display that the customer already ha a coupon on them

opaque coral
#

yes - but the coupon is not valid - and we have a check to vaify that

brave niche
#

Not sure what you mean, are you saying after it has been used on the customer?

opaque coral
#

"used" = assigned

brave niche
#

I was more trying to say that once it has been applied to the customer, you can display that it has been applied without ever having to make that POST request again

opaque coral
#

true - but on the forst assignment - the response of the customer update - is invalid coupon

brave niche
#

Can you send me the ID of a request where you got this error? (req_123)

opaque coral
#

req_J5BW1BSWoL12Kl

brave niche
#

The description for that field says "whether this coupon can still be applied to a customer." so I think here it is trying to say that it is already on this customer and it can't be applied to other ones. Have you tried actually making an applicable subscription on that customer? I think the coupon has already been applied when you get that return, you would get an error if it wasn't able to be added to the customer
https://stripe.com/docs/api/coupons/object

opaque coral
#

the coupon did work on real time - i unserstand the value valid is confusin in this case because it means no longer valid *for other users *

brave niche
#

Yeah, definitely get that confusion. Glad it still worked here!

opaque coral
#

so to sum it up -
the best way to get the coupon details wil be befre adding it to customer

brave niche
#

Yep yep