paypal-nvp-api
Advanced tools
Comparing version 1.2.27 to 1.2.28
{ | ||
"version": "1.2.27", | ||
"version": "1.2.28", | ||
"name": "paypal-nvp-api", | ||
@@ -23,7 +23,8 @@ "description": "Node.js wrapper for the Paypal Name-Value Pair — NVP ", | ||
"posttest": "npm run report", | ||
"coveralls": "npm test && cat ./coverage/lcov.info | coveralls" | ||
"coveralls": "npm test && cat ./coverage/lcov.info | coveralls", | ||
"reset": "node reset" | ||
}, | ||
"dependencies": { | ||
"bellajs": "6.x.x", | ||
"promise.prototype.finally": "2.x.x", | ||
"bellajs": "7.x.x", | ||
"promise-wtf": "1.x.x", | ||
"request": "2.x.x" | ||
@@ -37,3 +38,3 @@ }, | ||
"nsp": "2.x.x", | ||
"nyc": "10.x.x", | ||
"nyc": "11.x.x", | ||
"tap-spec": "4.x.x", | ||
@@ -40,0 +41,0 @@ "tape": "4.x.x" |
@@ -8,6 +8,6 @@ # paypal-nvp-api | ||
[![Dependency Status](https://gemnasium.com/badges/github.com/ndaidong/paypal-nvp-api.svg)](https://gemnasium.com/github.com/ndaidong/paypal-nvp-api) | ||
[![Known Vulnerabilities](https://snyk.io/test/npm/paypal-nvp-api/badge.svg)](https://snyk.io/test/npm/paypal-nvp-api) | ||
[![NSP Status](https://nodesecurity.io/orgs/techpush/projects/b6471f27-370b-4f79-badd-75cd5401d826/badge)](https://nodesecurity.io/orgs/techpush/projects/b6471f27-370b-4f79-badd-75cd5401d826) | ||
# Usage | ||
### Usage | ||
@@ -86,3 +86,3 @@ Import module and init an instance with given config: | ||
# API reference | ||
### APIs | ||
@@ -116,3 +116,3 @@ ### request(String method, Object query) | ||
# Test | ||
### Test | ||
@@ -127,4 +127,4 @@ ``` | ||
# License | ||
## License | ||
The MIT License (MIT) |
@@ -13,6 +13,9 @@ /** | ||
var promiseFinally = require('promise.prototype.finally'); | ||
promiseFinally.shim(); | ||
global.Promise = require('promise-wtf'); | ||
var bella = require('bellajs'); | ||
var { | ||
isObject, | ||
copies | ||
} = require('bellajs'); | ||
var request = require('request'); | ||
@@ -45,7 +48,12 @@ | ||
let sendRequest = (method, params) => { | ||
let pr = params || {}; | ||
let o = bella.copies(payload, pr); | ||
o.METHOD = method; | ||
let sendRequest = (method, params = {}) => { | ||
return new Promise((resolve, reject) => { | ||
if (!isObject(params)) { | ||
return reject(new Error('Params must be an object')); | ||
} | ||
let o = copies(payload, params); | ||
o.METHOD = method; | ||
return request.post({ | ||
@@ -59,3 +67,3 @@ url: baseURL, | ||
}, | ||
body: stringify(pr) | ||
body: stringify(params) | ||
}, (err, response, body) => { | ||
@@ -65,2 +73,8 @@ if (err) { | ||
} | ||
let { | ||
statusCode | ||
} = response; | ||
if (statusCode !== 200) { | ||
return reject(new Error(`Error: Response error with code: ${statusCode}`)); | ||
} | ||
let r = parse(body); | ||
@@ -67,0 +81,0 @@ return resolve(r); |
@@ -6,5 +6,10 @@ /** | ||
var bella = require('bellajs'); | ||
var test = require('tape'); | ||
var nock = require('nock'); | ||
var { | ||
isObject, | ||
hasProperty | ||
} = require('bellajs'); | ||
var config = require('../config'); | ||
@@ -16,3 +21,3 @@ | ||
var hasRequiredKey = (o, k) => { | ||
return bella.hasProperty(o, k); | ||
return hasProperty(o, k); | ||
}; | ||
@@ -32,3 +37,3 @@ | ||
paypal.request('GetBalance', {}).then((re) => { | ||
assert.ok(bella.isObject(re), 'Result should be an object'); | ||
assert.ok(isObject(re), 'Result should be an object'); | ||
props.forEach((k) => { | ||
@@ -65,3 +70,3 @@ assert.ok(hasRequiredKey(re, k), `Result must have the required property "${k}"`); | ||
paypal.request('SetExpressCheckout', query).then((re) => { | ||
assert.ok(bella.isObject(re), 'Result should be an object'); | ||
assert.ok(isObject(re), 'Result should be an object'); | ||
props.forEach((k) => { | ||
@@ -80,4 +85,4 @@ assert.ok(hasRequiredKey(re, k), `Result must have the required property "${k}"`); | ||
paypal.request('CallUnexistMethod', {}).then((re) => { | ||
assert.ok(bella.isObject(re), 'Result should be an object'); | ||
assert.equals(re.ACK, 'Failure', 'It must be an error'); | ||
assert.ok(isObject(re), 'Result should be an object'); | ||
assert.equals(re.ACK, 'Failure', `Response's properry "ACK" must be an error`); | ||
}).catch((e) => { | ||
@@ -93,4 +98,4 @@ console.log(e); | ||
paypal.request('GetBalance', 'noop').then((re) => { | ||
assert.ok(bella.isObject(re), 'Result should be an object'); | ||
assert.equals(re.ACK, 'Failure', 'It must be an error'); | ||
assert.ok(isObject(re), 'Result should be an object'); | ||
assert.equals(re.ACK, 'Failure', `Response's properry "ACK" must be an error`); | ||
}).catch((e) => { | ||
@@ -106,4 +111,4 @@ console.log(e); | ||
fakePaypal.request('GetBalance', {}).then((re) => { | ||
assert.ok(bella.isObject(re), 'Result should be an object'); | ||
assert.equals(re.ACK, 'Failure', 'It must be an error'); | ||
assert.ok(isObject(re), 'Result should be an object'); | ||
assert.equals(re.ACK, 'Failure', `Response's properry "ACK" must be an error`); | ||
}).catch((e) => { | ||
@@ -115,1 +120,18 @@ console.log(e); | ||
}); | ||
test('When Paypal returns error', (assert) => { | ||
nock('https://api-3t.sandbox.paypal.com') | ||
.log(console.log) | ||
.post('/nvp', 'USER=&PWD=&SIGNATURE=&VERSION=204&METHOD=xMethod') | ||
.reply(500, 'Server error'); | ||
let fakePaypal = nvp(); | ||
fakePaypal.request('xMethod', {}).then((re) => { | ||
console.log(re); | ||
}).catch((e) => { | ||
let msg = 'Error: Response error with code: 500'; | ||
assert.equals(e.message, msg, `It must throw: ${msg}`); | ||
return false; | ||
}).finally(assert.end); | ||
}); | ||
@@ -6,5 +6,8 @@ /** | ||
var bella = require('bellajs'); | ||
var test = require('tape'); | ||
var { | ||
isString | ||
} = require('bellajs'); | ||
var config = require('../config'); | ||
@@ -95,3 +98,3 @@ | ||
let result = paypal.formatCurrency(v); | ||
assert.deepEquals(result, item.result, ' / paypal.formatCurrency(' + (bella.isString(v) ? `'${v}'` : v) + ')'); | ||
assert.deepEquals(result, item.result, ' / paypal.formatCurrency(' + (isString(v) ? `'${v}'` : v) + ')'); | ||
}); | ||
@@ -98,0 +101,0 @@ |
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
20
431
15869
3
1
+ Addedpromise-wtf@1.x.x
+ Addedbellajs@7.5.0(transitive)
+ Addedpromise-wtf@1.2.11(transitive)
- Removedpromise.prototype.finally@2.x.x
- Removedarray-buffer-byte-length@1.0.2(transitive)
- Removedarraybuffer.prototype.slice@1.0.4(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedbellajs@6.4.51(transitive)
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removeddata-view-buffer@1.0.2(transitive)
- Removeddata-view-byte-length@1.0.2(transitive)
- Removeddata-view-byte-offset@1.0.1(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedes-abstract@1.23.9(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.1.1(transitive)
- Removedes-set-tostringtag@2.1.0(transitive)
- Removedes-to-primitive@1.3.0(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedfunction.prototype.name@1.1.8(transitive)
- Removedfunctions-have-names@1.2.3(transitive)
- Removedget-intrinsic@1.2.7(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedget-symbol-description@1.1.0(transitive)
- Removedglobalthis@1.0.4(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-bigints@1.1.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.2.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinternal-slot@1.1.0(transitive)
- Removedis-array-buffer@3.0.5(transitive)
- Removedis-async-function@2.1.0(transitive)
- Removedis-bigint@1.1.0(transitive)
- Removedis-boolean-object@1.2.1(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-data-view@1.0.2(transitive)
- Removedis-date-object@1.1.0(transitive)
- Removedis-finalizationregistry@1.1.1(transitive)
- Removedis-generator-function@1.1.0(transitive)
- Removedis-map@2.0.3(transitive)
- Removedis-number-object@1.1.1(transitive)
- Removedis-regex@1.2.1(transitive)
- Removedis-set@2.0.3(transitive)
- Removedis-shared-array-buffer@1.0.4(transitive)
- Removedis-string@1.1.1(transitive)
- Removedis-symbol@1.1.1(transitive)
- Removedis-typed-array@1.1.15(transitive)
- Removedis-weakmap@2.0.2(transitive)
- Removedis-weakref@1.1.0(transitive)
- Removedis-weakset@2.0.4(transitive)
- Removedisarray@2.0.5(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.assign@4.1.7(transitive)
- Removedown-keys@1.0.1(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedpromise.prototype.finally@2.0.1(transitive)
- Removedreflect.getprototypeof@1.0.10(transitive)
- Removedregexp.prototype.flags@1.5.4(transitive)
- Removedsafe-array-concat@1.1.3(transitive)
- Removedsafe-push-apply@1.0.0(transitive)
- Removedsafe-regex-test@1.1.0(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedset-function-name@2.0.2(transitive)
- Removedset-proto@1.0.0(transitive)
- Removedside-channel@1.1.0(transitive)
- Removedside-channel-list@1.0.0(transitive)
- Removedside-channel-map@1.0.1(transitive)
- Removedside-channel-weakmap@1.0.2(transitive)
- Removedstring.prototype.trim@1.2.10(transitive)
- Removedstring.prototype.trimend@1.0.9(transitive)
- Removedstring.prototype.trimstart@1.0.8(transitive)
- Removedtyped-array-buffer@1.0.3(transitive)
- Removedtyped-array-byte-length@1.0.3(transitive)
- Removedtyped-array-byte-offset@1.0.4(transitive)
- Removedtyped-array-length@1.0.7(transitive)
- Removedunbox-primitive@1.1.0(transitive)
- Removedwhich-boxed-primitive@1.1.1(transitive)
- Removedwhich-builtin-type@1.2.1(transitive)
- Removedwhich-collection@1.0.2(transitive)
- Removedwhich-typed-array@1.1.18(transitive)
Updatedbellajs@7.x.x