Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var soap = require('soap');
- const username = "authdev"
- const password = "ad.900"
- const Version = "1000"
- const Processor = 21
- const MerchantId = "21"
- const url = "https://gatewaytest.borgun.is/ws/Heimir.pub.ws:Authorization"
- const paymentHandler = async (cc, expiry, cvc, amount) => {
- return new Promise((resolve) => {
- var args = {
- getAuthorization: {
- Version,
- Processor,
- MerchantID: MerchantId,
- TerminalID: 2,
- TransType: 1,
- TrAmount: amount,
- TrCurrency: 352,
- DateAndTime: dateString(),
- PAN: cc,
- ExpDate: expiry,
- RRN: "TEST00000001",
- CVC2: cvc,
- }
- };
- soap.createClientAsync(`${url}?wsdl`, {'Content-Type': 'text/xml'} ).then((client) => {
- client.setEndpoint(url);
- client.setSecurityAsync(new soap.BasicAuthSecurity(username, password))
- client.getAuthorization(args, (err, res, rawResponse, soapheader, rawRequest) => {
- console.log(rawRequest)
- console.log(res)
- },{}, {})
- })
- })
- }
- const main = () => {
- paymentHandler("5587402000012037", "0922", "310", 4000)
- }
- main()
- function dateString(){
- function pad2(n) { return n < 10 ? '0' + n : n }
- var date = new Date();
- return date.getFullYear().toString() + pad2(date.getMonth() + 1) + pad2( date.getDate()) + pad2( date.getHours() ) + pad2( date.getMinutes() ) + pad2( date.getSeconds() )
- }
- module.exports = {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement