ethercreative / web-payments

Web Payments for Craft Commerce
Other
5 stars 7 forks source link

How to set redirect to url on payment failure? #12

Open davecosec opened 4 years ago

davecosec commented 4 years ago

is there a way to set the redirect on payment failure?

billythekid commented 4 years ago

@davecosec did you work this out?

davecosec commented 4 years ago

yeah, ended up editing the JS code after setting the repo to path @billythekid which is not ideal at all. Had to unminify web-payments.js then in the onToken function in the post("pay", {... call back

                if(data.status == "fail"){

                    e.complete('fail');

                    alert('Payment failed, please try another method');

                }else {

                    e.complete(data.status), state.onComplete.js && eval("const cwp = { number: '" + data.number + "' };" + state.onComplete.js), state.onComplete.redirect && (window.location = state.onComplete.redirect.replace("{number}", data.number))
                 }
billythekid commented 4 years ago

@davecosec yeah not ideal to have to fork the repo and edit it but great to know it is possible. Would be nice to be able to pass the path as a property in the twig call or something.

Thanks so much for taking the time to respond.