#sagi-promo-code-usage
1 messages · Page 1 of 1 (latest)
Are you Stripe Customer objects (cus_xxx)?
That's how we track 'first-time order' status
Otherwise you'd need to track that status yourself and only apply the coupon/discount accordingly
Yes I am using Stripe Customer objects. I can show you 2 invoices with the same customer and same promo code coupon discount applied.
Sure, please share!
I created those 2 invoices with the same user, and used the same promo code (10DOLLARSFIRST) (of course in test env) see the discount that applied:
Can you paste the IDs (in_xxx)
in_1LfMKgIYe94xuOWzWOOwxYNF
in_1LfMM0IYe94xuOWzmjW39D0o
Hey, sorry for the wait
It's because you're using the coupon ID, not the promo_ ID when creating the invoices
The redemption limit is configured on the promotion code (promo_1Lexi1IYe94xuOWzlJPGz9qe)
I don't think Invoicing supports promotion codes however 🤔
Yes you are right I am passing the coupon id, but as I see. on the docs of "discounts" param of POST /invoices:
"The coupons to redeem into discounts for the invoice. If not specified, inherits the discount from the invoice’s customer. Pass an empty string to avoid inheriting any discounts."
now, when creating an invoice I am passing it like using the (Stripe.InvoiceCreateParams interface):
{
...
discounts: [{ coupon: coupon_id }]
}
(discounts is from type InvoiceCreateParams.Discount[])
So I actually cant pass the promo id instead of the coupon id?
Hey! Taking over for my colleague. Let me catch up.
ok Thanks
Sorry for my late reply
I tried passing it like:
{ .., discounts: [{ coupon: 'promo_xyz' }]
gets:
StripeInvalidRequestError: No such coupon: 'promo_1Lexi1IYe94xuOWzlJPGz9qe'
The discount object take coupon and not a promotion code
yes
A promotion code is used by customer while doing payment, in order to apply for a coupon
So when using APIs you need to pass couponId of the promotion_code that you want to use for
For this case, you should pass the coupon id which is co_1Lexi1IYe94xuOWzjjwIrzlB
Yes this is what I initially did, but the real question is how can I use the "Eligible for first-time order only" option?
because the customer can re-use again and again this code
if I pass the coupon id like that
Your integration should track this, if you are applying the coupon on behalf of customer from server side using APIs
I don't understand what you mean.
Yes I am applying the coupon on behalf of the customers from server as you said, but when passing the couponId that have a promo code with the discounts array, and this promo code has "Eligible for first-time order only" option turned on - customer can actually enter it on another order and it will work, is there a way to "know" or to reject it?
Hello 👋
Taking over as os4m37 needs to step away soon, give me a few to catch up
ok thanks
If I understood the problem on your end correctly, the problem is that when passing into the discounts array a couponId (which is the only option, can't pass a promoId) - Stripe don't know that the option of "Eligible for first-time order only" is turned on because it is found ONLY on the promo code entity and not on the coupon entity, and because the discounts array can get only couponIds, this maybe can't used that way
yup that is correct, so basically you'd want to track if the coupon is only for first-time orders by checking if the customer have already used/exhausted their coupon redemption.
As my colleague mentioned, this isn't something invoicing supports as the moment
you mean I have to check it in my backend/own server?
because no support for this scenario on invoices from Stripe
yes that's correct.