Case-sensitive coupons allow for human error

552 views
Skip to first unread message

Dan Philibin

unread,
Jun 30, 2016, 5:40:04 PM6/30/16
to Stripe API Discussion
I've run into issues with several clients who use coupons, and the issues arise because Stripe's coupons are case-sensitive. And this allows for human error in two ways: when my client enters coupons in the backend, or when the user enters a coupon in the registration form.

1. Admin error:  Because coupons are case-sensitive, my applications convert coupons to all-lowercase (or all-uppercase) letters before including them in a Stripe request so the case is guaranteed on Stripe's end. But this means dashboard admins have to remember to create coupons using all lowercase or uppercase letters, and everyone I've worked with has had coupons not work because they forgot this.

2. User error: If I did it the other way around and let admins enter coupons as they please and advertise them with the matching case, then the responsibility is on the user to match the case exactly. Sometimes for readability purposes, CamelCased is easier to read & advertise. For all-caps coupons, sometimes users don't care and type them in with all lowercase letters. Or maybe they're on mobile with auto-capitalize-first-letters turned on, and the coupon is entered with just the Firstlettercapitalized.

So my proposal here is either for coupons to not be case-sensitive anymore, or for Stripe to handle the case conversion so neither dashboard admins nor users have to worry about what case a coupon is entered. (If there are technical reasons or product decisions regarding why coupons are and might remain case-sensitive, I'd love to hear about it!)

Remi J.

unread,
Jun 30, 2016, 5:48:14 PM6/30/16
to api-d...@lists.stripe.com
Hey Dan,

Coupons are case-sensitive on our end as you mentioned and I'm not sure it would make sense for all coupons to become case-insensitive for everyone. Some users might already rely on that behavior or expect it in the first place and not everyone would agree that 50OFF should work if the coupon is called "50off".

There are multiple solutions that you can use here though. The first one is to build an admin page on your end where your users can go and create the coupon(s) directly. This would go through your own code so that you can validate the input or convert it to lower case automatically to avoid any mistakes. 

Another solution would be to use webhooks and listen for `coupon.created` events. This allows you to detect when a coupon was just created and react accordingly if it doesn't match your requirements (not fully lower case for example). You could then:
- warn the user of the issue.
- delete the coupon and recreate a new one with the same values but a lower case id instead.
- store in your database a reference to that coupon. Let's say someone creates the coupon SUMMER50OFF. You can detect it and from now on remember that anytime someone uses a coupon that reads summer50off after being converted to lower-case, your code should use SUMMER50OFF in the API.

I hope this helps!
Remi

--
You received this message because you are subscribed to the Google Groups "Stripe API Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.
To post to this group, send email to api-d...@lists.stripe.com.
Visit this group at https://groups.google.com/a/lists.stripe.com/group/api-discuss/.

Dan Philibin

unread,
Jul 1, 2016, 11:07:35 PM7/1/16
to Stripe API Discussion
Hey Remi — thanks for the response. Little more work than I'd like on my end, but I understand the implications of a flat-out change to case insensitivity and that it might not be for everyone. Setting up a webhook to correct improper coupons sounds like the fastest option—really appreciate the suggestions.

Thanks,

Dan
Reply all
Reply to author
Forward
0 new messages