Commit 7f796c813193bb39abf38b6b3dd8ce8f4eb9191f

Authored by Adhidarma Hadiwinoto
1 parent bb9e3f5056
Exists in master

coba easysoap

Showing 2 changed files with 48 additions and 14 deletions Side-by-side Diff

... ... @@ -20,6 +20,7 @@
20 20 "author": "Adhidarma Hadiwinoto <me@adhisimon.org>",
21 21 "license": "ISC",
22 22 "dependencies": {
  23 + "easysoap": "^1.0.5",
23 24 "ini": "^1.3.4",
24 25 "sate24": "git+http://gitlab.kodesumber.com/reload97/node-sate24.git",
25 26 "sate24-expresso": "git+http://gitlab.kodesumber.com/reload97/sate24-expresso.git",
partner-kospinjasa.js
... ... @@ -2,6 +2,7 @@ var winston = require(&#39;winston&#39;);
2 2 var soap = require('soap');
3 3 var crypto = require('crypto');
4 4 var strftime = require('strftime');
  5 +var easysoap = require('easysoap');
5 6  
6 7 var max_retry = 10;
7 8 var sleep_before_retry = 5000;
... ... @@ -37,22 +38,52 @@ function topupRequest(task, retry) {
37 38 }
38 39  
39 40 var remoteProduct = task.remoteProduct.split(',');
  41 + var args = {
  42 + userName: config.h2h_out.userid,
  43 + productCode: remoteProduct[0] ,
  44 + terminal: 'terminal0',
  45 + transactionType: '50',
  46 + billNumber: createBillNumber(task.destination),
  47 + amount: remoteProduct[1],
  48 + bit61: createBillNumber(task.destination),
  49 + reff: task.requestId,
  50 + timeStamp: strftime('%d-%m-%Y %H:%M:%S', new Date()),
  51 + }
  52 +
  53 + var signature = createSignature(args, config.h2h_out.password);
  54 + args.signature = signature;
  55 +
  56 + topupRequestEasySoap(task, args, retry);
  57 +}
  58 +
  59 +function topupRequestEasySoap(task, args, retry) {
  60 + //partner=http://203.130.243.155/ApiH2H/index.php?wsdl
  61 +
  62 + var params = {
  63 + host: '203.130.243.155',
  64 + path: '/ApiH2H/index.php'
  65 + wsdl: '/ApiH2H/index.php?wsdl'
  66 + }
  67 +
  68 + var soapClient = easysoap.createClient(params);
  69 + soapClient.call({
  70 + method: 'billpayment',
  71 + params: args,
  72 + })
  73 + .then((callResponse) => {
  74 + console.log(callResponse.data); // response data as json
  75 + console.log(callResponse.body); // response body
  76 + console.log(callResponse.header); //response header
  77 + })
  78 + .catch((err) => { throw new Error(err); });
  79 +
  80 + callbackReport(task.requestId, '68', 'debug');
  81 +
  82 +}
  83 +
  84 +function topupRequestSoap(task, args, retry) {
40 85  
41 86 soap.createClient(config.h2h_out.partner, function(err, client) {
42   - var args = {
43   - userNam: config.h2h_out.userid,
44   - productCode: remoteProduct[0] ,
45   - terminal: 'terminal0',
46   - transactionType: '50',
47   - billNumber: createBillNumber(task.destination),
48   - amount: remoteProduct[1],
49   - bit61: createBillNumber(task.destination),
50   - reff: task.requestId,
51   - timeStamp: strftime('%d-%m-%Y %H:%M:%S', new Date()),
52   - }
53   -
54   - var signature = createSignature(args, config.h2h_out.password);
55   - args.signature = signature;
56 87  
57 88 logger.info('Requesting to service', {url: config.h2h_out.partner, args: args});
58 89  
... ... @@ -72,6 +103,8 @@ function topupRequest(task, retry) {
72 103 });
73 104 }
74 105  
  106 +
  107 +
75 108 function createSignature(args, password) {
76 109 var passwordHash = crypto.createHash('sha256').update(password).digest().toString('hex');
77 110