Simple SDKs

eWAY is the easiest way to accept payments in your app or on your website. Get integrated and start selling more, faster - in a range of languages using the eWAY SDKs, helpful documentation, and 24/7 support from real humans. eWAY - with you every step of the way.

SDK

Node.JS SDK

Accept payments quickly and easily with eWAY and Node.js using the eWAY Rapid Node.js SDK. Using the eWAY Node.js SDK provides convenient access to all the features of eWAY’s Rapid API, so you can create transactions, process refunds, query transactions, create token customers, and more!

Getting Started

Requirements

The eWAY Node.js SDK requires Node version 0.10 and requires bluebird, express-uri-template, lodash and request-promise. We recommend installing using the npm package manager to install it.

To make development and testing with eWAY easy, get a free partner account which provides access to the eWAY Sandbox.

Install

Using npm, the eWAY Node.js SDK can be installed with the following command:

1

$ npm install eway-rapid

BUILD

Once installed, the eWAY Node.js SDK can be included in your project by requiring it:

1

var rapid = require('eway-rapid');

Now you are all set to build your eWAY integration! You can find code samples for integrating various eWAY functions as part of the eWAY Rapid API reference.

Example Integration

To demonstrate adding the eWAY Node.js SDK, this example will show how to accept a payment with the Responsive Shared Page.

1. Add the eWAY Node.js SDK

In the project directory, run the npm command to install the eWAY Node.js SDK

1

$ npm install eway-rapid

Once completed, the SDK and its dependencies will be downloaded and added to your project’s node_modules directory.

2. Load the eWAY Node.js SDK

In the file where you wish to initiate your eWAY transaction, add the eWAY SDK:

1

var rapid = require('eway-rapid');

Now the eWAY client can be created with your Rapid API key & password. These can be found in Sandbox or Live MYeWAY – remember that different credentials are needed for sandbox to production.

3. Create a Shared Payment URL

In order to send a customer to the Responsive Shared Page, a URL must be generated using the createTransaction function. This accepts a JSON object – more details of the variables that can be passed can be found in the Rapid API reference.

This step would usually take place after collecting the customer’s information in a checkout process. For this example, just some dummy data will be used:

4. Redirect the Customer

​Usually once the shared page URL has been created, the customer can be immediately redirected. Alternatively, you can display the URL (how this is displayed will depend on your Node.js framework):

1

'<a href="'+ $sharedURL +'">Pay with our secure payment page</a>'

Now a link will be displayed which goes to the Responsive Shared Page created with the details submitted in the previous step.

5. Fetch the Result

Once the customer has gone to the Responsive Shared Page and submitted their payment information, they will be redirected back to the RedirectUrl specified in the request. This page should use the AccessCode (passed as a query variable) to fetch the result of the transaction.

1

client.queryTransaction(accessCode)

Key information such as the success of the transaction and the transaction ID can be found in the response. If the transaction wasn’t successful, the reason can be found in the ResponsiveMessage. An example of handling this information would be: