Advertisement
Guest User

Untitled

a guest
Apr 29th, 2019
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var soap = require('soap');
  2. const username =  "authdev"
  3. const password = "ad.900"
  4. const Version = "1000"
  5. const Processor = 21
  6. const MerchantId = "21"
  7. const url = "https://gatewaytest.borgun.is/ws/Heimir.pub.ws:Authorization"
  8.  
  9. const paymentHandler = async (cc, expiry, cvc, amount) => {
  10.     return new Promise((resolve) => {
  11.         var args = {
  12.             getAuthorization: {
  13.                 Version,
  14.                 Processor,
  15.                 MerchantID: MerchantId,
  16.                 TerminalID: 2,
  17.                 TransType: 1,
  18.                 TrAmount: amount,
  19.                 TrCurrency: 352,
  20.                 DateAndTime: dateString(),
  21.                 PAN: cc,
  22.                 ExpDate: expiry,
  23.                 RRN: "TEST00000001",
  24.                 CVC2: cvc,
  25.             }
  26.         };
  27.         soap.createClientAsync(`${url}?wsdl`, {'Content-Type': 'text/xml'} ).then((client) => {
  28.             client.setEndpoint(url);
  29.             client.setSecurityAsync(new soap.BasicAuthSecurity(username, password))
  30.             client.getAuthorization(args, (err, res, rawResponse, soapheader, rawRequest) => {
  31.                 console.log(rawRequest)
  32.                 console.log(res)
  33.             },{}, {})
  34.         })
  35.  
  36.     })
  37. }
  38.  
  39. const main = () => {
  40.     paymentHandler("5587402000012037", "0922", "310", 4000)
  41. }
  42.  
  43. main()
  44.  
  45. function dateString(){
  46.     function pad2(n) { return n < 10 ? '0' + n : n }
  47.     var date = new Date();
  48.     return date.getFullYear().toString() + pad2(date.getMonth() + 1) + pad2( date.getDate()) + pad2( date.getHours() ) + pad2( date.getMinutes() ) + pad2( date.getSeconds() )
  49. }
  50.  
  51. module.exports = {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement