When is the onError function called?

thierryler
Contributor
Contributor

Hello. Using the standard integration, I cannot figure out when the onError function is supposed to be called. Can someone give an example?

 

Here is my code:

 

<script src="https://www.paypal.com/sdk/js?client-id={{ ppClientId }}&currency=EUR"></script>


<script>
  showSpinner();

  paypal.Buttons({
    style: {
      shape: 'pill',
    },

    createOrder: function(data, actions) {
      return actions.order.create({
        purchase_units: [{
          amount: {
            currency_code: "EUR",
            value: "{{ price }}",
          },
          invoice_id: "{{ invoice.ppInvoiceId }}",
          custom_id: "{{ invoice.ppCustomId }}",
        }],
        {# application_context: {
          shipping_preference: "SET_PROVIDED_ADDRESS", 
        }, #}
        payer: {
          email_address: "{{ email }}",
          name: {
            given_name: "{{ firstname }}",
            surname: "{{ lastname }}",
          },
          {# phone: {
            phone_number: "{{ phone }}"
          }, #}
          address: {
            address_line_1: "{{ streetAddress1 }}",
            address_line_2: "{{ streetAddress2 }}",
            postal_code: "{{ postalCode }}",
            country_code: "{{ countryCode | upper}}",
            admin_area_2: "{{ city | upper}}",
          }
        }
      });
    },

    onApprove: function(data, actions) {
      console.log('ICE ::: onApprove ::: data: ', data)
      showSpinner();
      ...
    },

    onCancel: function (data) {
      // console.log('ICE ::: onCancel ::: data: ', data)
      hideSpinner();
    },

    onError: function (err) {
      console.log('ICE ::: onError ::: data: ', err)
      hideSpinner();
    },

    onClick: function()  {
      console.log('ICE ::: onClick')
    },

    onInit: function(data, actions)  {
      console.log('ICE ::: onInit ::: data: ', data)
      hideSpinner();
    }

  }).render('#paypal-button-container');
</script>

 

whatever I do, it never goes into onError...

 

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.