Giter Site home page Giter Site logo

paypal-node-sdk's Introduction

Deprecation Notice:

This SDK is deprecated. You can continue to use it, but no new features or support requests will be accepted. For alternatives, please visit the current SDK homepage on the PayPal Developer Portal

PayPal REST SDK

Continuous integration status:

Build Status Coverage Status Gitter chat

NPM status:

NPM version Dependency Status

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.

2.0 Beta: We now have a 2.0 beta available, featuring promise support, and a revamped integration. Check out the 2.0-beta branch for details, or run npm install paypal-rest-sdk@beta.

v1.0.0 notice: If upgrading from paypal rest sdk 0.*, Please view Breaking Changes in release_notes.md

The Payment Card Industry (PCI) Council has mandated that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, PayPal is updating its services to require TLS 1.2 for all HTTPS connections. At this time, PayPal will also require HTTP/1.1 for all connections. See the PayPal TLS Update repository for more information.

**TLSv1_2 warning: Due to PCI compliance, merchant servers using a version of TLS that does not support TLSv1_2 will receive a warning.

**To verify that your server supports PCI compliant version of TLS, test against the PayPal sandbox environment which uses TLS 1.2.

Direct Credit Card Support

Important: The PayPal REST API no longer supports new direct credit card integrations. Please instead consider Braintree Direct; which is, PayPal's preferred integration solution for accepting direct credit card payments in your mobile app or website. Braintree, a PayPal service, is the easiest way to accept credit cards, PayPal, and many other payment methods.

PayPal Checkout v2

Please note that if you are integrating with PayPal Checkout, this SDK and corresponding API v1/payments are in the process of being deprecated.

We recommend that you integrate with API v2/checkout/orders and v2/payments. Please refer to the Checkout Node.js SDK to continue with the integration.

2.0 Release Candidate!

We're releasing a brand new version of our SDK! 2.0 is currently at release candidate status, and represents a full refactor, with the goal of making all of our APIs extremely easy to use. 2.0 includes all of the existing APIs (except payouts), and includes the new Orders API (disputes and Marketplace coming soon). Check out the FAQ and migration guide, and let us know if you have any suggestions or issues!

Installation

npm install paypal-rest-sdk

Usage

To write an app using the SDK

  • Register for a developer account and get your client_id and secret at PayPal Developer Portal.

  • Add dependency 'paypal-rest-sdk' in your package.json file.

  • Require 'paypal-rest-sdk' in your file

    var paypal = require('paypal-rest-sdk');
  • Create config options, with parameters (mode, client_id, secret).

    paypal.configure({
      'mode': 'sandbox', //sandbox or live
      'client_id': 'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM',
      'client_secret': 'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM'
    });
  • For multiple configuration support, have a look at the sample

  • Invoke the rest api (eg: create a PayPal payment) with required parameters (eg: data, config_options, callback).

    var create_payment_json = {
        "intent": "sale",
        "payer": {
            "payment_method": "paypal"
        },
        "redirect_urls": {
            "return_url": "http://return.url",
            "cancel_url": "http://cancel.url"
        },
        "transactions": [{
            "item_list": {
                "items": [{
                    "name": "item",
                    "sku": "item",
                    "price": "1.00",
                    "currency": "USD",
                    "quantity": 1
                }]
            },
            "amount": {
                "currency": "USD",
                "total": "1.00"
            },
            "description": "This is the payment description."
        }]
    };
    
    
    paypal.payment.create(create_payment_json, function (error, payment) {
        if (error) {
            throw error;
        } else {
            console.log("Create Payment Response");
            console.log(payment);
        }
    });
  • For creating Subscription Payments, check out the samples for creating planned sets of future recurring payments at periodic intervals.

  • To create Future Payments, check out this sample for executing future payments for a customer who has granted consent on a mobile device.

  • For exploring additional payment capabilites, such as handling discounts, insurance, soft_descriptor and invoice_number, have a look at this example. These bring REST payment functionality closer to parity with older Merchant APIs.

  • Customizing a PayPal payment experience is available as of version 1.1.0 enabling merchants to provide a customized experience to consumers from the merchant’s website to the PayPal payment. Get started with the supported rest methods and samples.

  • For creating and managing Orders, i.e. getting consent from buyer for a purchase but only placing the funds on hold when the merchant is ready to fulfill the order, have a look at samples.

  • For creating batch and single payouts, check out the samples for payouts and payout items. The Payouts feature enables you to make PayPal payments to multiple PayPal accounts in a single API call.

  • For Invoicing, check out the samples to see how you can use the node sdk to create, send and manage invoices.

  • To receive notifications from PayPal about Payment events on your server, webhook support is now available as of version 1.2.0. For creating and managing Webhook and Webhook Events, check out the samples to see how you can use the node sdk to manage webhooks, webhook events and verify that the response unaltered and is really from PayPal. Please follow the Webhook Validation sample to understand how to verify the authenticity of webhook messages. It is also important to note that simulated messages generated using the Webhook simulator would not be compatible with the verification process since they are only mock data.

  • To use OpenID Connect

    // OpenID configuration
    paypal.configure({
      'openid_client_id': 'CLIENT_ID',
      'openid_client_secret': 'CLIENT_SECRET',
      'openid_redirect_uri': 'http://example.com' });
    
    // Authorize url
    paypal.openIdConnect.authorizeUrl({'scope': 'openid profile'});
    
    // Get tokeninfo with Authorize code
    paypal.openIdConnect.tokeninfo.create("Replace with authorize code", function(error, tokeninfo){
      console.log(tokeninfo);
    });
    
    // Get tokeninfo with Refresh code
    paypal.openIdConnect.tokeninfo.refresh("Replace with refresh_token", function(error, tokeninfo){
      console.log(tokeninfo);
    });
    
    // Get userinfo with Access code
    paypal.openIdConnect.userinfo.get("Replace with access_code", function(error, userinfo){
      console.log(userinfo);
    });
    
    // Logout url
    paypal.openIdConnect.logoutUrl("Replace with tokeninfo.id_token");

