Created
June 24, 2015 06:10
-
-
Save incarnate/505c2bd25938a7a363a9 to your computer and use it in GitHub Desktop.
eWAY Node.js + Express demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
eWAY now has a Node.js SDK to make this even easier!
https://github.com/eWAYPayment/eway-rapid-node