If you're using coupons with your payments you can optionally include pre-validation on coupons seperate to the regular full validation.
Note: this validation is additional to the native coupon validation. Coupons are always validated when they are applied to a payment, regardless of this setup.
When a coupon field is passed as part of a payment attempt it is validated. If valid the payment attempt will continue, but if not, the submission will return with an error attached to the coupon field, with a message similar to 'Sorry, this coupon code is invalid'.
Optionally you can use the extra AJAX endpoint of : charge/coupon/validate
to check the validity of a coupon prior to form submission, and return a valid/invalid message early.
charge/coupon/validate
coupon
This endpoint always return a JSON response.
Success State :
valid
Bool TRUEmessage
String 'This coupon is valid'paymentType
String 'One-off' or 'Recurring'coupon
Array of the associated couponFailure State :
valid
Bool FALSEmessage
String similar to : 'Sorry, this coupon is invalid' etc..Note: Just because a coupon returns as valid doesn't guarantee it will be accepted for the payment. Further restrictions may apply when the coupon is applied such as paymentType mismatch, limits on usages, etc... Always include coupon validation error message output in your templates.