Running Samples

Instructions for running samples are located in the sample directory.

Running Tests

To run the test suite first invoke the following command within the repo

If Grunt is not installed:

npm install -g grunt-cli

If Mocha is not installed:

npm install -g mocha

To install the development dependencies (run where the package.json is):

npm install

Run the tests:

grunt test (timeout is specified in milliseconds eg: 15000ms)

To run the tests without the mocks:

NOCK_OFF=true mocha -t 60000

Debugging

  • As of version 1.6.2, full request/response are logged for non production environments with PAYPAL_DEBUG set

    You can set the environment variable on the command line by running PAYPAL_DEBUG=1 node <path of script> or by executing export PAYPAL_DEBUG=1 and then running your Node.js script. Please see your command terminal/shell's manual pages for specific information.

  • 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 PAYPAL_DEBUG=1.

  • The error object returned for any bad request has error.response populated with details. PAYPAL_DEBUG=1 setting also gives you access to stringfied response in error messages.

Reference

[REST API Reference] (https://developer.paypal.com/webapps/developer/docs/api/)

Contribution

  • If you would like to contribute, please fork the repo and send in a pull request.
  • Please ensure you run grunt before sending in the pull request.

License

Code released under SDK LICENSE

Contributions

Pull requests and new issues are welcome. See CONTRIBUTING.md for details.

paypal-node-sdk's People

Contributors

avidas avatar bluk avatar braebot avatar braintreeps avatar bulkan avatar dasmall avatar dshaw avatar ganeshx avatar impanda-cookie avatar jaypatel512 avatar jcleblanc avatar jkingyens avatar krisbarrett avatar lathavairamani avatar lvairamani avatar neuralviva avatar night avatar ppmtscory avatar prannamalai avatar prayagverma avatar rse avatar sahat avatar sankarbhavanib avatar siddick avatar tkanta avatar xiaoleih41 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paypal-node-sdk's Issues

'MALFORMED_REQUEST' for update billing plans

I wanna active my billing plans via update, but it returned Malformed request, seems that someone in the Php got similar problem. it is related to the PATCH request wrong parameter:

http://stackoverflow.com/questions/25602097/paypal-rest-api-activate-billing-plan

My codes ---

 var options = [{
        "path": "/",
        "values": update_values,
        "op": "replace",
      }],
      billingPlanId = self.subscription.billingPlanId;
          paypal.billingPlan.update(billingPlanId, options, function (error, response) {
              if (error) {
                  console.log(error.response);
                  return next(null, error);
              } else if (response.httpStatusCode == 200) {
                  self.subscription.paypal_activated = true;
                  return next(response);
              } 
              return next(null, "Unexpected Error");
          });

I captured the data in lib/generate.js

update: function update(id, data, config, cb) {
console.log("config is ")
console.log(this.baseURL + id)     
console.log(config)      
console.log(data)      
        api.executeHttp('PATCH', this.baseURL + id, data, config, cb);
    },

The output is

config is
/v1/payments/billing-plans/P-1xxx569444D761401YBTP75JI
[Function]
[ { path: '/', values: { state: 'ACTIVE' }, op: 'replace' } ]
http_options is ----------
/v1/payments/billing-plans/P-1xxx69444D761401YBTP75JI
[ { path: '/', values: { state: 'ACTIVE' }, op: 'replace' } ]
{ mode: 'sandbox',
  schema: 'https',
  host: 'api.sandbox.paypal.com',
  port: '',
  openid_connect_schema: 'https',
  openid_connect_host: 'api.sandbox.paypal.com',
  openid_connect_port: '',
  authorize_url: 'https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize',
  logout_url: 'https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/endsession',
  headers: {},
  client_id: 'AYxDPRPEsuZSlhmMMlqD2KwQ9kzT3wwaRkHj3sFb_5vu537FvLEKrHaSdNRrQSIomxwD3byICMJiwonb',
  client_secret: 'EBIH0XQVQb3r1m5ZIigz9QYe565fTsnqSEVwYVy1C2dOvwA_wHfbavPhLkz7mxBC90eLXNT4fA-VFYa7' }

Error Got

{ name: 'MALFORMED_REQUEST',
  message: 'Incoming JSON request does not map to API request',
  information_link: 'https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST',
  debug_id: 'c4852d7ab0da5',
  httpStatusCode: 400 }
Error: Response Status : 400
    at IncomingMessage.<anonymous> (/myhome/node_modules/paypal-rest-sdk/lib/client.js:117:23)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

Long running paypal gives errors

Hello,

I am using the latest 1.5.1 release. But I am having trouble if our server process has been running for a while. The first request after having the application run for a day will always fail like this:

2015-03-26 11:06 +00:00: 2015-03-26T11:06:32.014Z - error:  Error: Invalid JSON Response Received
  at IncomingMessage.<anonymous> (/opt/prisma-cloud/releases/20150326083347/node_modules/paypal-rest-sdk/lib/client.js:104:23)
  at IncomingMessage.emit (events.js:129:20)
  at IncomingMessage.wrapped (/opt/prisma-cloud/releases/20150326083347/node_modules/newrelic/lib/transaction/tracer/index.js:156:28)
  at IncomingMessage.wrappedEmit [as emit] (/opt/prisma-cloud/releases/20150326083347/node_modules/newrelic/lib/transaction/tracer/index.js:188:46)
  at _stream_readable.js:908:16
  at wrapped (/opt/prisma-cloud/releases/20150326083347/node_modules/newrelic/lib/transaction/tracer/index.js:156:28)
  at _tickDomainCallback (node.js:381:11)
  at process.nextTickWrapper (/opt/prisma-cloud/releases/20150326083347/node_modules/newrelic/lib/instrumentation/core/timers.js:12:14)

The second request will work. Then again after a day for example it will fail again and work afterwards. This behaviour lets me think that maybe this is due to a 401 being received and the token being refreshed.

The paypal.payment.create request we are sending out has the following request:

{ intent: 'sale',
  payer: { payment_method: 'paypal' },
  redirect_urls:
   { return_url: 'http://komola.prismabox.de/viewer/2529/checkout/confirmation',
     cancel_url: 'http://komola.prismabox.de/viewer/2529/checkout/payment' },
  transactions:
   [ { description: 'Your photo order.',
       amount: { currency: 'EUR', total: '1.00' } } ] }

How can we trace this? Is there a way for me to disable a token to be able to test the behaviour? Waiting 24 hours between each test is not really something I would like to do..

create payment with credit card received Response Status : 500 INTERNAL_SERVICE_ERROR after changing to SGD in currency

Hello there,

ok I download this rest-api-sdk-nodejs package and I tested samples\payment\create_with_credit_card.js inside this package and it worked fine.

I changed currency to SGD and I also changed credit number to my real credit card number, real expire_month, real expire year, real cvv2, country_code to SG and I got the following exception:

{ [Error: Response Status : 500]
response:
{ name: 'INTERNAL_SERVICE_ERROR',
message: 'An internal service error has occurred',
information_link: 'https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR',
debug_id: 'fe17a1a286dfc' },
httpStatusCode: 500 }

Fyi, I am testing under sandbox and I have also added SGD under Manage Currencies (https://www.paypal.com/sg/cgi-bin/?cmd=_profile-currencies&fli=true).

Please kindly advise on this issue.

regards,
Mark

It is impossible to set up more than one pay-pal configuration

What I need is to use 2 pay-pal APPs (with different client_id/secret). It seems that there is no such option in PayPal-node-SDK because there is only global paypal.configure(...) method. Or maybe I am missing something? Is it possible to work with more than one pay-pal APP?

Support third party usage?

This library seems to assume that the client id and secret are only going to be used to act on behalf of the app creator. But if someone is building an app that serves "other" PayPal customers, they need slightly different flows even though most of the code is the same. Am I understanding the current code properly? If so, it would be nice to add some way to pass an access/refresh token and have the requests use them and also automatically refresh the token if the APIs return a failure indicating refresh is needed.

Unauthorized payment error when using the live API

Hello,
We have used this package to create our "pay by credit card" payment method we have completed testing with the sandbox and migrated it into dev, however upon using it in live - using live API credentials, it errors having an unauthorized payment:
screen shot 2014-09-17 at 3 56 32 pm

under account permissions, we saw that direct credit cards is not enabled.
screen shot 2014-09-17 at 4 11 38 pm

we have been following this guide:
https://developer.paypal.com/webapps/developer/docs/classic/lifecycle/goingLive/
to enable the live credit card payments

in one of the steps there is something about getting the live API credentials
Obtain your live API credentials as follows:

Log into the PayPal website with the account associated with your application or website.
Navigate to My Selling Tools by selecting My Account > Profile > My Selling Tools.
Click Selling Online > API Access > Update to display the API Access page.
Under Option 2, click View API Signature to view the Request API Credentials page. If you have existing credentials, they are displayed here.
To create new credentials, select Request API Signature and click Agree and Submit.

but it has a different format that of the one in the config on this package.

500 Internal Service Error on underscored subdomains

Problem:

I broke PayPal.

I process many requests using this API and noticed that I get an error every time there is an underscore in the subdomain or domain of the redirect_urls list.

Request:

 {
    intent: 'sale',
    payer: { payment_method: 'paypal' },
    redirect_urls: {
        return_url: 'https://es_es.website.com/account/upgrade/3?payment=paypal',
        cancel_url: 'https://es_es.website.com/account/upgrade' },
    transactions: [{
        amount: {
            currency: 'USD',
            total: 79
        },
        description: 'My Description'
    }]
}

Response:

{ [Error: Response Status : 500]
  response: 
   { name: 'INTERNAL_SERVICE_ERROR',
     message: 'An internal service error has occurred',
     information_link: 'https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR',
     debug_id: 'f930419484ab7' },
  httpStatusCode: 500 }

Review:

When I just do en.website.com or any hostname without an underscore, it works fine. The problem arises when there is an underscore in the hostname (ie. es_es.website.com).

Not sure if this is an SDK issue or something on PayPal's end.

authorize_url doesn't change

Problem

SDK Configuration:

paypal_sdk.configure({
    'mode'                  : config.paypal.sandbox ? 'sandbox' : 'live',
    'openid_client_id'      : config.paypal.clientId,
    'openid_client_secret'  : config.paypal.secret,
    'openid_redirect_uri'   : config.paypal.redirect_uri
});

If mode is sandbox or live the same auth URL is generated:

paypal_sdk.openid_connect.authorize_url({'scope': config.paypal.scopes});

Workaround

By default authorize_url has a value (lib/paypal-rest-sdk.js):

lin.22:

    var default_options = {
...
        'authorize_url': 'https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize',
...

lin. 315:

var url = config.authorize_url ||
            'https://www.' + get_default_endpoint(config.mode) + '/webapps/auth/protocol/openidconnect/v1/authorize' || default_options.authorize_url;

if the authorize_url is undefined, it works for both modes:

paypal_sdk.configure({
    'mode'                  : config.paypal.sandbox ? 'sandbox' : 'live',
    'openid_client_id'      : config.paypal.clientId,
    'openid_client_secret'  : config.paypal.secret,
    'openid_redirect_uri'   : config.paypal.redirect_uri,
    'authorize_url'         : undefined
});

Is this workaround the correct solution?
What am I doing wrong?

Pass Products details

Hi,
How can i pass the products details into the API, like the product name, quantity and the amount as we are passing the total amount.

Thanks

500 Error Response

I'm receiving the following error response when calling the credit card payment API:

{ [Error: Response Status : 500]
response:
{ name: 'INTERNAL_SERVICE_ERROR',
message: 'An internal service error has occurred',
information_link: 'https://developer.paypal.com/docs/api/#INTERNAL_SERVICE_ERROR',
debug_id: 'e69d5d0abab0a',
httpStatusCode: 500 },
httpStatusCode: 500 }

Here's my JSON request:

"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card":{"type":"visa","number":"4111111111111111","expire_month":"01","expire_year":"2014","cvv2":"111"}}]},"transactions":[{"amount":{"total":"1","currency":"USD"},"description":"Credits added to account."}]}

