#gabor
1 messages ยท Page 1 of 1 (latest)
Good question. Can you show me what you are doing in the API now and what error you get?
Sure, just a sec.
stripe subscriptions update sub_1MrPeHIW2fFx6PmmZuvxm1U3 --coupon=referral-monthly
Then I still have "discount": null in the subscription object.
Oh interesting. So we don't error out but it still doesn't get set
it seems like
I also tried with a clock, in different months, and got the same result.
Do you have the request ID from a time you tried this? (req_123)
Looking through your logs but if you have it on hand that would be easier
Where can I find it?
I found some https://dashboard.stripe.com/test/logs/req_mnvSujXrbZZ0Jb
https://dashboard.stripe.com/test/logs/req_fZcxJTFJ8F1JQl
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I can just do one more request, so that will be the newest.
Yes please much appreciated
I've just done one that set the discount object. Hm.
Yeah I noticed that on the first request that I linked to it did set the coupon https://dashboard.stripe.com/test/logs/req_mnvSujXrbZZ0Jb
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
It might be because I used a different coupon than in the last one?
Exactly my thoughts
Can you try advancing the test clock and doing the same coupon?
Yes, I was going to say the same thing. Just a sec.
done
no discount added this time
Gotcha and here is the request ID for reference https://dashboard.stripe.com/test/logs/req_E80RMrlqJWNlMP
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I think this is a bug. I will file a report. Can try to think of workarounds in the mean time if you need this now.
Thank you! I will try, but not really sure if it will work without the once coupons. The problem is that it's not possible to remove coupons from a subscription manually, if I'm right.
I'm building a reward system. I have 13 different coupons in the system. One 100% coupon for the monthly plan, and twelve others like 8.33%, 16.67% etc. to 100% for yearly plan, so that we can give away multiple free months.
I built a logic that would updated the attached coupon dynamically, based on the available reward points in our db.
once coupons work for this, because they are removed from the subscription after used up when the invoice paid. So, if there is no free month for next month, there is no coupon.
I'm not sure if it is possible to do this with the forever coupons, if deleting them from subscriptions is not possible via the API.
Testing this now, you can remove coupons from subscriptions via the API by passing coupon=""
Oh, that's great, thanks for that!
Yeah, so that may help work around or get other functionality that you are looking for. I was just able to use it to unapply and then apply a one time coupon.
Yes, that sounds good, it's going to work for me, probably! Thanks again for your help!
I have one more question, if that's okay:
Glad I could help. And like I said I will file a bug report so needing to do that should go away
And sounds good what is your question? As a heads up I'm about to leave but @sturdy raptor is here
No problem. My other question is about events. When is it best time to add a new coupon to the subscription after the previous one was used? I tried invoice.finalized, but didn't work. It's possible though that the once problem caused it (what we've just discussed).
Hello ๐
The invoice can only be modified when it is in draft status. You can't update it once it has been finalized. So you'd likely want to rely on invoice.created webhook events instead.
Hi @sturdy raptor ,
I mean I'd like to create a new coupon once a period ended, and the previous coupon was used.
I'm planning to update the coupons at three events in the system:
- when the customer receives a new reward point (one free month)
- when the invoice is paid (a period ended)
- at plan switch (from monthly to yearly)
No problem
So, if I create a new coupon when got invoice.paid, will that discount belong to the next payment period?
It sounds logical
Yup ๐ Since you already have an integration running, you can test it out quickly w/ test clocks
Great! I will, just wanted to ask before I continue, because ran into some errors previously. But it's likely they happened because of what we discussed above.
I have one more question about plan switch, but I will ask that later. First I will do some tests and see how things work that way.
Thank you for your help!
Sounds good! Good luck ๐
Thanks ๐