Skip to content

Instantly share code, notes, and snippets.

@incarnate
Created June 24, 2015 06:10
Show Gist options
  • Save incarnate/505c2bd25938a7a363a9 to your computer and use it in GitHub Desktop.
Save incarnate/505c2bd25938a7a363a9 to your computer and use it in GitHub Desktop.
eWAY Node.js + Express demo
/**
* eWAY Node.js demo
*
* Uses Node.js, Express & Restler to demonstrate connecting to eWAY Rapid API
* This file is a route, it calls a view called eway to display the data (not included)
*
* https://www.eway.com.au
*
* https://nodejs.org/
* http://expressjs.com/
* https://github.com/danwrong/restler
*/
var express = require('express');
var router = express.Router();
/* GET test eWAY Transaction */
router.get('/', function(req, res, next) {
var rest = require('restler');
var ewayData = {
"Customer": {
"CardDetails": {
"Name": "John Smith",
"Number": "4444333322221111",
"ExpiryMonth": "12",
"ExpiryYear": "25",
"CVN": "123"
}
},
"Payment": {
"TotalAmount": 1000
},
"Method": "ProcessPayment",
"TransactionType": "Purchase"
};
rest.postJson('https://api.sandbox.ewaypayments.com/Transaction', ewayData, {
username: 'eWAY Rapid API Key goes here',
password: 'eWAY Rapid API password'
}).on('complete', function(data) {
res.render('eway', { title: 'eWAY Payment', data: data });
});
});
module.exports = router;
@incarnate
Copy link
Author

eWAY now has a Node.js SDK to make this even easier!
https://github.com/eWAYPayment/eway-rapid-node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment