Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@parkerproject/paypal-payouts-sdk
Advanced tools
NodeJS SDK for PayPal Payouts APIs that accepts accessToken
Forked from the official SDK.
Please refer to the PayPal Payouts Integration Guide for more information. Also refer to Setup your SDK for additional information about setting up the SDK's.
This will create a Payout and print the batch_id for the Payout.
const paypal = require('@parkerproject/paypal-payouts-sdk');
// Creating an environment using client id and secret
let clientId = "<<PAYPAL-CLIENT-ID>>";
let clientSecret = "<<PAYPAL-CLIENT-SECRET>>";
let environment = new paypal.core.SandboxEnvironment(clientId, clientSecret);
let client = new paypal.core.PayPalHttpClient(environment);
// Creating an environment using access token
let accessToken = "<<PAYPAL-ACCESS-TOKEN>>"
let environment = new paypal.core.SandboxEnvironmentWithAccessToken(accessToken);
let client = new paypal.core.PayPalHttpClient(environment);
let requestBody = {
"sender_batch_header": {
"recipient_type": "EMAIL",
"email_message": "SDK payouts test txn",
"note": "Enjoy your Payout!!",
"sender_batch_id": "Test_sdk_1",
"email_subject": "This is a test transaction from SDK"
},
"items": [{
"note": "Your 1$ Payout!",
"amount": {
"currency": "USD",
"value": "1.00"
},
"receiver": "payout-sdk-1@paypal.com",
"sender_item_id": "Test_txn_1"
}, {
"note": "Your 1$ Payout!",
"amount": {
"currency": "USD",
"value": "1.00"
},
"receiver": "payout-sdk-2@paypal.com",
"sender_item_id": "Test_txn_2"
}, {
"note": "Your 1$ Payout!",
"amount": {
"currency": "USD",
"value": "1.00"
},
"receiver": "payout-sdk-3@paypal.com",
"sender_item_id": "Test_txn_3"
}, {
"note": "Your 1$ Payout!",
"amount": {
"currency": "USD",
"value": "1.00"
},
"receiver": "payout-sdk-4@paypal.com",
"sender_item_id": "Test_txn_4"
}, {
"note": "Your 1$ Payout!",
"amount": {
"currency": "USD",
"value": "1.00"
},
"receiver": "payout-sdk-5@paypal.com",
"sender_item_id": "Test_txn_5"
}]
}
// 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)}`);
// If call 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)}`);
}
createPayouts();
This will create a Payout with validation failure to showcase how to parse the failed response entity. Refer samples for more scenarios
const paypal = require('@parkerproject/paypal-payouts-sdk');
// Creating an environment using client id and secret
let clientId = "<<PAYPAL-CLIENT-ID>>";
let clientSecret = "<<PAYPAL-CLIENT-SECRET>>";
let environment = new paypal.core.SandboxEnvironment(clientId, clientSecret);
let client = new paypal.core.PayPalHttpClient(environment);
// Creating an environment using access token
let accessToken = "<<PAYPAL-ACCESS-TOKEN>>"
let environment = new paypal.core.SandboxEnvironmentWithAccessToken(accessToken);
let client = new paypal.core.PayPalHttpClient(environment);
let requestBody = {
"sender_batch_header": {
"recipient_type": "EMAIL",
"email_message": "SDK payouts test txn",
"note": "Enjoy your Payout!!",
"sender_batch_id": "Test_sdk_fail",
"email_subject": "This is a test transaction from SDK"
},
"items": [{
"note": "Your 1$ Payout!",
"amount": {
"currency": "USD",
"value": "1.00"
},
"receiver": "payout-sdk-1@paypal.com",
"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(){
try {
let response = await client.execute(request);
console.log(`Response: ${JSON.stringify(response)}`);
// If call 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)}`);
catch (e) {
if (e.statusCode) {
//Handle server side/API failure response
console.log("Status code: ", e.statusCode);
// Parse failure response to get the reason for failure
const error = JSON.parse(e.message)
console.log("Failure response: ", error)
console.log("Headers: ", e.headers)
} else {
//Hanlde client side failure
console.log(e)
}
}
}
createPayouts();
Pass the batchId from the previous sample to retrieve Payouts batch details
let getPayouts = async function(batchId) {
request = new paypal.payouts.PayoutsGetRequest(batchId);
request.page(1);
request.pageSize(10);
request.totalRequired(true);
// Call API with your client and get a response for your call
let response = await client.execute(request);
console.log(`Response: ${JSON.stringify(response)}`);
// If call returns body in response, you can get the deserialized version from the result attribute of the response.
console.log(`Payouts Batch: ${JSON.stringify(response.result)}`);
}
getPayouts('REPLACE-WITH-BATCH-ID');
To run integration tests using your client id and secret, clone this repository and run the following command:
$ npm install
$ PAYPAL_CLIENT_ID=YOUR_SANDBOX_CLIENT_ID PAYPAL_CLIENT_SECRET=YOUR_SANDBOX_CLIENT_SECRET npm test
You can start off by trying out Payouts Samples
To run samples run the following command:
$ npm install
$ PAYPAL_CLIENT_ID=YOUR_SANDBOX_CLIENT_ID PAYPAL_CLIENT_SECRET=YOUR_SANDBOX_CLIENT_SECRET npm test
To try out different samples head to this link
Note: Update the payPalClient.js
with your sandbox credentials or pass your client credentials as environment variable while executing the samples.
PayPalHttpClient used as part of this project returns Promises
You can read more about Promises here: https://www.promisejs.org/
Code released under SDK LICENSE
FAQs
NodeJS SDK for PayPal Payouts APIs that accepts accessToken
We found that @parkerproject/paypal-payouts-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.