I'm not sure how to debug it...

Thanks,
Chris

[uncaught exception] TypeError: Cannot set property 'httpStatusCode' of null

Hi there,

The following exception

TypeError: Cannot set property 'httpStatusCode' of null
at IncomingMessage.module.exports.http_options.host (/home/node/srp/node_modules/paypal-rest-sdk/lib/paypal-rest-sdk.js:222:41)

is produced by this line of code:

https://github.com/paypal/rest-api-sdk-nodejs/blob/master/lib/paypal-rest-sdk.js#L222

I guess the assignment should be within the try catch or get it resolved otherway when there isn't well formatted json response from paypal servers the lib blows with uncaught exception

Required Scope Missing

When I tried creating a Payout, I couldn't really get it to work, I keep receiving the "Required Scope Missing" error. Couldn't find any answers, anyone tried using payout yet?

Node.js SDK - How to get user info?

The API has fabulous documentation. Not so much for the Node.js SDK. Par for the course... I find myself having to backwards engineer functionality by combing through the source code.

I'm trying to get user information (profile, email, etc).

Assume I've declared var paypal_sdk = require('paypal-rest-sdk').

I'm successfully using a "Log in with Paypal" button, getting the auth code in the return URL, and then getting the auth token via paypal_sdk.generateToken({authorization_code:code}). Is this the correct method?

