New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

paypal-server-api

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paypal-server-api - npm Package Compare versions

Comparing version 0.0.8 to 1.0.0

48

dist/index.js

@@ -28,8 +28,12 @@ const fetch = require('wonderful-fetch');

const self = this;
const url = `${self._getURL('v1/oauth2/token')}`;
if (self.log) {
console.log('Authenticate', url);
}
return new Promise(function(resolve, reject) {
const url = `${self._getURL('v1/oauth2/token')}`;
// Log
if (self.log) {
console.log('Authenticate', url);
}
// Authenticate with server
fetch(url, {

@@ -52,3 +56,5 @@ method: 'post',

}
self.access_token = json.access_token;
return resolve(json);

@@ -65,10 +71,8 @@ })

options = options || {};
url = self._getURL(url);
if (self.log) {
console.log('Execute', url);
}
return new Promise(function(resolve, reject) {
options = options || {};
url = self._getURL(url);
let payload =
{
// Build payload
const payload = {
response: 'text',

@@ -86,7 +90,13 @@ tries: 2,

if (options.body) {
payload.body = JSON.stringify(options.body);
}
// Add body
if (options.body) {
payload.body = options.body;
}
return new Promise(function(resolve, reject) {
// Log
if (self.log) {
console.log('Execute', url, payload.headers, payload.body || {});
}
// Execute
fetch(url, payload)

@@ -108,8 +118,12 @@ .then(async (text) => {

const self = this;
url = (url || '')
// Remove leading slashes
.replace(/^\/+/, '')
return (self.environment === 'sandbox' || self.environment === 'development' || self.environment === 'dev'
? `https://api-m.sandbox.paypal.com/${url}`
: `https://api.paypal.com/${url}`).replace(/v1\/\//g, '')
: `https://api.paypal.com/${url}`)
};
module.exports = PayPal;
{
"name": "paypal-server-api",
"version": "0.0.8",
"version": "1.0.0",
"description": "Powerful assistive library for interacting with the PayPal API.",

@@ -8,3 +8,3 @@ "main": "dist/index.js",

"test": "npm run prepare && ./node_modules/mocha/bin/mocha test/ --recursive --timeout=10000",
"prepare": "node -e 'require(`prepare-package`)'"
"prepare": "node -e 'require(`prepare-package`)()'"
},

@@ -36,5 +36,5 @@ "engines": {

"fs-jetpack": "^4.3.1",
"mocha": "^8.0.1",
"prepare-package": "^0.0.13"
"mocha": "^8.4.0",
"prepare-package": "^0.0.16"
}
}

@@ -25,3 +25,3 @@ <p align="center">

<br>
<strong>PayPal API</strong> is an NPM module for backend and frontend developers that exposes powerful utilities and tools.
<strong>PayPal API</strong> makes it easy to work with the PayPal API.
</p>

@@ -39,3 +39,3 @@

## Example Setup
After installing via npm, simply `require` the library and begin enjoying the library 🧰.
After installing via npm, simply `require` the library and authenticate it.
```js

@@ -45,10 +45,42 @@ // In your functions/index.js file

const paypal = new Payapl({
clientId: 'client_id',
secret: 'secret',
environment: 'production', // production | sandbox
log: true,
clientId: 'client_id', // Your PayPal client ID
secret: 'secret', // Your PayPal secret
environment: 'production', // Determine which API URL to use (sandbox OR production)
log: true, // Log some information to the console
});
// Authenticate with PayPal
await paypal.authenticate();
const billingData = await paypal.execute(`v1/billing/subscriptions/I-ABC123ABC123`);
```
## Making calls
After installing and authenticating, begin enjoying the library 🧰.
```js
// Get subscription details
const subscription = await paypal.execute(`v1/billing/subscriptions/I-ABC123ABC123`);
// Update subscription pricing
const update = await paypal.execute(`v1/billing/subscriptions/I-ABC123ABC123`, {
method: 'PATCH',
body: [
{
op: 'replace',
path: '/plan/billing_cycles/@sequence==1/pricing_scheme/fixed_price',
value: {
currency_code: 'USD',
value: '19.95',
},
},
{
op: 'replace',
path: '/plan/payment_preferences/payment_failure_threshold',
value: 0,
},
{
op: 'replace',
path: '/plan/payment_preferences/auto_bill_outstanding',
value: true,
},
]
});
```

@@ -55,0 +87,0 @@

@@ -28,8 +28,12 @@ const fetch = require('wonderful-fetch');

const self = this;
const url = `${self._getURL('v1/oauth2/token')}`;
if (self.log) {
console.log('Authenticate', url);
}
return new Promise(function(resolve, reject) {
const url = `${self._getURL('v1/oauth2/token')}`;
// Log
if (self.log) {
console.log('Authenticate', url);
}
// Authenticate with server
fetch(url, {

@@ -52,3 +56,5 @@ method: 'post',

}
self.access_token = json.access_token;
return resolve(json);

@@ -65,10 +71,8 @@ })

options = options || {};
url = self._getURL(url);
if (self.log) {
console.log('Execute', url);
}
return new Promise(function(resolve, reject) {
options = options || {};
url = self._getURL(url);
let payload =
{
// Build payload
const payload = {
response: 'text',

@@ -86,7 +90,13 @@ tries: 2,

if (options.body) {
payload.body = JSON.stringify(options.body);
}
// Add body
if (options.body) {
payload.body = options.body;
}
return new Promise(function(resolve, reject) {
// Log
if (self.log) {
console.log('Execute', url, payload.headers, payload.body || {});
}
// Execute
fetch(url, payload)

@@ -108,8 +118,12 @@ .then(async (text) => {

const self = this;
url = (url || '')
// Remove leading slashes
.replace(/^\/+/, '')
return (self.environment === 'sandbox' || self.environment === 'development' || self.environment === 'dev'
? `https://api-m.sandbox.paypal.com/${url}`
: `https://api.paypal.com/${url}`).replace(/v1\/\//g, '')
: `https://api.paypal.com/${url}`)
};
module.exports = PayPal;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc