Проверка Использование формата application / x-www-form-urlencoded из Axios doc
Если вы используете его из браузера:
const params = new URLSearchParams();
params.append('USER', 'Caller_ID');
params.append('PWD', 'Caller_Pswd');
params.append('SIGNATURE', 'Caller_Sig');
params.append('METHOD', 'SetExpressCheckout');
params.append('RETURNURL', 'https://example.com/success.html');
params.append('CANCELURL', 'https://example.com/canceled.html');
params.append('VERSION', 93);
params.append('PAYMENTREQUEST_0_CURRENCYCODE', 'USD');
params.append('PAYMENTREQUEST_0_AMT', 250);
params.append('PAYMENTREQUEST_0_ITEMAMT', 225);
params.append('PAYMENTREQUEST_0_TAXAMT', 25);
params.append('PAYMENTREQUEST_0_PAYMENTACTION', 'Sale');
params.append('PAYMENTREQUEST_0_DESC', 'Sandwich Combo');
params.append('PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID', 'Receiver_1');
params.append('PAYMENTREQUEST_0_PAYMENTREQUESTID', 'CART1');
params.append('L_PAYMENTREQUEST_0_NAME0', 'Super Sub');
params.append('L_PAYMENTREQUEST_0_NUMBER0', 'SS-101');
params.append('L_PAYMENTREQUEST_0_QTY0', 1);
params.append('L_PAYMENTREQUEST_0_AMT0', 125);
params.append('L_PAYMENTREQUEST_0_TAXAMT0', 15);
params.append('L_PAYMENTREQUEST_0_NAME1', 'Classic Wineinformation');
params.append('L_PAYMENTREQUEST_0_QTY1', 1);
params.append('L_PAYMENTREQUEST_0_AMT1', 100);
params.append('L_PAYMENTREQUEST_0_TAXAMT1', 10);
params.append('PAYMENTREQUEST_1_CURRENCYCODE', 'USD');
params.append('PAYMENTREQUEST_1_AMT', 75);
params.append('PAYMENTREQUEST_1_ITEMAMT', 65);
params.append('PAYMENTREQUEST_1_TAXAMT', 10);
params.append('PAYMENTREQUEST_1_PAYMENTACTION', 'Sale');
params.append('PAYMENTREQUEST_1_DESC', 'Mocktail Large');
params.append('PAYMENTREQUEST_1_SELLERPAYPALACCOUNTID', 'Receiver_2');
params.append('PAYMENTREQUEST_1_PAYMENTREQUESTID', 'CART2');
params.append('L_PAYMENTREQUEST_1_NAME0', 'Orange crush');
params.append('L_PAYMENTREQUEST_1_NUMBER0', 'MC-77');
params.append('L_PAYMENTREQUEST_1_QTY0', 1);
params.append('L_PAYMENTREQUEST_1_AMT0', 65);
params.append('L_PAYMENTREQUEST_1_TAXAMT0', 1);
axios.post('https://api-3t.sandbox.paypal.com/nvp', params);
.then(function(response) {
//handle success
console.log(response);
})
.catch(function(response) {
//handle error
console.log(response);
});
С nodejs :
const querystring = require('querystring');
axios.post('https://api-3t.sandbox.paypal.com/nvp', querystring.stringify({
USER: "Caller_ID",
PWD: "Caller_Pswd",
SIGNATURE: "Caller_Sig",
METHOD: "SetExpressCheckout",
RETURNURL: "https: //example.com/success.html",
CANCELURL: "https: //example.com/canceled.html ",
VERSION: 93,
PAYMENTREQUEST_0_CURRENCYCODE: "USD",
PAYMENTREQUEST_0_AMT: 250,
PAYMENTREQUEST_0_ITEMAMT: 225,
PAYMENTREQUEST_0_TAXAMT: 25,
PAYMENTREQUEST_0_PAYMENTACTION: "Sale",
PAYMENTREQUEST_0_DESC: "Sandwich Combo",
PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID: "Receiver_1",
PAYMENTREQUEST_0_PAYMENTREQUESTID: "CART1",
L_PAYMENTREQUEST_0_NAME0: "Super Sub",
L_PAYMENTREQUEST_0_NUMBER0: "SS-101",
L_PAYMENTREQUEST_0_QTY0: 1,
L_PAYMENTREQUEST_0_AMT0: 125,
L_PAYMENTREQUEST_0_TAXAMT0: 15,
L_PAYMENTREQUEST_0_NAME1: "Classic Wineinformation",
L_PAYMENTREQUEST_0_QTY1: 1,
L_PAYMENTREQUEST_0_AMT1: 100,
L_PAYMENTREQUEST_0_TAXAMT1: 10,
PAYMENTREQUEST_1_CURRENCYCODE: "USD",
PAYMENTREQUEST_1_AMT: 75,
PAYMENTREQUEST_1_ITEMAMT: 65,
PAYMENTREQUEST_1_TAXAMT: 10,
PAYMENTREQUEST_1_PAYMENTACTION: "Sale",
PAYMENTREQUEST_1_DESC: "Mocktail Large",
PAYMENTREQUEST_1_SELLERPAYPALACCOUNTID: "Receiver_2",
PAYMENTREQUEST_1_PAYMENTREQUESTID: "CART2",
L_PAYMENTREQUEST_1_NAME0: "Orange crush",
L_PAYMENTREQUEST_1_NUMBER0: "MC-77",
L_PAYMENTREQUEST_1_QTY0: 1,
L_PAYMENTREQUEST_1_AMT0: 65,
L_PAYMENTREQUEST_1_TAXAMT0: 1,
}));