Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

paypal-v2-sdk

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paypal-v2-sdk - npm Package Compare versions

Comparing version 1.1.10 to 1.1.11

2

package.json

@@ -6,3 +6,3 @@ {

"name": "paypal-v2-sdk",
"version": "1.1.10",
"version": "1.1.11",
"description": "Unofficial promise-based PayPal API v2 SDK for node.js",

@@ -9,0 +9,0 @@ "main": "index.js",

@@ -13,5 +13,5 @@ const Axios = require("axios").default;

async requestNewToken(clientId, clientSecret) {
async requestNewToken(clientId, clientSecret, sandbox) {
const response = await Axios.post(
"https://api.paypal.com/v1/oauth2/token",
`https://${sandbox ? "api-m.sandbox" : "api"}.paypal.com/v1/oauth2/token`,
"grant_type=client_credentials",

@@ -43,3 +43,3 @@ {

this.setAxiosDefaults();
this.setAxiosDefaults(sandbox);

@@ -52,4 +52,8 @@ setTimeout(() => {

setAxiosDefaults() {
this.PayPal.setDefaultAuthorizationHeader(this.token);
setAxiosDefaults(sandbox) {
this.PayPal.setDefaultAuthorizationHeader(this.token)
.setDefaultBaseUrl(
sandbox ? "https://api-m.sandbox.paypal.com" : "https://api.paypal.com"
)
.setDefaultHeaders();
}

@@ -56,0 +60,0 @@

@@ -8,2 +8,7 @@ const Axios = require("axios").default;

setDefaultBaseUrl(url) {
this.Axios.defaults.baseURL = url;
return this;
}
setDefaultAuthorizationHeader(token) {

@@ -14,2 +19,7 @@ this.Axios.defaults.headers.common["Authorization"] = `Bearer ${token}`;

setDefaultHeaders() {
this.Axios.defaults.headers.common["Content-Type"] = "application/json";
return this;
}
post(...args) {

@@ -26,4 +36,8 @@ return this.Axios.post(...args);

}
delete(...args) {
return this.Axios.delete(...args);
}
}
module.exports = API;

@@ -14,10 +14,5 @@ const PayPalClass = require("../../PayPal");

async request() {
const response = await this.PayPal.Axios.post(
"https://api.paypal.com/v2/invoicing/generate-next-invoice-number",
null,
{
headers: {
"Content-Type": "application/json",
},
}
const response = await this.PayPal.post(
"/v2/invoicing/generate-next-invoice-number",
{}
);

@@ -24,0 +19,0 @@ this.setNumber(response.data.invoice_number);

@@ -18,10 +18,3 @@ const PayPalClass = require("../../PayPal");

async get(id) {
const response = await this.PayPal.Axios.get(
`https://api.paypal.com/v2/invoicing/invoices/${id}`,
{
headers: {
"Content-Type": "application/json",
},
}
);
const response = await this.PayPal.get(`/v2/invoicing/invoices/${id}`, {});
return response.data;

@@ -35,11 +28,5 @@ }

async list(query) {
const response = await this.PayPal.Axios.get(
"https://api.paypal.com/v2/invoicing/invoices",
{
headers: {
"Content-Type": "application/json",
},
params: query,
}
);
const response = await this.PayPal.get("/v2/invoicing/invoices", {
params: query,
});
return response.data;

@@ -54,11 +41,5 @@ }

async create(json) {
const response = await this.PayPal.Axios.post(
`https://api.paypal.com/v2/invoicing/invoices`,
{
headers: {
"Content-Type": "application/json",
},
data: json,
}
);
const response = await this.PayPal.post(`/v2/invoicing/invoices`, {
data: json,
});
return response.data;

@@ -73,9 +54,5 @@ }

async delete(id) {
const response = await this.PayPal.Axios.delete(
`https://api.paypal.com/v2/invoicing/invoices/${id}`,
{
headers: {
"Content-Type": "application/json",
},
}
const response = await this.PayPal.delete(
`/v2/invoicing/invoices/${id}`,
{}
);

@@ -92,8 +69,5 @@ return response.status === 204;

async cancel(id, query) {
const response = await this.PayPal.Axios.post(
`https://api.paypal.com/v2/invoicing/invoices/${id}/cancel`,
const response = await this.PayPal.post(
`/v2/invoicing/invoices/${id}/cancel`,
{
headers: {
"Content-Type": "application/json",
},
data: query,

@@ -111,8 +85,5 @@ }

async generateQrCode(id, query) {
const response = await this.PayPal.Axios.post(
`https://api.paypal.com/v2/invoicing/invoices/${id}/generate-qr-code`,
const response = await this.PayPal.post(
`/v2/invoicing/invoices/${id}/generate-qr-code`,
{
headers: {
"Content-Type": "application/json",
},
data: query,

@@ -130,8 +101,5 @@ }

async recordPayment(id, query) {
const response = await this.PayPal.Axios.post(
`https://api.paypal.com/v2/invoicing/invoices/${id}/payments`,
const response = await this.PayPal.post(
`/v2/invoicing/invoices/${id}/payments`,
{
headers: {
"Content-Type": "application/json",
},
data: query,

@@ -150,8 +118,5 @@ }

async recordRefund(id, query) {
const response = await this.PayPal.Axios.post(
`https://api.paypal.com/v2/invoicing/invoices/${id}/refunds`,
const response = await this.PayPal.post(
`/v2/invoicing/invoices/${id}/refunds`,
{
headers: {
"Content-Type": "application/json",
},
data: query,

@@ -164,9 +129,5 @@ }

async deleteExternalPayment(invoiceId, transactionId) {
const response = await this.PayPal.Axios.delete(
`https://api.paypal.com/v2/invoicing/invoices/${invoiceId}/payments/${transactionId}`,
{
headers: {
"Content-Type": "application/json",
},
}
const response = await this.PayPal.delete(
`/v2/invoicing/invoices/${invoiceId}/payments/${transactionId}`,
{}
);

@@ -177,9 +138,5 @@ return response.status === 204 ? true : false;

async deleteExternalRefund(invoiceId, transactionId) {
const response = await this.PayPal.Axios.delete(
`https://api.paypal.com/v2/invoicing/invoices/${invoiceId}/refunds/${transactionId}`,
{
headers: {
"Content-Type": "application/json",
},
}
const response = await this.PayPal.delete(
`/v2/invoicing/invoices/${invoiceId}/refunds/${transactionId}`,
{}
);

@@ -195,8 +152,5 @@ return response.status === 204;

async sendReminder(id, query) {
const response = await this.PayPal.Axios.post(
`https://api.paypal.com/v2/invoicing/invoices/${id}/remind`,
const response = await this.PayPal.post(
`/v2/invoicing/invoices/${id}/remind`,
{
headers: {
"Content-Type": "application/json",
},
data: query,

@@ -209,8 +163,5 @@ }

async send(id, query) {
const response = await this.PayPal.Axios.post(
`https://api.paypal.com/v2/invoicing/invoices/${id}/send`,
const response = await this.PayPal.post(
`/v2/invoicing/invoices/${id}/send`,
{
headers: {
"Content-Type": "application/json",
},
data: query,

@@ -223,18 +174,12 @@ }

async find(query) {
const response = await this.PayPal.Axios.post(
"https://api.paypal.com/v2/invoicing/search-invoices",
{
headers: {
"Content-Type": "application/json",
},
params: {
page: query.page,
page_size: query.pageSize,
total_required: query.totalRequired,
},
data: Object.keys(query)
.filter((x) => !["page", "pageSize", "totalRequired"].includes(x))
.reduce((a, b) => Object.assign(a, { b: query[b] }), {}),
}
);
const response = await this.PayPal.post("/v2/invoicing/search-invoices", {
params: {
page: query.page,
page_size: query.pageSize,
total_required: query.totalRequired,
},
data: Object.keys(query)
.filter((x) => !["page", "pageSize", "totalRequired"].includes(x))
.reduce((a, b) => Object.assign(a, { b: query[b] }), {}),
});
return response.data;

@@ -241,0 +186,0 @@ }

@@ -13,7 +13,9 @@ const Events = require("events");

this.clientSecret = null;
this.sandbox = false;
}
configure(id, secret) {
configure(id, secret, sandbox = false) {
this.clientId = id;
this.clientSecret = secret;
this.sandbox = sandbox;

@@ -20,0 +22,0 @@ this.eventHandler = new Events.EventEmitter();

@@ -119,3 +119,4 @@ const BasePayPal = require("./BasePayPal");

this.clientId,
this.clientSecret
this.clientSecret,
this.sandbox
);

@@ -122,0 +123,0 @@ } catch (e) {

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