@paypal/payouts-sdk
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -28,3 +28,3 @@ 'use strict'; | ||
req.headers["sdk_name"] = "Payouts SDK"; | ||
req.headers["sdk_version"] = "1.0.0"; | ||
req.headers["sdk_version"] = "1.1.0"; | ||
req.headers["sdk_tech_stack"] = "NodeJS " + process.version; | ||
@@ -31,0 +31,0 @@ req.headers["api_integration_type"] = "PAYPALSDK"; |
{ | ||
"name": "@paypal/payouts-sdk", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "NodeJS SDK for PayPal Payouts APIs", | ||
@@ -14,2 +14,6 @@ "keywords": [ | ||
"main": "index", | ||
"files": [ | ||
"lib", | ||
"index.js" | ||
], | ||
"directories": { | ||
@@ -16,0 +20,0 @@ "lib": "./lib" |
@@ -40,3 +40,3 @@ # PayPal Payouts API SDK for NodeJS | ||
"items": [{ | ||
"note": "Your 5$ Payout!", | ||
"note": "Your 1$ Payout!", | ||
"amount": { | ||
@@ -49,3 +49,3 @@ "currency": "USD", | ||
}, { | ||
"note": "Your 5$ Payout!", | ||
"note": "Your 1$ Payout!", | ||
"amount": { | ||
@@ -58,3 +58,3 @@ "currency": "USD", | ||
}, { | ||
"note": "Your 5$ Payout!", | ||
"note": "Your 1$ Payout!", | ||
"amount": { | ||
@@ -67,3 +67,3 @@ "currency": "USD", | ||
}, { | ||
"note": "Your 5$ Payout!", | ||
"note": "Your 1$ Payout!", | ||
"amount": { | ||
@@ -76,3 +76,3 @@ "currency": "USD", | ||
}, { | ||
"note": "Your 5$ Payout!", | ||
"note": "Your 1$ Payout!", | ||
"amount": { | ||
@@ -97,3 +97,3 @@ "currency": "USD", | ||
// 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)}`); | ||
console.log(`Payouts Create Response: ${JSON.stringify(response.result)}`); | ||
} | ||
@@ -103,2 +103,62 @@ createPayouts(); | ||
### Handle API Failure | ||
This will create a Payout with validation failure to showcase how to parse the failed response entity. Refer samples for more scenarios | ||
#### Code to Execute: | ||
```javascript | ||
const paypal = require('@paypal/payouts-sdk'); | ||
// Creating an environment | ||
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); | ||
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(); | ||
``` | ||
## Retrieve a Payout Batch | ||
@@ -109,3 +169,3 @@ Pass the batchId from the previous sample to retrieve Payouts batch details | ||
let getPayouts = async function(batchId) { | ||
request = new paypal.payouts.PayoutsGetRequest(batch); | ||
request = new paypal.payouts.PayoutsGetRequest(batchId); | ||
request.page(1); | ||
@@ -112,0 +172,0 @@ request.pageSize(10); |
Sorry, the diff of this file is not supported yet
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
3
206
0
49077
18
558