Handle funding failures

DocsCurrent

Last updated: Feb 28th, 7:37pm

If your payer's funding source fails, the Orders API returns an INSTRUMENT_DECLINED error. A funding source might fail for the following reasons:

  • The billing address associated with the payment method is incorrect.
  • The transaction exceeds the card limit.
  • The card issuer denied the transaction.

To handle this error, restart the payment so the payer can select a different payment option.

Know before you code

Required
Get Started

Complete the steps in Get started to get the following sandbox account information from the Developer Dashboard:

  • Your personal and business sandbox accounts.
  • Your access token.
Get started

Required
Standard Checkout

This feature modifies an existing standard Checkout integration and uses the following:

Optional
Explore PayPal APIs with Postman

You can use Postman to explore and test PayPal APIs. Learn more in our Postman guide.

Restart the payment

Restarting the payment is required if you directly call the Orders API from your server. If you use actions.order.capture(), the script automatically restarts the checkout flow and prompts the payer to select a different funding source.

Restart the payment in the onApprove function as follows:

    1paypal.Buttons({
    2 onApprove: function (data, actions) {
    3 return fetch('/my-server/capture-paypal-transaction', {
    4 headers: {
    5 'content-type': 'application/json'
    6 },
    7 body: JSON.stringify({
    8 orderID: data.orderID
    9 })
    10 }).then(function(res) {
    11 return res.json();
    12 }).then(function(captureData) {
    13 if (captureData.error === 'INSTRUMENT_DECLINED'); // Your server response structure and key names are what you choose
    14 return actions.restart();
    15 }
    16 });
    17 }
    18}).render('#paypal-button-container');