From 06a7b2adcc840a0f10adc49fa2d5f4bcfdf69623 Mon Sep 17 00:00:00 2001 From: Avi Das Date: Tue, 3 Mar 2015 09:08:47 -0600 Subject: [PATCH 1/6] credit kobalicek --- lib/utils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index 3ff61694..4a0a2d26 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -39,7 +39,9 @@ function clone(v) { /** * Merges two Objects recursively, setting property of obj1 to those of obj2 - * and creating property as necessary + * and creating property as necessary. + * + * Implementation suggested by @kobalicek on https://github.com/paypal/PayPal-node-SDK/issues/69 * @param {Object} obj1 * @param {Object} obj2 * @return {Object} From fe7d5ea875011771e821f09b92b9565a5048572c Mon Sep 17 00:00:00 2001 From: Avi Das Date: Tue, 3 Mar 2015 09:14:12 -0600 Subject: [PATCH 2/6] Error message typo --- lib/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index 4a0a2d26..71305367 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -54,7 +54,7 @@ var merge = exports.merge = function merge(obj1, obj2) { } if (obj2 === null || typeof obj2 !== "object") { - throw new TypeError("merge() - first parameter has to be an object, not " + typeof obj1 + "."); + throw new TypeError("merge() - first parameter has to be an object, not " + typeof obj2 + "."); } if (isArray(obj1) || isArray(obj2)) { From 95943506fbed3f1623058ce18591f410f79e1bc7 Mon Sep 17 00:00:00 2001 From: Avi Das Date: Thu, 5 Mar 2015 10:16:54 -0600 Subject: [PATCH 3/6] Link to github pages on README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f92010a6..e7ee8e7c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ NPM status: [![NPM version](https://badge.fury.io/js/paypal-rest-sdk.png)](http://badge.fury.io/js/paypal-rest-sdk) [![Dependency Status](https://david-dm.org/paypal/PayPal-node-SDK.png)](https://david-dm.org/paypal/PayPal-node-SDK) -Repository for PayPal's Node SDK (node.js version >=0.6.x) and Node samples for REST API. Refer [Node.js Sample Reference App ](https://github.com/paypal/rest-api-sample-app-nodejs) for a sample web app implementing the REST APIs. +Repository for PayPal's Node SDK (node.js version >=0.6.x) and Node samples for REST API. For a full working app and documentation, have a look at the [PayPal Node SDK Page](http://paypal.github.io/PayPal-node-SDK/). > **v1.0.0 notice**: If upgrading from paypal rest sdk 0.*, Please view Breaking Changes in release_notes.md From b7fdacb61b7fdc97cf5a1847b0e834a006289b2c Mon Sep 17 00:00:00 2001 From: Avi Das Date: Fri, 13 Mar 2015 21:35:05 -0500 Subject: [PATCH 4/6] Add paypal debug id name to debug level logging, and update readme instructions --- README.md | 6 ++++++ lib/client.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e7ee8e7c..1c55b386 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,12 @@ Repository for PayPal's Node SDK (node.js version >=0.6.x) and Node samples for > **Before starting to use the sdk, please be aware of the [existing issues and currently unavailable or upcoming features](https://github.com/paypal/PayPal-Python-SDK/wiki/Existing-Issues-and-Unavailable%5CUpcoming-features) for the REST APIs. (which the sdks are based on)** +## Installation + +```sh +npm install paypal-rest-sdk +``` + ## Usage To write an app using the SDK diff --git a/lib/client.js b/lib/client.js index 70372130..6f904b54 100644 --- a/lib/client.js +++ b/lib/client.js @@ -98,7 +98,7 @@ var invoke = exports.invoke = function invoke(http_method, path, data, http_opti //for questions to merchant technical services. Similar convention //to express.js if (res.headers['paypal-debug-id'] !== undefined && process.env.NODE_ENV === 'development') { - console.log(res.headers['paypal-debug-id']); + console.log('paypal-debug-id: ' + res.headers['paypal-debug-id']); } } catch (e) { err = new Error('Invalid JSON Response Received'); From f3484112da88e0456b30967e9232122a00056691 Mon Sep 17 00:00:00 2001 From: "Ralf S. Engelschall" Date: Sun, 15 Mar 2015 20:28:45 +0100 Subject: [PATCH 5/6] fix API methods like PayPal.openIdConnect.userinfo.get() where PayPal returns an HTTP 'Content-Type' header with the value 'application/json;charset=UTF-8' instead of just 'application/json' --- lib/client.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index 6f904b54..2129e724 100644 --- a/lib/client.js +++ b/lib/client.js @@ -85,7 +85,8 @@ var invoke = exports.invoke = function invoke(http_method, path, data, http_opti //Set response to be parsed JSON object if data received is json //expect that content-type header has application/json when it //returns data - if (res.headers['content-type'] === "application/json") { + if (typeof res.headers['content-type'] === "string" && + res.headers['content-type'].match(/^application\/json(?:;.*)?$/) !== null) { response = JSON.parse(response); } //Set response to an empty object if no data was received From bbd0672a807109aed797cef51e63322c787f6adf Mon Sep 17 00:00:00 2001 From: Avi Das Date: Fri, 27 Mar 2015 14:13:08 -0500 Subject: [PATCH 6/6] Update for 1.5.2 release and NODE_ENV development provides strinfigied response --- README.md | 4 ++-- lib/client.js | 3 +++ package.json | 2 +- release_notes.md | 6 ++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1c55b386..ea2a6b3e 100644 --- a/README.md +++ b/README.md @@ -135,8 +135,8 @@ grunt test (timeout is specified in milliseconds eg: 15000ms) ## Debugging - * It is recommended to provide Paypal-Debug-Id if requesting PayPal Merchant Technical Services for support. You can get access to the debug id by setting environment variable NODE_ENV=development - * The error object returned for any bad request has error.response populated with [details](https://developer.paypal.com/webapps/developer/docs/api/#errors) + * It is recommended to provide Paypal-Debug-Id if requesting PayPal Merchant Technical Services for support. You can get access to the debug id by setting environment variable NODE_ENV=development. + * The error object returned for any bad request has error.response populated with [details](https://developer.paypal.com/webapps/developer/docs/api/#errors). NODE_ENV=development setting also gives you access to stringfied response in error messages. ## Reference [REST API Reference] (https://developer.paypal.com/webapps/developer/docs/api/) diff --git a/lib/client.js b/lib/client.js index 2129e724..491b1465 100644 --- a/lib/client.js +++ b/lib/client.js @@ -116,6 +116,9 @@ var invoke = exports.invoke = function invoke(http_method, path, data, http_opti if (!err && (res.statusCode < 200 || res.statusCode >= 300)) { err = new Error('Response Status : ' + res.statusCode); err.response = response; + if (process.env.NODE_ENV === 'development') { + err.response_stringified = JSON.stringify(response); + } err.httpStatusCode = res.statusCode; response = null; } diff --git a/package.json b/package.json index 4a51c3b3..85460584 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "PayPal (https://developer.paypal.com/)", "name": "paypal-rest-sdk", "description": "SDK for PayPal REST APIs", - "version": "1.5.1", + "version": "1.5.2", "homepage": "https://github.com/paypal/PayPal-node-SDK", "keywords": [ "paypal", diff --git a/release_notes.md b/release_notes.md index 599a6f24..3db51748 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,6 +1,12 @@ PayPal Node SDK release notes ============================ +v1.5.2 +---- +* Content-Type Header parsing fix +* Merge updated +* NODE_ENV=development provides stringified response + v1.5.1 ---- * utils.merge patch for empty header, fixes #69 and #70