Adaptive Payments and Adaptive Accounts SDK
Node.js sdk for Paypal Adaptive Payments and Paypal Adaptive Accounts APIs, without dependencies
Usage
- Add dependency 'paypal-adaptive' in your package.json file.
- Require 'paypal-adaptive' in your file.var Paypal = ;var paypalSdk =userId: 'userId'password: 'password'signature: 'signature'sandbox: true //defaults to false;
- Call to sdk methods or to the generic method callApi. If you get an error, you can check the response too for better error handling.var requestData =requestEnvelope:errorLanguage: 'en_US'detailLevel: 'ReturnAll'payKey: 'AP-1234567890';paypalSdk;
API
GetPaymentOptions
var payKey = 'AP-1234567890'; paypalSdk;
PaymentDetails
// One of this params is required// The payKeyvar params = payKey: 'AP-1234567890';// Or the transactionIdvar params = transactionId: 'AP-1234567890';// Or the trackingIdvar params = trackingId: 'AP-1234567890'; paypalSdk;
Pay
var payload = requestEnvelope: errorLanguage: 'en_US' actionType: 'PAY' currencyCode: 'USD' feesPayer: 'EACHRECEIVER' memo: 'Chained payment example' cancelUrl: 'http://test.com/cancel' returnUrl: 'http://test.com/success' receiverList: receiver: email: 'primary@test.com' amount: '100.00' primary:'true' email: 'secondary@test.com' amount: '10.00' primary:'false' ; paypalSdk;
Preapproval
var payload = currencyCode: 'USD' startingDate: endingDate: '2020-01-01' returnUrl: 'http://your-website.com' cancelUrl: 'http://your-website.com' ipnNotificationUrl: 'http://your-ipn-listener.com' maxNumberOfPayments: 1 displayMaxTotalAmount: true maxTotalAmountOfAllPayments: '100.00' requestEnvelope: errorLanguage: 'en_US' paypalSdk;
Note: The other API methods has default behavior by now: you send a payload and obtains the Paypal original response.
var payload = requestEnvelope: errorLanguage: 'en_US' // another data required by API method; var { if err // Handle error console; else // Paypal response console }; // For Adaptive PaymentspaypalSdk; paypalSdk; paypalSdk; paypalSdk; paypalSdk; paypalSdk; paypalSdk; // For Adaptive AccountspaypalSdk; paypalSdk; paypalSdk; paypalSdk;// To use this method you can set X-PAYPAL-SANDBOX-EMAIL-ADDRESS and X-PAYPAL-DEVICE-IPADDRESS headers passing 'sandboxEmailAddress' and 'deviceIpAddress' properties on config paypalSdk; paypalSdk; paypalSdk; paypalSdk;
Tests
Tests can be ran with:
mocha
Reference
Paypal Adaptive Payments Paypal Adaptive Accounts
License
Copyright (c) 2014 Gonzalo Aguirre. See the LICENSE file for license rights and limitations (MIT).