How do I get the user information? Is it via paypal_sdk. openIdConnect.userinfo.get()? If so, how?

Update

So I tried paypal_sdk. openIdConnect.userinfo.get(auth_token,cb), and in my callback ("cb") I get the error object

{ [Error: Response Status : 404] response: { httpStatusCode: 404 }, httpStatusCode: 404 }

Update

https://api.paypal.com/v1/identity/openidconnect/userinfo returns a 404.

Error when the transaction array has more than one object.

I created a paypal payment object that has a the following details:

         {
            "intent": "sale",
            "payer": {
                "payment_method": "paypal"
            },
            "redirect_urls": {
                "return_url": "http://localhost:3000/api/paypal-execute",
                "cancel_url": "http://localhost:3000/payment"
            },
            "transactions": [{
                "amount": {
                    "currency": "USD",
                    "total": "30"
                },
                "description": "Play for Java: Covers Play 2"
            }, {
                "amount": {
                    "currency": "USD",
                    "total": "16.91"
                },
                "description": "JavaScript & jQuery: The Missing Manual"
            }]
        }

When I execute paypal.payment.create(payment, cb) function, it always gave me the Error: Response Status: 400:

{ [Error: Response Status : 400]
  response: 
   { name: 'VALIDATION_ERROR',
     details: [ [Object] ],
     message: 'Invalid request - see details',
     information_link: 'https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR',
     debug_id: 'f5f6552186df1',
     httpStatusCode: 400 },
  httpStatusCode: 400
 }

