Quantcast
Channel: Active questions tagged paypal - Stack Overflow
Viewing all articles
Browse latest Browse all 571

PayPal Checkout JS SDK onError not triggering when cards not processed

$
0
0

I am trying to redirect customers to an error page for my website if their card cannot be processed. It not working and all I can get is the standard PayPal alert that says "Things don't appear to be working at the moment."

What confuses me especially is that I have a redirect page for purchase approval that IS working correctly in the onApprove function (seen below).

PayPal JavaScript SDK says this is the code to redirect customers to a customer URL:

paypal.Buttons({  onError: function (err) {    // For example, redirect to a specific error page    window.location.href = "/your-error-page-here";  }}).render('#paypal-button-container');

This is what my onError function looks like:

onError: function (err) {        //My Redirect Page        window.location.href = "https://www.fitnessbydylan.com/error-page.html";}

This is my full Javascript for my PayPal button.

<script>                    function initPayPalButton() {                      paypal.Buttons({                        style: {                          shape: 'rect',                          color: 'gold',                          layout: 'vertical',                          label: 'paypal',                        },                        createOrder: function(data, actions) {                          return actions.order.create({                            purchase_units: [{"description":"1 MONTH DIGITAL COACHING","amount":{"currency_code":"USD","value":0.06,"breakdown":{"item_total":{"currency_code":"USD","value":0.06},"shipping":{"currency_code":"USD","value":0},"tax_total":{"currency_code":"USD","value":0.00}}}}]                          });                        },                        onApprove: function(data, actions) {                          return actions.order.capture().then(function(details) {                           // Simulate a mouse click:                           window.location.href = "http://www.fitnessbydylan.com/purchase-page.html";                           alert('Transaction completed by '+ details.payer.name.given_name +'!');                          });                        },                        onError: function (err) {                          // My Redirect Page                          window.location.href = "https://www.fitnessbydylan.com/error-page.html";                        },                      }).render('#paypal-button-container');                     }                    initPayPalButton();</script>

Viewing all articles
Browse latest Browse all 571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>