paypal-v2-sdk
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -6,3 +6,3 @@ { | ||
"name": "paypal-v2-sdk", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "Unofficial promise-based PayPal API v2 SDK for node.js", | ||
@@ -9,0 +9,0 @@ "main": "index.js", |
@@ -12,2 +12,7 @@ const PayPalClass = require("../../PayPal"); | ||
/** | ||
* | ||
* @param {String} id | ||
* @returns | ||
*/ | ||
async get(id) { | ||
@@ -42,2 +47,7 @@ const response = await this.PayPal.Axios.get( | ||
/** | ||
* | ||
* @param {Object|JSON} json | ||
* @returns | ||
*/ | ||
async create(json) { | ||
@@ -56,2 +66,7 @@ const response = await this.PayPal.Axios.post( | ||
/** | ||
* | ||
* @param {String} id | ||
* @returns | ||
*/ | ||
async delete(id) { | ||
@@ -68,4 +83,71 @@ const response = await this.PayPal.Axios.delete( | ||
} | ||
/** | ||
* | ||
* @param {String} id | ||
* @param {Object} query | ||
* @returns | ||
*/ | ||
async cancel(id, query) { | ||
const response = await this.PayPal.Axios.post( | ||
`https://api.paypal.com/v2/invoicing/invoices/${id}/cancel`, | ||
{ | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
data: query, | ||
} | ||
); | ||
return response.status === 204 ? true : false; | ||
} | ||
/** | ||
* | ||
* @param {String} id | ||
* @param {Object} query | ||
*/ | ||
async generateQrCode(id, query) { | ||
const response = await this.PayPal.Axios.post( | ||
`https://api.paypal.com/v2/invoicing/invoices/${id}/generate-qr-code`, | ||
{ | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
data: query, | ||
} | ||
); | ||
return response.data; | ||
} | ||
/** | ||
* | ||
* @param {String} id | ||
* @param {Object} query | ||
*/ | ||
async recordPayment(id, query) { | ||
const response = await this.PayPal.Axios.post( | ||
`https://api.paypal.com/v2/invoicing/invoices/${id}/payments`, | ||
{ | ||
headers: { | ||
"Content-Type": "application/json", | ||
data: query, | ||
}, | ||
} | ||
); | ||
return response.data; | ||
} | ||
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", | ||
}, | ||
} | ||
); | ||
return response.status === 204 ? true : false; | ||
} | ||
} | ||
module.exports = Invoices; |
@@ -35,2 +35,7 @@ const PayPalClass = require("../../PayPal"); | ||
const ListInvoicesResponse = require("../../Types/Responses/ListInvoices"); | ||
const CancelInvoiceQuery = require("../../Types/Queries/CancelInvoice"); | ||
const QrCodeQuery = require("../../Types/Queries/QRCode"); | ||
const RecordPaymentQuery = require("../../Types/Queries/RecordPayment"); | ||
const RecordPaymentResponse = require("../../Types/Responses/RecordPayment"); | ||
const DeleteExternalPaymentQuery = require("../../Types/Queries/DeleteExternalPayment"); | ||
@@ -538,5 +543,47 @@ class Invoices extends InvoicesAPI { | ||
// cancel a SENT invoice BY ID (can also cancel via invoice object) | ||
async cancel() {} | ||
/** | ||
* | ||
* @param {String} id | ||
* @param {CancelInvoiceQuery} body | ||
* @returns | ||
*/ | ||
async cancel(id, body) { | ||
const cancelled = await super.cancel(id, body.toAttributeObject()); | ||
return cancelled; | ||
} | ||
/** | ||
* | ||
* @param {String} id | ||
* @param {QrCodeQuery} body | ||
* @returns | ||
*/ | ||
async generateQrCode(id, body) { | ||
const qrCode = await super.generateQrCode(id, body.toAttributeObject()); | ||
return qrCode; | ||
} | ||
/** | ||
* | ||
* @param {String} id | ||
* @param {RecordPaymentQuery} body | ||
*/ | ||
async recordPayment(id, body) { | ||
const response = await super.recordPayment(id, body.toAttributeObject()); | ||
return new RecordPaymentResponse(this).setPaymentId(response.payment_id); | ||
} | ||
/** | ||
* | ||
* @param {DeleteExternalPaymentQuery} body | ||
*/ | ||
async deleteExternalPayment(body) { | ||
const response = await super.deleteExternalPayment( | ||
body.invoiceId, | ||
body.transactionId | ||
); | ||
return response; | ||
} | ||
} | ||
module.exports = Invoices; |
@@ -35,2 +35,6 @@ const BasePayPal = require("./BasePayPal"); | ||
const ListInvoicesResponse = require("./Types/Responses/ListInvoices"); | ||
const CancelInvoiceQuery = require("./Types/Queries/CancelInvoice"); | ||
const QrCodeQuery = require("./Types/Queries/QRCode"); | ||
const RecordPaymentQuery = require("./Types/Queries/RecordPayment"); | ||
const DeleteExternalPaymentQuery = require("./Types/Queries/DeleteExternalPayment"); | ||
@@ -88,6 +92,7 @@ // handlers | ||
ListInvoices: ListInvoicesQuery.bind(null, this), | ||
CancelInvoice: CancelInvoiceQuery.bind(null, this), | ||
QRCode: QrCodeQuery.bind(null, this), | ||
RecordPayment: RecordPaymentQuery.bind(null, this), | ||
DeleteExternalPayment: DeleteExternalPaymentQuery.bind(null, this), | ||
}, | ||
responses: { | ||
ListInvoices: ListInvoicesResponse.bind(null, this), | ||
}, | ||
}; | ||
@@ -94,0 +99,0 @@ } |
@@ -21,3 +21,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -24,0 +28,0 @@ } |
@@ -23,3 +23,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -26,0 +30,0 @@ } |
@@ -23,3 +23,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -26,0 +30,0 @@ } |
@@ -22,3 +22,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -25,0 +29,0 @@ } |
@@ -25,3 +25,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -28,0 +32,0 @@ } |
@@ -23,3 +23,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -26,0 +30,0 @@ } |
@@ -22,3 +22,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -25,0 +29,0 @@ } |
@@ -24,3 +24,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -27,0 +31,0 @@ } |
@@ -22,3 +22,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -25,0 +29,0 @@ } |
@@ -23,3 +23,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -26,0 +30,0 @@ } |
@@ -21,3 +21,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -24,0 +28,0 @@ } |
@@ -25,3 +25,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -28,0 +32,0 @@ } |
@@ -21,3 +21,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -24,0 +28,0 @@ } |
@@ -21,3 +21,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -24,0 +28,0 @@ } |
@@ -21,3 +21,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -24,0 +28,0 @@ } |
@@ -21,3 +21,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -24,0 +28,0 @@ } |
@@ -22,3 +22,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -25,0 +29,0 @@ } |
@@ -23,3 +23,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -26,0 +30,0 @@ } |
@@ -23,3 +23,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -26,0 +30,0 @@ } |
@@ -21,3 +21,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -24,0 +28,0 @@ } |
@@ -24,3 +24,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -27,0 +31,0 @@ } |
@@ -22,3 +22,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -25,0 +29,0 @@ } |
@@ -23,3 +23,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -26,0 +30,0 @@ } |
@@ -23,3 +23,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -26,0 +30,0 @@ } |
@@ -23,3 +23,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -26,0 +30,0 @@ } |
@@ -14,3 +14,6 @@ const PayPalClass = require("../../PayPal"); | ||
const InvoiceAPI = require("../../API/Invoices/Invoices"); | ||
const QrCodeQuery = require("../Queries/QRCode"); | ||
const RecordPaymentQuery = require("../Queries/RecordPayment"); | ||
const RecordPaymentResponse = require("../Responses/RecordPayment"); | ||
const DeleteExternalPaymentQuery = require("../Queries/DeleteExternalPayment"); | ||
@@ -39,4 +42,3 @@ class Invoice { | ||
const api = new InvoiceAPI(this.PayPal); | ||
const deleted = await api.delete(this.id); | ||
const deleted = await this.PayPal.invoices.invoices.delete(this.id); | ||
@@ -46,2 +48,45 @@ return deleted; | ||
async cancel() { | ||
const cancelled = await this.PayPal.invoices.invoices.cancel(this.id); | ||
return cancelled; | ||
} | ||
/** | ||
* | ||
* @param {QrCodeQuery} body | ||
* @returns {String} | ||
*/ | ||
async generateQrCode(body) { | ||
const qrCode = await this.PayPal.invoices.invoices.generateQrCode( | ||
this.id, | ||
body | ||
); | ||
return qrCode; | ||
} | ||
/** | ||
* | ||
* @param {RecordPaymentQuery} body | ||
* @returns {RecordPaymentResponse} | ||
*/ | ||
async recordPayment(body) { | ||
const response = await this.PayPal.invoices.invoices.recordPayment( | ||
this.id, | ||
body | ||
); | ||
return response; | ||
} | ||
/** | ||
* | ||
* @param {DeleteExternalPaymentQuery} body | ||
*/ | ||
async deleteExternalPayment(body) { | ||
const response = await this.PayPal.invoices.invoices.deleteExternalPayment( | ||
body | ||
); | ||
return response; | ||
} | ||
/* | ||
@@ -62,3 +107,7 @@ | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -65,0 +114,0 @@ } |
@@ -25,3 +25,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -28,0 +32,0 @@ } |
@@ -23,3 +23,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -26,0 +30,0 @@ } |
@@ -21,3 +21,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -24,0 +28,0 @@ } |
@@ -17,3 +17,7 @@ const PayPalClass = require("../../PayPal"); | ||
this[entry] instanceof Object | ||
? this[entry].toAttributeObject() | ||
? this[entry] instanceof Array | ||
? this[entry].map((x) => | ||
x instanceof Object ? x.toAttributeObject() : x | ||
) | ||
: this[entry].toAttributeObject() | ||
: this[entry]; | ||
@@ -20,0 +24,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101875
48
3522