Node.js Paypal Payout api error in Live enviornment

297 Views Asked by At

I am using a PayPal payout API to transfer money, its working perfect in sandbox environment but when I changed it to live environment it is throwing some error:

text: '{"name":"VALIDATION_ERROR","message":"Invalid request - see details","debug_id":"a641429b40e07","information_link":"https://developer.paypal.com/docs/api/payments.payouts-batch/#errors","details":[{"field":"items[0].receiver","location":"body","issue":"may not be null"}],"links":[]}'

This is the code I am using to request a payout

let requestBody = {

    "sender_batch_header": {
        "recipient_type": "EMAIL",
        "email_message": "SDK payouts test txn",
        "note": "Enjoy your Payout!!",
        "sender_batch_id": 'asd12432',
        "email_subject": "This is a test transaction from SDK"
    },
    "items": [{
        "note": "Your 5$ Payout!",
        "amount": {
            "currency": "USD",
            "value": 20
        },
        "receiver": '[email protected]',
        "sender_item_id": "Test_txn_1"
    }]
}

// Construct a request object and set desired parameters
// Here, PayoutsPostRequest() creates a POST request to /v1/payments/payouts
let request = new paypal.payouts.PayoutsPostRequest();
request.requestBody(requestBody);


// Call API with your client and get a response for your call
let createPayouts = async function () {
    let response = await client.execute(request);
    console.log(`Response: ${JSON.stringify(response.statusCode)}`);

    // If caladfl returns body in response, you can get the deserialized version from the result attribute of the response.
    console.log(`Payouts Create Response: ${JSON.stringify(response.result)}`);
    //res.redirect('/adam?payment=success');
    res.redirect('/adam?payment=success');

}
createPayouts();
0

There are 0 best solutions below