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

paypal-nvp-api

Package Overview
Dependencies
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paypal-nvp-api - npm Package Compare versions

Comparing version 1.2.27 to 1.2.28

reset.js

11

package.json
{
"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

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