> Let’s say your app also allows promotional codes to be used, and that promo codes in your app live outside Stripe, because Stripe does not support promo codes for your type of product. What this means in practice is that before calling Stripe’s confirmPayment, you have to send a request to your server with the promo code that the user wants to apply. This request can respond in one of two ways - either the promo code is valid, or it isn’t. If it is valid, then you can go ahead and call confirmPayment. If it isn’t valid, then you need to render validation errors.
This is an extremely trivial bit of JavaScript, but it is made difficult because it is trying to use a JavaScript framework developed by people who hate JavaScript. Do the form validation on the client side to give users instant feedback and then do final validation on the server side where you enforce business rules. These are two different kinds of validation and it's not actually effort saving to try to combine them. If you have good client side validation, you can just be a hard ass on the server side because you know that anyone who gets the server side error is already bypassing client side validation, so they are being naughty to begin with. It makes like easier to keep the validation separate.
This is an extremely trivial bit of JavaScript, but it is made difficult because it is trying to use a JavaScript framework developed by people who hate JavaScript. Do the form validation on the client side to give users instant feedback and then do final validation on the server side where you enforce business rules. These are two different kinds of validation and it's not actually effort saving to try to combine them. If you have good client side validation, you can just be a hard ass on the server side because you know that anyone who gets the server side error is already bypassing client side validation, so they are being naughty to begin with. It makes like easier to keep the validation separate.