Validate coupon codes

Played around with the coupon function, it is working perfectly. :+1:

I have a concern though, on promo code validation, or lack of.

To repro:

  1. Entered a valid test CC
  2. Entered a random promo code that doesn’t exist in my coupon configuration
  3. Transaction was completed
  4. The full price was charged without any discounts

System-wise, this is expected behaviour, don’t get me wrong. But I am hoping to get consensus that step 2 requires some form of user intervention, The process should be halted and the user prompted if an invalid promo code is entered.

By allowing the transaction to go through, the user expects a discounted price but will be surprised at the full charge. The occurrence of typos is real, I have seen users fumbling with even the simplest copy-paste instructions.

Some considerations if this can be repro by all:

  • Introduce validation checking of promo codes
  • Ability to prefill the promo code field through hardcoded URL parameters to minimize manual typing e.g. /s/productname?promo_code=awesomesupporter

Good catch! I’ll add this to the list of improvements to make.


Thank you Justin, really appreciate of the work put into this.


Coupon code validation is implemented in this PR:

EDIT: Merged.