xendit-node
Advanced tools
Comparing version 1.21.9 to 1.21.10
@@ -19,2 +19,3 @@ console.log('Starting Integration Test...'); // eslint-disable-line no-console | ||
require('./transaction.test')(), | ||
require('./payment_request.test')(), | ||
require('./payment_method_v2.test'), | ||
@@ -21,0 +22,0 @@ // require('./refund.test')() //test disabled until refunds endpoint is fixed |
{ | ||
"name": "xendit-node", | ||
"version": "1.21.9", | ||
"version": "1.21.10", | ||
"description": "NodeJS client for Xendit API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,8 @@ | ||
const { promWithJsErr, Validate, fetchWithHTTPErr, Auth, queryStringWithoutUndefined } = require('../utils'); | ||
const { | ||
promWithJsErr, | ||
Validate, | ||
fetchWithHTTPErr, | ||
Auth, | ||
queryStringWithoutUndefined, | ||
} = require('../utils'); | ||
@@ -6,284 +12,281 @@ const PAYMENT_METHOD_V2_PATH = '/v2/payment_methods'; | ||
function PaymentMethodV2(options) { | ||
let aggOpts = options; | ||
if ( | ||
PaymentMethodV2._injectedOpts && | ||
Object.keys(PaymentMethodV2._injectedOpts).length > 0 | ||
) { | ||
aggOpts = Object.assign({}, options, PaymentMethodV2._injectedOpts); | ||
} | ||
let aggOpts = options; | ||
if ( | ||
PaymentMethodV2._injectedOpts && | ||
Object.keys(PaymentMethodV2._injectedOpts).length > 0 | ||
) { | ||
aggOpts = Object.assign({}, options, PaymentMethodV2._injectedOpts); | ||
} | ||
this.opts = aggOpts; | ||
this.API_ENDPOINT = this.opts.xenditURL + PAYMENT_METHOD_V2_PATH; | ||
this.opts = aggOpts; | ||
this.API_ENDPOINT = this.opts.xenditURL + PAYMENT_METHOD_V2_PATH; | ||
} | ||
PaymentMethodV2._injectedOpts = {}; | ||
PaymentMethodV2._constructorWithInjectedXenditOpts = function (options) { | ||
PaymentMethodV2._injectedOpts = options; | ||
return PaymentMethodV2; | ||
PaymentMethodV2._constructorWithInjectedXenditOpts = function(options) { | ||
PaymentMethodV2._injectedOpts = options; | ||
return PaymentMethodV2; | ||
}; | ||
PaymentMethodV2.prototype.createPaymentMethodV2 = function (data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields( | ||
['type', 'reusability'], | ||
data, | ||
reject, | ||
); | ||
PaymentMethodV2.prototype.createPaymentMethodV2 = function(data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields(['type', 'reusability'], data, reject); | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.for_user_id; | ||
} | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.for_user_id; | ||
} | ||
if (data && data.idempotency_key) { | ||
headers['idempotency-key'] = data.idempotency_key; | ||
} | ||
if (data && data.idempotency_key) { | ||
headers['idempotency-key'] = data.idempotency_key; | ||
} | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}`, { | ||
method: 'POST', | ||
headers, | ||
body: JSON.stringify({ | ||
type: data.type, | ||
reusability: data.reusability, | ||
reference_id: data.reference_id, | ||
customer_id: data.customer_id, | ||
country: data.country, | ||
description: data.description, | ||
billing_information: data.billing_information, | ||
metadata: data.metadata, | ||
ewallet: data.ewallet, | ||
direct_debit: data.direct_debit, | ||
card: data.card, | ||
over_the_counter: data.over_the_counter, | ||
virtual_account: data.virtual_account, | ||
qr_code: data.qr_code | ||
}), | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}`, { | ||
method: 'POST', | ||
headers, | ||
body: JSON.stringify({ | ||
type: data.type, | ||
reusability: data.reusability, | ||
reference_id: data.reference_id, | ||
customer_id: data.customer_id, | ||
country: data.country, | ||
description: data.description, | ||
billing_information: data.billing_information, | ||
metadata: data.metadata, | ||
ewallet: data.ewallet, | ||
direct_debit: data.direct_debit, | ||
card: data.card, | ||
over_the_counter: data.over_the_counter, | ||
virtual_account: data.virtual_account, | ||
qr_code: data.qr_code, | ||
}), | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
}; | ||
PaymentMethodV2.prototype.listPaymentMethodV2 = function (data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields([], data, reject); | ||
PaymentMethodV2.prototype.listPaymentMethodV2 = function(data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields([], data, reject); | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.for_user_id; | ||
} | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.for_user_id; | ||
} | ||
const queryStr = data | ||
? queryStringWithoutUndefined({ | ||
id: data.id ? data.id : undefined, | ||
type: data.type ? data.type : undefined, | ||
reusability: data.reusability ? data.reusability : undefined, | ||
reference_id: data.reference_id ? data.reference_id : undefined, | ||
customer_id: data.customer_id ? data.customer_id : undefined, | ||
limit: data.limit ? data.limit : undefined, | ||
after_id: data.after_id ? data.after_id : undefined, | ||
before_id: data.before_id ? data.before_id : undefined | ||
}) | ||
: ''; | ||
const queryStr = data | ||
? queryStringWithoutUndefined({ | ||
id: data.id ? data.id : undefined, | ||
type: data.type ? data.type : undefined, | ||
reusability: data.reusability ? data.reusability : undefined, | ||
reference_id: data.reference_id ? data.reference_id : undefined, | ||
customer_id: data.customer_id ? data.customer_id : undefined, | ||
limit: data.limit ? data.limit : undefined, | ||
after_id: data.after_id ? data.after_id : undefined, | ||
before_id: data.before_id ? data.before_id : undefined, | ||
}) | ||
: ''; | ||
const queryStrWithQuestionMark = queryStr ? `?${queryStr}` : ''; | ||
const queryStrWithQuestionMark = queryStr ? `?${queryStr}` : ''; | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}${queryStrWithQuestionMark}`, { | ||
method: 'GET', | ||
headers, | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}${queryStrWithQuestionMark}`, { | ||
method: 'GET', | ||
headers, | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
}; | ||
PaymentMethodV2.prototype.authorizePaymentMethodV2 = function (data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields(['id'], data, reject); | ||
PaymentMethodV2.prototype.authorizePaymentMethodV2 = function(data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields(['id'], data, reject); | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.forUserID; | ||
} | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.forUserID; | ||
} | ||
if (data && data.idempotency_key) { | ||
headers['idempotency-key'] = data.idempotency_key; | ||
} | ||
if (data && data.idempotency_key) { | ||
headers['idempotency-key'] = data.idempotency_key; | ||
} | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/${data.id}/auth`, { | ||
method: 'POST', | ||
headers, | ||
body: JSON.stringify({ | ||
auth_code: data.auth_code | ||
}), | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/${data.id}/auth`, { | ||
method: 'POST', | ||
headers, | ||
body: JSON.stringify({ | ||
auth_code: data.auth_code, | ||
}), | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
}; | ||
PaymentMethodV2.prototype.getPaymentMethodByIdV2 = function (data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields(['id'], data, reject); | ||
PaymentMethodV2.prototype.getPaymentMethodByIdV2 = function(data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields(['id'], data, reject); | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.forUserID; | ||
} | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.forUserID; | ||
} | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/${data.id}`, { | ||
method: 'GET', | ||
headers | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/${data.id}`, { | ||
method: 'GET', | ||
headers, | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
}; | ||
PaymentMethodV2.prototype.updatePaymentMethodV2 = function (data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields(['id'], data, reject); | ||
PaymentMethodV2.prototype.updatePaymentMethodV2 = function(data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields(['id'], data, reject); | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.forUserID; | ||
} | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.forUserID; | ||
} | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/${data.id}`, { | ||
method: 'PATCH', | ||
headers, | ||
body: JSON.stringify({ | ||
reference_id: data.reference_id, | ||
description: data.description, | ||
metadata: data.metadata, | ||
status: data.status, | ||
reusability: data.reusability, | ||
over_the_counter: data.over_the_counter, | ||
virtual_account: data.virtual_account | ||
}), | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/${data.id}`, { | ||
method: 'PATCH', | ||
headers, | ||
body: JSON.stringify({ | ||
reference_id: data.reference_id, | ||
description: data.description, | ||
metadata: data.metadata, | ||
status: data.status, | ||
reusability: data.reusability, | ||
over_the_counter: data.over_the_counter, | ||
virtual_account: data.virtual_account, | ||
}), | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
}; | ||
PaymentMethodV2.prototype.expirePaymentMethodV2 = function (data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields(['id'], data, reject); | ||
PaymentMethodV2.prototype.expirePaymentMethodV2 = function(data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields(['id'], data, reject); | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.forUserID; | ||
} | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.forUserID; | ||
} | ||
if (data && data.idempotency_key) { | ||
headers['idempotency-key'] = data.idempotency_key; | ||
} | ||
if (data && data.idempotency_key) { | ||
headers['idempotency-key'] = data.idempotency_key; | ||
} | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/${data.id}/expire`, { | ||
method: 'POST', | ||
headers, | ||
body: JSON.stringify({ | ||
auth_code: data.auth_code | ||
}), | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/${data.id}/expire`, { | ||
method: 'POST', | ||
headers, | ||
body: JSON.stringify({ | ||
auth_code: data.auth_code, | ||
}), | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
}; | ||
PaymentMethodV2.prototype.expirePaymentMethodV2 = function (data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields(['id'], data, reject); | ||
PaymentMethodV2.prototype.expirePaymentMethodV2 = function(data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields(['id'], data, reject); | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.forUserID; | ||
} | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.forUserID; | ||
} | ||
if (data && data.idempotency_key) { | ||
headers['idempotency-key'] = data.idempotency_key; | ||
} | ||
if (data && data.idempotency_key) { | ||
headers['idempotency-key'] = data.idempotency_key; | ||
} | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/${data.id}/expire`, { | ||
method: 'POST', | ||
headers, | ||
body: JSON.stringify({ | ||
auth_code: data.auth_code | ||
}), | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/${data.id}/expire`, { | ||
method: 'POST', | ||
headers, | ||
body: JSON.stringify({ | ||
auth_code: data.auth_code, | ||
}), | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
}; | ||
PaymentMethodV2.prototype.listPaymentsByPaymentMethodIdV2 = function (data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields([], data, reject); | ||
PaymentMethodV2.prototype.listPaymentsByPaymentMethodIdV2 = function(data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields([], data, reject); | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
let headers = { | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
'Content-Type': 'application/json', | ||
}; | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.for_user_id; | ||
} | ||
if (data && data.for_user_id) { | ||
headers['for-user-id'] = data.for_user_id; | ||
} | ||
const queryStr = data | ||
? queryStringWithoutUndefined({ | ||
payment_request_id: data.payment_request_id ? data.payment_request_id : undefined, | ||
reference_id: data.reference_id ? data.reference_id : undefined, | ||
status: data.status ? data.status :undefined, | ||
limit: data.limit ? data.limit : undefined, | ||
after_id: data.after_id ? data.after_id : undefined, | ||
before_id: data.before_id ? data.before_id : undefined, | ||
created: data.created ? data.created : undefined, | ||
updated: data.updated ? data.updated : undefined | ||
}) | ||
: ''; | ||
const queryStr = data | ||
? queryStringWithoutUndefined({ | ||
payment_request_id: data.payment_request_id | ||
? data.payment_request_id | ||
: undefined, | ||
reference_id: data.reference_id ? data.reference_id : undefined, | ||
status: data.status ? data.status : undefined, | ||
limit: data.limit ? data.limit : undefined, | ||
after_id: data.after_id ? data.after_id : undefined, | ||
before_id: data.before_id ? data.before_id : undefined, | ||
created: data.created ? data.created : undefined, | ||
updated: data.updated ? data.updated : undefined, | ||
}) | ||
: ''; | ||
const queryStrWithQuestionMark = queryStr ? `?${queryStr}` : ''; | ||
const queryStrWithQuestionMark = queryStr ? `?${queryStr}` : ''; | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/${data.id}/payments${queryStrWithQuestionMark}`, { | ||
method: 'GET', | ||
headers, | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
fetchWithHTTPErr( | ||
`${this.API_ENDPOINT}/${data.id}/payments${queryStrWithQuestionMark}`, | ||
{ | ||
method: 'GET', | ||
headers, | ||
}, | ||
) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
}; | ||
module.exports = PaymentMethodV2; |
@@ -19,2 +19,3 @@ import Errors from './errors'; | ||
import { TransactionService } from './transaction'; | ||
import { PaymentRequestService } from './payment_request'; | ||
import { PaymentMethodV2Service } from './payment_method_v2'; | ||
@@ -43,2 +44,3 @@ import { RefundService } from './refund'; | ||
Transaction: typeof TransactionService; | ||
PaymentRequest: typeof PaymentRequestService; | ||
PaymentMethodV2: typeof PaymentMethodV2Service; | ||
@@ -45,0 +47,0 @@ Refund: typeof RefundService; |
@@ -18,2 +18,3 @@ const { CardService } = require('./card'); | ||
const { TransactionService } = require('./transaction'); | ||
const { PaymentRequestService } = require('./payment_request'); | ||
const { PaymentMethodV2Service } = require('./payment_method_v2'); | ||
@@ -49,2 +50,5 @@ const { RefundService } = require('./refund'); | ||
); | ||
this.PaymentRequest = PaymentRequestService._constructorWithInjectedXenditOpts( | ||
this.opts, | ||
); | ||
this.PaymentMethodV2 = PaymentMethodV2Service._constructorWithInjectedXenditOpts( | ||
@@ -51,0 +55,0 @@ this.opts, |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
282801
212
8002
1