Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
paypal-rest-api
Advanced tools
This package is NOT supported by PayPal. The current PayPal Node SDK does not support the newest Javascript features. This package is intended to support the most cutting edge Javascript features.
yarn add paypal-rest-api
All examples in this README are using Typescript, however this module can be included in CommonJS(require) as well. See the common.js example for how to use CommonJS with this module.
The most up to date configuration options can be found on the IConfigureOptions interface
import { PayPalRestApi } from "../src";
const paypal = new PayPalRestApi({
client_id: "", // Your paypal client id
client_secret": "", // Your paypal client secret
mode: "sandbox", // "production" or "sandbox"
requestOptions: {
maxRetries: 2, // Sets the number of retries for 500 or Network timeout. Set to 0 to disable.
retryDelay: 5000, // Microseconds to wait until next retry. 5000 = 5 seconds
// Any options from the following
// https://github.com/FGRibreau/node-request-retry
// https://github.com/request/request
},
});
It is STRONGLY recommended to use VSCode for the debugger and breakpoints. You must npm install first.
use the yarn run example script and pass in any file path from the examples folder.
git clone https://github.com/trainerbill/paypal-rest-api.git
cd paypal-rest-api
yarn install
yarn run example examples/invoice/model/create-update-send-get.ts
The repo provides some launch configurations and tasks for VsCode. Switch to the Debugger, open the example file you want to run, select the "Launch Example File" configuration and select run.
There are 3 different methods to make API Calls. It is STRONGLY recommended to use the Model approach. For full examples refer to the examples folder.
The modeling approach provides the most functionality. By storing the information in a model we can validate additional information before making another api call. For example, an invoice can only be deleted if it is in a DRAFT state. Using modeling we can prevent the delete api call unless the status is DRAFT. We also do not have to keep passing around ids since the information is stored on the model.
import { PayPalRestApi } from "paypal-rest-api";
const paypal = new PayPalRestApi({
client_id: "YOUR_CLIENT_ID",
client_secret: "YOUR_CLIENT_SECRET",
mode: "sandbox",
});
const invoice = new paypal.invoice({
merchant_info: {
business_name: "testy",
},
});
// Create an invoice, send it, delete will throw an exception before sending the api call.
invoice.create()
.then(() => invoice.send())
.then(() => invoice.delete())
.catch((err) => console.log(err));
All api functions are available on the models. You can access them on the api property. Each API function takes the requestretry options as an argument so you set the body property to your api payload. Each API function returns a request response. All api functions are validated via a schema. Occasionally these may fail so please submit an issue.
import { PayPalRestApi } from "paypal-rest-api";
const paypal = new PayPalRestApi({
client_id: "YOUR_CLIENT_ID",
client_secret: "YOUR_CLIENT_SECRET",
mode: "sandbox",
});
paypal.invoice.api.create({
body: {
merchant_info: {
business_name: "testy",
},
}
})
.then((response) => {
return response.body.id;
})
.then((id) => paypal.invoice.api.send(id))
.catch((err) => console.log(err));
If an API function does not exist or you are getting a false negative on a schema validation, you can always use the request method to directly execute an API call to an endpoint. You must specify the path, method, and more than likely the body.
import { PayPalRestApi } from "../src";
const paypal = new PayPalRestApi({
client_id: "YOUR_CLIENT_ID",
client_secret: "YOUR_CLIENT_SECRET",
mode: "sandbox",
});
paypal.client.request({
body: {
merchant_info: {
business_name: "testy",
},
},
method: "POST",
uri: "v1/invoicing/invoices/",
})
.then((response) => console.log(response))
.catch((err) => console.error(err));
FAQs
A typescript module for integrating with PayPal REST APIs.
The npm package paypal-rest-api receives a total of 11 weekly downloads. As such, paypal-rest-api popularity was classified as not popular.
We found that paypal-rest-api 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.