However, when I have only one object in my transaction array, it worked perfectly. I can't really figure it out why, I always got the error when I have two transaction objects. Any help would be appreciated.

Is it possible to retrieve history of completed payments via this API?

I have PayPal payment buttons on my site (part of PayPal's "Website Payments Standard" service). I can retrieve a history of completed payments by manually downloading a file from the PayPal website (My account > History > Download history).

What I do currently: I download a CSV file containing a history of completed payments from the PayPal site and then process the file locally and update the database on my web server accordingly.

What I would like to do: Retrieve this information (history of completed payments) using your API. I could set up a task on my web server which would make an API call to PayPal and get the information. Than I could process the information on the web server and update the database. This would be performed automatically, so I wouldn't have to manually download the data from the PayPal site. Is this possible with your API?

Shipping address is not returned via payment.get after authorization

Before a payment is executed but after a user has authorized the payment and returned to the original site, a request to Paypal fetching the payment details does not return the shipping address entered by the user at Paypal.

This limitation combined with the #28 makes no logical sense at all. Because I can't access the address the user entered on Paypal I have to get the user to enter their shipping address on our site and get them to enter their shipping address again on Paypal (which will not be used). This is confusing to the customer.

Web-hook API Issues

When retrieving a list of web-hook events, the resource links point to intranet URLs:

            "links": [{
                "href": "https://10.74.133.169:17881/v1/payments/sale/:transactionId",
                "rel": "self",
                "method": "GET"
            }, {
                "href": "https://10.74.133.169:17881/v1/payments/sale/:transactionId/refund",
                "rel": "refund",
                "method": "POST"
            }, {
                "href": "https://10.74.133.169:17881/v1/payments/payment/:payId",
                "rel": "parent_payment",
                "method": "GET"
            }],

Additionally, I have been unable to resend a web-hook event. I get the following error when I try:

exception

java.lang.RuntimeException: org.apache.cxf.interceptor.Fault
    org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:117)
    org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:331)
    org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
    org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
    org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:163)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
    com.paypal.foundation.service.rest.logging.StandardOuterTransactionCALFilter.doFilter(StandardOuterTransactionCALFilter.java:94)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    com.paypal.common.resource.filter.SecurityContextFilter.doFilter(SecurityContextFilter.java:75)

root cause

org.apache.cxf.interceptor.Fault
    org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162)
    org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:194)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:102)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
    org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
    org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
    org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
    org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:163)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
    com.paypal.foundation.service.rest.logging.StandardOuterTransactionCALFilter.doFilter(StandardOuterTransactionCALFilter.java:94)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    com.paypal.common.resource.filter.SecurityContextFilter.doFilter(SecurityContextFilter.java:75)

root cause

java.lang.ExceptionInInitializerError
    com.paypal.webhooks.bl.notification.NotificationFinderImpl.findEventByEventId(NotificationFinderImpl.java:43)
    com.paypal.webhooks.handler.WebhooksEventsHandler.handleResendNotification(WebhooksEventsHandler.java:177)
    com.paypal.webhooks.WebhooksEventsImpl.resendNotification(WebhooksEventsImpl.java:73)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
    org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:194)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:102)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
    org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
    org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
    org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
    org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:163)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
    com.paypal.foundation.service.rest.logging.StandardOuterTransactionCALFilter.doFilter(StandardOuterTransactionCALFilter.java:94)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    com.paypal.common.resource.filter.SecurityContextFilter.doFilter(SecurityContextFilter.java:75)

root cause

java.lang.IllegalArgumentException: encrypted_webhook_event_id_mac_key not specified in protected properties file
    com.paypal.foundation.security.crypto.AbstractIdEncryptor.getProtectedProperty(AbstractIdEncryptor.java:121)
    com.paypal.foundation.security.crypto.ObjectIdEncryptor.getEncryptor(ObjectIdEncryptor.java:37)
    com.paypal.foundation.security.crypto.AbstractIdEncryptor.initialize(AbstractIdEncryptor.java:95)
    com.paypal.webhooks.clients.util.WebhookEventIdCryptUtils.<init>(WebhookEventIdCryptUtils.java:32)
    com.paypal.webhooks.clients.util.WebhookEventIdCryptUtils.<clinit>(WebhookEventIdCryptUtils.java:20)
    com.paypal.webhooks.bl.notification.NotificationFinderImpl.findEventByEventId(NotificationFinderImpl.java:43)
    com.paypal.webhooks.handler.WebhooksEventsHandler.handleResendNotification(WebhooksEventsHandler.java:177)
    com.paypal.webhooks.WebhooksEventsImpl.resendNotification(WebhooksEventsImpl.java:73)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
    org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:194)
    org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:102)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
    org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
    org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
    org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
    org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
    org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
    org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:163)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
    com.paypal.foundation.service.rest.logging.StandardOuterTransactionCALFilter.doFilter(StandardOuterTransactionCALFilter.java:94)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    com.paypal.common.resource.filter.SecurityContextFilter.doFilter(SecurityContextFilter.java:75)

And lastly, eChecks appear to not send web-hook events upon completion (despite your documentation stating that they do). I have, however, gotten some web-hook events for non-eCheck payments.

