Hello stackover community, I want to integrate paypal payout functionality in my existing nodeJS Application. while doing RnD i found out that i can’t send money from paypal’s account to bank account directly. so i changed my appraoch, such as in payout api, i have passed "receipent_type" to PAYPAL_ID. i am in pakistan asia region. Paypal does not work here. now i want to test my api. from where i can get Paypal_account_ID as while completing the profile it requires me the bank account, SNS and other details which i am not having is there any way to that i can test my code
const paypalPayouts = async (req, res) => {
const { paypalID, amount, currency, note } = req.body;
if (!paypalID || !amount || !currency) {
return res
.status(400)
.json({ message: "paypalID, amount, and currency are required" });
}
const payout = {
sender_batch_header: {
sender_batch_id: Math.random().toString(36).substring(9),
email_subject: "You have a payout!",
email_message:
"You have received a payout! Thanks for using our paypal payout service!!",
},
items: [
{
recipient_type: "PAYPAL_ID",
amount: {
value: amount,
currency: currency,
},
receiver: paypalID,
note: note || "Thank you.",
sender_item_id: Math.random().toString(36).substring(9),
},
],
};
paypal.payout.create(payout, (error, payout) => {
if (error) {
console.error(error);
return res
.status(500)
.json({ message: "Error creating payout", error: error.response });
} else {
console.log("paypal Payout response=>", payout);
return res
.status(200)
.json({ message: "Payout created successfully", payout: payout });
}
});
};
how can i get my accountID or is there any way to run this api.
2
Answers
you need to pass the accountID, when you make an account in paypal in sandbox mode you need an extra account as well to perform the tesing such as one account as admin one account as buyer. Go to sandbox account and open admin account. you will find the ID there. same goes for the buyer account. copy the buyer account ID and pass in the JSON such as below hit the api. the balance will be deducted from one account and will be added into another account
For testing purposes in sandbox mode only, I think the only way is to log into the developer portal with an account of type "developer" to create/manage sandbox accounts and REST Apps. To do this you likely need to click ‘sign up’ at that link (for a "free developer account") and choose country ‘United States’ for that type of account to be possible. A VPN might possibly be necessary, not sure.