#mathieu_upcoming-promotioncode

1 messages ยท Page 1 of 1 (latest)

solid skyBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1257706140112781423

๐Ÿ“ Have more to share? Add details, code, screenshots, videos, etc. below.

warm agateBOT
carmine portal
#

Hi there ๐Ÿ‘‹ great question! It looks like there may be some misalignment between our documentation here.

The code sample shown in the section of documentation that you linked to looks to me like it's using the Promotion Codes code rather than it's ID. Do you encounter an error if you try to do the same?

orchid ice
carmine portal
carmine portal
orchid ice
carmine portal
#

If you're looking in the dashboard, you may need to change the method from POST to GET. I believe by default that view only shows POST requests.

#

Oh I see the request now. Okay, we are responding with a 400 instead of a 500.

orchid ice
#

here are my 2 attemps : req_Ane5Rbm7G4s3aX and req_KUA1D0eBREYgdp

carmine portal
#

So I think what you'll need to do here, is use this endpoint to list Promotion Code objects, where you can provide a value for code to filter the results to only Promotion Codes with that code:
https://docs.stripe.com/api/promotion_codes/list

Then you can pass the corresponding ID of the Promotion Code to the Invoice preview endpoint.

#

I'll also flag to our teams that the sample in that doc is incorrect so we can get that adjusted.

orchid ice
#

okay that seems more appropriate indeed

#

so now my question is, will i get proper feedback status on the promotion_codes list API endpoint to check if the code exist or can be used ?

For example i tried with a client restricted promo code and get the following feedback on req_ClT3djS39XbnK2 : This promotion code is not specified for use with this customer.
This is pretty self explanatory, but as our frontend is for french customer we will retranslate it. To do that we need to rely on some kind of specific code to translate the right message.
On req_ClT3djS39XbnK2 we have an error.type which is invalid_request_error but i don't known if it is specific to the message above or if it is a generic error type code

carmine portal
#

If you want to only list Promotion Codes that are restricted to a given Customer, you can use the customer field when listing those:
https://docs.stripe.com/api/promotion_codes/list#list_promotion_code-customer

Listing Promotion Codes won't result in feedback similar to trying to use an restricted Promotion Code, the purpose of those requests is to different for that to be the right way for us to respond to a list request.

orchid ice
#

Ok and just that you get more context here is what our subscription form looks like (cf. screen)

And our goal here would be that our customer try to fill the promo code field and give them a direct feedback (using an ajax call on the route you mention) of their promo code is valid or not.
And in case it is not valid having the right message explaning why like :

  • code not found
  • code already used (for unique usage)
  • ...

So do you think using the promotion_code list is the right way to go ? Is there some cookbook on docs.stripe.com about best practice about that subject or should i just kept with the api reference for now ?

carmine portal
#

I would lookup the Promotion Codes in your backend. So your ajax call would be to your server, which then interacts with Stripe, and can respond with a message appropriate for your flow.

You shouldn't make calls to the Stripe API from client-side code, as they typically require your secret API key and you don't want to send that client-side.

orchid ice
#

yeah we alreay have that part done right our frontend call our backend which then call you API, we don't call it directly from our frontend

carmine portal
#

Gotcha! That should give you the control needed to intercept the responses or errors that we provide, so you can respond to your frontend with the right message for your flow.

orchid ice
carmine portal
#

Totally agree, especially since you can't use the code there instead. I'll be sure to raise that feedback with our teams!

orchid ice
#

can i come back to this thread if i got more question about promotion_code usage or do you prefer i reopen another one ?

carmine portal
#

If the thread is still open, you're welcome to ask any additional questions you have here.

I will close it after it sits idle for 15-25 minutes, but if that happens you can always start a new thread and whichever of our team members is around then will be happy to help.

orchid ice
#

Alright thanks for all !

carmine portal
#

Any time!

orchid ice
#

Can you confirm me that trying to apply a promotion code restricted to a specific product but not having that product on the subscription item (and instead some other product that have nothing to deal with it) do not resolve in an error and just don't decrease the final amount (as the requierement of having the product is not matched) ?

carmine portal
#

Yup, exactly

#

If you add the applicable Product to the Subscription later, then the Coupon/Promotion Code should immediately begin working if it is still on the Subscrption too.

orchid ice
#

ok thanks

solid skyBOT
winged mauve
#

mathieu_upcoming-promotioncode

orchid ice
#

what happen if the amount of the promotion code is higher to the commande final amount ?
For exemple when using the promo code just some day before a renewal we can have such scenario where the estimated paid amount will be less (due to prorata) that the promotion code amount (which is a fixed amount for our case not a percent amount)

More precisely what will happen to the excess of the promo amount ? is it lost ? does it goes as a negative balance for future payment ?

winged mauve
#

@orchid ice it's lost. I recommend just testing something like this in Test mode. It would take a couple minutes and give you a definitive answer

orchid ice
#

ok thx, gonna try it out

orchid ice
#

as i describe above on the case where a promotion code is apply but the restricted product isn't on the subscription item we can stilll have some trace that the promotion code have been use on your response like in the discount field or in the total_discount_amounts.
But in case that the target product of the promo code isn't there the price is not decrease which the expected behavior, my question is since those attribut discount and total_discount_amounts are always set (as if there is a promo valid existing code applied regardless of whether the restricted product is there or not), what is the field we can rely on to check that the final total as been indeed well reduce (in case we the restrcited product) by a discount ?

orchid ice
#

oh okay i didn't check the total_discount_amounts[]amount properly which is indeed of 0 if the promo code is used without the restricted product, thanks !

winged mauve
#

sure!