From https://developer.paypal.com/docs/integration/direct/rest-webhooks-overview/

PAYMENT.SALE.COMPLETED: This event gets triggered when the sale is completed for eCheck.

No shipping option

The new rest api does not support a "no shipping" option.

This is a duplicate of issue #6. I've opened another issued since the previous one was closed and I believe this is a very important option to support.

`utils.merge` has a bug that is causing some other failures.

Guys, I spent today some time with a bug on your side that is happening in api.js, this code:

function updateToken(http_options, error_callback, callback) {
    generateToken(http_options, function (error, token) {
        if (error) {
            error_callback(error, token);
        } else {
            http_options.headers.Authorization = token;
            callback();
        }
    });
}

The problem is that http_option.headers is undefined so it throws TypeError. I tracked it down and the issue is most probably in your utils.merge function, that uses some weird approach to merge properties from one object to another, and it fails in certain cases.

I wrote a test program to verify your utils.merge, If you install paypal-rest-sdk locally, you should be able to reproduce it:

var utils = require("./node_modules/paypal-rest-sdk/lib/utils");

var obj1 = {
  "host": "api.sandbox.paypal.com",
  "port": "",
  "client_id": "SomeId",
  "client_secret": "SomeSecret"
};

var obj2 = {
  "mode": "sandbox",
  "schema": "https",
  "host": "api.sandbox.paypal.com",
  "port": "",
  "openid_connect_schema": "https",
  "openid_connect_host": "api.sandbox.paypal.com",
  "openid_connect_port": "",
  "authorize_url": "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize",
  "logout_url": "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/endsession",
  "headers": {}
};

console.log("OBJ1 = " + JSON.stringify(obj1, null, 2));
console.log("OBJ2 = " + JSON.stringify(obj2, null, 2));

var result = utils.merge(obj1, obj2);
console.log("RESULT = " + JSON.stringify(result, null, 2));

The console output is:

OBJ1 = {
  "host": "api.sandbox.paypal.com",
  "port": "",
  "client_id": "SomeId",
  "client_secret": "SomeSecret"
}
OBJ2 = {
  "mode": "sandbox",
  "schema": "https",
  "host": "api.sandbox.paypal.com",
  "port": "",
  "openid_connect_schema": "https",
  "openid_connect_host": "api.sandbox.paypal.com",
  "openid_connect_port": "",
  "authorize_url": "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize",
  "logout_url": "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/endsession",
  "headers": {}
}
RESULT = {
  "host": "api.sandbox.paypal.com",
  "port": "",
  "client_id": "SomeId",
  "client_secret": "SomeSecret",
  "mode": "sandbox",
  "schema": "https",
  "openid_connect_schema": "https",
  "openid_connect_host": "api.sandbox.paypal.com",
  "openid_connect_port": "",
  "authorize_url": "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize",
  "logout_url": "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/endsession"
}

The headers object is NOT in the result, but your code in api.js assumes it's there.

No-shipping for new API

Hi! Is there a way to disable the shipping address with the new API? Like NOSHIPPING with classic checkout?

Mode "live" does not work without host

When I set

mode: "live"

and leave out host, the calls fail with:

W20140512-22:39:03.352(2)? (STDERR) error: %j name=Invalid JSON Response Received, JSON Parse Error, response=, httpStatusCode=401

When I add this, it works fine:

host: "api.paypal.com"

Confirmation on inability to fetch transactions

After unsuccessfully trying to get any transaction data I saw the message in the PP REST API docs stating "This call returns only the sales that were created via the REST API.". I am unclear if this means that I cannot fetch any transaction data created from standard cart sales using the REST API? Or am I misunderstanding this.

Always error on payment

We are in sandbox mode and always receive this error

  1. Create payment.create with this response

{"id":"PAY-2LS37066M34178307KOPPU4I","create_time":"2014-06-16T14:08:49Z","update_time":"2014-06-16T14:08:50Z","state":"created","intent":"sale","payer":{"payment_method":"paypal","payer_info":{"shipping_address":{}}},"transactions":[{"amount":{"total":"1.00","currency":"USD","details":{"subtotal":"1.00"}},"description":"Filmtastic asset purchase"}],"links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-2LS37066M34178307KOPPU4I","rel":"self","method":"GET"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-2C0980734G849091D","rel":"approval_url","method":"REDIRECT"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-2LS37066M34178307KOPPU4I/execute","rel":"execute","method":"POST"}]}

  1. redirect to approval URL
  2. use test account to make payment

Result is always

{ [Error: Response Status : 401]
response:
{ error: 'invalid_client',
error_description: 'The client credentials are invalid' },
httpStatusCode: 401 }

What al I doing wrong here?

Create with paypal slow to redirect to paypal payment page

Not really sure if this is normal behaviour but I'm finding that there is quite a long delay before the customer is redirected to the paypal payment page. It's taking 3 seconds plus for this to happen.

It seems that the delay occurs every time the sdk is used i.e

paypal_sdk.payment.create()
paypal_sdk.payment.execute()

`payer` and `shipping_address` is missing from Billing Agreement object

Hi Paypal team,

Neither paypal.billingAgreement.create() nor paypal.billingAgreement.get() returns the payer or shipping_address information. We relay on these info to providing shipping for our subscribers.

