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.
Last updated: May 14th, 9:26am
If your payer's funding source fails, the Orders API returns an INSTRUMENT_DECLINED
error. A funding source might fail for the following reasons:
To handle this error, restart the payment so the payer can select a different payment option.
Complete the steps in Get started to get the following sandbox account information from the Developer Dashboard:
This feature modifies an existing PayPal Checkout integration and uses the following:
You can use Postman to explore and test PayPal APIs. Learn more in our Postman guide.
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.orderID9 })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 choose14 return actions.restart();15 }16 });17 }18}).render('#paypal-button-container');