Another missing property is id in the response of paypal.billingAgreement.create(). I have to merge the billing agreement object with the response of paypal.billingAgreement.execute() to obtain the ID.

Thanks,
Greg

INVALID_PAYER_ID

Hi,
I might need your help on this one.
On my web app users can subscribe to plans and I'd like to privide them a link where they can pay with their paypal account.
what are the steps to:

  • take them to log into paypal
  • process the payment
  • retrieve the transaction state
    I wrote tried the code below from the samples directory but it doesn't work since I don't know how to get the payer_id.
    Any help or sample code would be highly appreciated.

I'm using sailsjs

buy: function(req, res){
        paypal_api.configure({
            'mode': 'sandbox',
                'client_id': 'blablabla',
                'client_secret': 'blablabla'
        });
        var create_payment_json = {
          "intent": "authorize",
            "payer": {
                "payment_method": "paypal"
            },
            "redirect_urls": {
                "return_url": "http://return.url",
                "cancel_url": "http://cancel.url"
            },
            "transactions": [{
                "item_list": {
                    "items": [{
                        "name": "item",
                        "sku": "item",
                        "price": "1.00",
                        "currency": "EUR",
                        "quantity": 1
                    }]
                },
                "amount": {
                    "currency": "EUR",
                    "total": "1.00"
                },
                "description": "Awesome object"
            }]
        };
        paypal_api.payment.create(create_payment_json, function (error, payment) {
            if (error) {
                throw error;
            } else {
                console.log("-----Create Payment Response---->");
                console.log(payment);

                //res.send(payment);
                paypal_api.payment.execute(payment.id, {payer_id: '???'}, function (error, payment) {
                          if (error) {
                                console.log(error.response);
                                throw error;
                            } else {
                                console.log("Get Payment Response");
                                console.log(JSON.stringify(payment));
                                res.send(payment)
                            }
                        });
            }
        });

Return Configuration

Can we have a method to return the configuration information? I am setting client and secret when the application starts and need to get the information in my controller. Possible just check if options === undefined in configure() then return default_options?

how to send payment to other account ?

right now. i can send payment and the account that will receive tha payment is the account that handle/hold my data in the paypal configure(client_id, secret)..

i cant see any example/documentation that tell how to configure the receiver of the payment.

thanks

Multiple Transactions

Cannot do multiple transactions.

reference: http://runnable.com/UXgyne_v2oZyAAC-/pay-with-a-credit-card-using-paypal-api-for-node-js

Error I get:
http://runnable.com/Uxo38MrDTawo_X6M/output

Code:
/* Copyright 2013 PayPal */
"use strict";

var paypal_api = require('paypal-rest-sdk');

var config_opts = {
    'host': 'api.sandbox.paypal.com',
    'port': '',
    'client_id': 'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM',
    'client_secret': 'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM'
};

var create_payment_json = {
    "intent": "sale",
    "payer": {
        "payment_method": "credit_card",
        "funding_instruments": [{
            "credit_card": {
                "type": "visa",
                "number": "4417119669820331",
                "expire_month": "11",
                "expire_year": "2018",
                "cvv2": "874",
                "first_name": "Joe",
                "last_name": "Shopper",
                "billing_address": {
                    "line1": "52 N Main ST",
                    "city": "Johnstown",
                    "state": "OH",
                    "postal_code": "43210",
                    "country_code": "US"
                }
            }
        }]
    },
    "transactions": [{
        "amount": {
            "total": "7",
            "currency": "USD",
            "details": {
                "subtotal": "5",
                "tax": "1",
                "shipping": "1"
            }
        },
        "description": "This is the payment transaction description."
    },{
        "amount": {
            "total": "2",
            "currency": "USD",
            "details": {
                "subtotal": "1",
                "tax": "1",
                "shipping": "2"
            }
        },
        "description": "This2 is the payment transaction description."
    }]
};

paypal_api.payment.create(create_payment_json, config_opts, function (err, res) {
    if (err) {
        console.log(err);
        throw err;
    }

    if (res) {
        console.log("Create Payment Response");
        console.log(res);
    }
});

Response Status : 400 in the Api

The api is generating this error me, and I'm looking at the example that you have

Error: Response Status : 400
    at IncomingMessage.<anonymous> (/home/node_modules/paypal-rest-sdk/lib/paypal-rest-sdk.js:227:27)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

payment created via paypal expresscheckout doesn't takes into account description field value

Hi there,

We've found following the example at https://github.com/paypal/rest-api-sdk-nodejs/blob/master/samples/payment/create_with_paypal.js

that values given for "transactions" .description field are not reflected into paypal (at least on the sandbox).

What is seen at https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout on the left is default empty values. See attached.
screenshot from 2013-08-02 15 35 59

What could be the reason for that?

Here is what we are sending as request:

     var request = {
        "intent": "sale",
        "payer": {
            "payment_method": "paypal"
        },
        "redirect_urls": {
          "return_url": config.paypal.ReturnURL,
          "cancel_url": config.paypal.CancelURL,
        },
        "transactions": [{
          "amount": {
            "currency": "USD",
            "total": "1.00"
          },
          "description": "Changed description"
        }]
      }

executing an already executed payment raises error 500

As name says, it would make the SDK much more robust if catches Paypal REST API weird errors, instead of raising an Error to node.js

Example stacktrace:

Error: Response Status : 500
    at IncomingMessage.<anonymous> (node_modules/paypal-rest-sdk/lib/paypal-rest-sdk.js:227:27)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

Exported methods use "_" instead of camelCase

This is largely stylistic, but using underscores is not common in JavaScript. JavaScript methods names are typically written in camelCase, e.g. creditCard rather than credit_card.

Subscription requests

Hello there,
is it possible to handle subscription requests with this sdk?
I want to do both subscribe and unsubscribe actions.

TypeError creating a charge from a Future Payment authorization

Having previously authorized a future payment and stored the refresh token in our DB, The following code is crashing the server (node.js) when payment information comes in from the iOS SDK. I've already ensured that all the data given to these objects is legit, and the client_id and client_secret were previously set by a call to paypal.configure.

ppConf = {
          mode = "sandbox",
          correlation_id: payment.corrID,
          refresh_token: paymentAuthID
      };
charge = {
          intent: "sale",
          payer: {payment_method: "paypal"},
          transactions: [{
            amount: {currency: "USD", total: order.grandTotal / 100.0},
            description: ""
            }]
      };
paypal.payment.create(charge, ppConf, function (err, payment) {
   ...
}

The exception:

TypeError: Cannot set property 'Paypal-Application-Correlation-Id' of undefined
     at Object.executeHttp (....../node_modules/paypal-rest-sdk/lib/api.js:132:67)
     at Object.create (..../node_modules/paypal-rest-sdk/lib/generate.js:27:13)

400: client id or secret is null

Hi all,

I am trying to replace a the authorization_code with an access_token using openid_connect.tokeninfo.create but I am getting this error

{ [Error: Response Status : 400]
  response: 
   { error_description: 'client id or secret is null',
     error: 'invalid_client' },
  httpStatusCode: 400 }

Something to do with the paypal url ..

Exported methods should be named

All exported functions should be named rather than anonymous. This helps with debugging. Otherwise, the stack will appear as a log of anonymous functions.

Weird behavior

Hi all,
I've been witnessing this issue since yesterday.
Locally I can create a payment and execute it correctly, but once I commit my source to my server and update the callback url, the paypal_api.payment returns a null object.
My app is based on node v0.10.21, sails v0.9.15 and using mongo
Find my code below
What I'm I doing wrong?
Thanks for your help

// utility function

var paypal_api = require('paypal-rest-sdk');
var build_payment_json = function(plan){
    var create_payment_json = {
    "intent": "sale",
            "payer": {
                "payment_method": "paypal"
            },
            "redirect_urls": {
                //"return_url": "http://localhost:1337/execute_payment",
                //"cancel_url": "http://localhost:1337/pricing"
                "return_url": "http://www.promotoolz.net/execute_payment",
                "cancel_url": "http://www.promotoolz.net/pricing"

            },
            "transactions": [{
                "item_list": {
                    "items": [{
                        "name": plan.name,
                        "sku": plan.id,
                        "price": plan.price,
                        "currency": "EUR",
                        "quantity": 1
                    }]
                },
                "amount": {
                    "currency": "EUR",
                    "total": plan.price
                },
                "description": plan.description
            }]
        };
        return create_payment_json; 
};
//controller action
buy: function(req, res){
        paypal_api.configure({
        'mode': 'sandbox',//sandbox or live
        'client_id': 'AYeWZxBvfYb8dMzONeHi0PWA86tk3BG-Q0DgJyGuFdESVAz7G4aKJA34NiD4',
        'client_secret': 'EGDk1xB5aOO7OtPpL9Jxf391KlPpWwzo6QnN8zMchctOOGKN6oXh4547UgzY'
        Plan.findOne({id: req.params.id}).done(function(err, plan){
            if(err) throw err;
            if (plan) {
                var create_payment_json = build_payment_json(plan);
                paypal_api.payment.create(create_payment_json, function (error, payment) {
                    console.log(error);
                    if(error) throw error;
                    if(payment){
                        var payment_to_save_locally = {
                            p_id: payment.id,
                            uid: req.user.uid,
                            plan_id: req.params.id,
                            internal_status: "NEW"                  
                        };
                        Payment.create(payment_to_save_locally).done(function(err, payment) {
                            if (err) throw err;
                        })
                        payment.links.forEach(function(link) {
                            if (link.method === "REDIRECT") {
                                redirectUrl = link.href
                            }
                        })
                        res.redirect(redirectUrl)   
                    }else{}
                });
                //res.send(create_payment_json)
            };
        })
    },

Don't use wildcard dependencies

package.json lists three wildcard dependencies:

  1. node-uuid
  2. mocha
  3. chai

Versions should always be pinned to a major version so that they don't break when the interface changes with major updates.

utils.merge

The merge-function doesn't work correctly with following input:

utils.merge({},{a:{b:'c'}});

it will return {a:undefined};

Add this in begin of function

if (!obj1) return obj2;

And it also allows you to get rid of the ugly try..catch

GET payment details

Currently using this call with a configured paypal object in sandbox mode:

paypal.payment.get(paymentId, function (error, payment) {
});

Using a paymentId generated by iOS client in same sandbox.

error is always retuned with message "Resource not found: 404"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.