From 823dbf1912367e68155e83d8529659bea6f10067 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 18:50:32 +0700 Subject: [PATCH 01/31] - added digiflazz supplier --- src/helper/irs-api.ts | 120 +++++++++++++++++--- src/transaction/ppob_callback.controller.ts | 21 ++++ src/transaction/transaction.service.ts | 92 ++++++++++++--- 3 files changed, 203 insertions(+), 30 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 4d7cbf0..7e83b8d 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -1,4 +1,5 @@ import axios from 'axios'; +import cryptoMd5 from "crypto"; const irs_url = 'http://h2h.elangpixiu.com/api/h2h'; const irs_id = 'PT0005'; @@ -7,32 +8,112 @@ const irs_user = 'D10BD0'; const irs_pass = '6251F3'; export const doTransaction = async ( - productCode, - destination, - idtrx, - supplier, - authorization, - typePaid, + productCode, + destination, + idtrx, + supplier, + authorization, + typePaid, + billTrxId, ) => { try { if (supplier.code == 'IRS') { const res = await axios.get( - `${irs_url}?id=${irs_id}&pin=${irs_pin}&user=${irs_user}&pass=${irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`, + `${irs_url}?id=${irs_id}&pin=${irs_pin}&user=${irs_user}&pass=${irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`, ); return res.data; } else if (supplier.code == 'NIRS') { const res = await axios.get( - `${supplier.url}?id=${supplier.irs_id}&pin=${supplier.irs_pin}&user=${supplier.irs_user}&pass=${supplier.irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`, + `${supplier.url}?id=${supplier.irs_id}&pin=${supplier.irs_pin}&user=${supplier.irs_user}&pass=${supplier.irs_pass}&kodeproduk=${productCode}&tujuan=${destination}&counter=1&idtrx=${idtrx}`, ); return res.data; - } else if (supplier.code == 'Hemat') { - if (authorization != "") { - console.log("initoken", authorization) + } else if (supplier.code == 'Digiflazz') { + if (typePaid == 'INQUIRY') { + const md5HashDigiflazz = `${irs_user}${irs_pass}${idtrx}`; + const cryptoMd5 = require('crypto'); + + cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex'); + const options = { - headers: {'Content-Type': 'application/json', - 'Authorization': 'Bearer ' + authorization} + headers: { 'Content-Type': 'application/json' }, + }; + const data = { + commands: 'inq-pasca', + username: irs_user, + customer_no: `${destination}`, + buyer_sku_code: `${productCode}`, + ref_id: `${idtrx}`, + sign: cryptoMd5, + testing: true, + }; + const res = await axios.post( + `${supplier.url}/v1/transaction`, + data, + options, + ); + + return res.data; + } else if (typePaid == 'PAYMENT') { + const md5HashDigiflazz = `${irs_user}${irs_pass}${idtrx}`; + const cryptoMd5 = require('crypto'); + + cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex'); + + const options = { + headers: { 'Content-Type': 'application/json' }, + }; + const data = { + commands: 'pay-pasca', + username: irs_user, + customer_no: `${destination}`, + buyer_sku_code: `${productCode}`, + ref_id: `${billTrxId}`, + sign: cryptoMd5, + testing: true, + }; + const res = await axios.post( + `${supplier.url}/v1/transaction`, + data, + options, + ); + + return res.data; + } else { + const md5HashDigiflazz = `${irs_user}${irs_pass}${idtrx}`; + const cryptoMd5 = require('crypto'); + + cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex'); + + const options = { + headers: {'Content-Type': 'application/json'}, + }; + const data = { + username: irs_user, + customer_no: `${destination}`, + buyer_sku_code: `${productCode}`, + ref_id: `${idtrx}`, + sign: cryptoMd5, + testing: true, + }; + const res = await axios.post( + `${supplier.url}/v1/transaction`, + data, + options, + ); + + return res.data; + } + } else if (supplier.code == 'Hemat') { + if (authorization != '') { + console.log('initoken', authorization); + + const options = { + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${authorization}`, + }, }; const data = { idtransaction: idtrx, @@ -40,25 +121,30 @@ export const doTransaction = async ( code: `${productCode}`, type: `${typePaid}`, }; - const res = await axios.post(`${supplier.url}/v1/transaction/request`, data, options); + const res = await axios.post( + `${supplier.url}/v1/transaction/request`, + data, + options, + ); return res.data; } } const res = await axios.get( - `${supplier.url}?memberID=${supplier.irs_id}&pin=${supplier.irs_pin}&password=${supplier.irs_pass}&product=${productCode}&dest=${destination}&counter=1&refID=${idtrx}`, + `${supplier.url}?memberID=${supplier.irs_id}&pin=${supplier.irs_pin}&password=${supplier.irs_pass}&product=${productCode}&dest=${destination}&counter=1&refID=${idtrx}`, ); return res.data; - console.log('restranshemat', res) + console.log('restranshemat', res); } catch (err) { console.log('errtranshemat', err); + if (err.includes('Maaf Saldo anda tidak mencukupi')) { throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; } else { throw err; } - } + } }; diff --git a/src/transaction/ppob_callback.controller.ts b/src/transaction/ppob_callback.controller.ts index caef626..95fd0dc 100644 --- a/src/transaction/ppob_callback.controller.ts +++ b/src/transaction/ppob_callback.controller.ts @@ -152,4 +152,25 @@ export class PpobCallbackController { ); } } + + @Public() + @Post('/digiflazz') + async getDigiflazz(@Req() request: FastifyRequest) { + const response = request.body; + console.log('responsehemat', response); + console.log('responsehemat2', request.body); + if (response['msg'] != 'Transaksi Sukses') { + //TODO: UPDATE GAGAL + await this.transactionService.checkCallbackOrderFailed( + response['data']['ref_id'], + response['data'], + ); + } else { + //TODO: UPDATE BERHASIL + await this.transactionService.checkCallbackOrderSuccess( + response['data']['ref_id'], + response['data'], + ); + } + } } diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 83bf98d..2a51b5e 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -614,12 +614,14 @@ export class TransactionService { } //HIT API SUPPLIER - const trxId = Array(11) - .fill(null) - .map(() => { - return Math.round(Math.random() * 16).toString(16); - }) - .join(''); + let trxId; + + trxId = Array(11) + .fill(null) + .map(() => { + return Math.round(Math.random() * 16).toString(16); + }) + .join(''); let hitLoginHemat; @@ -635,6 +637,7 @@ export class TransactionService { supplier, hitLoginHemat.data, product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', + orderTransactionDto.bill_trx_id ) : await doTransaction( orderTransactionDto.productCode, orderTransactionDto.destination, @@ -642,6 +645,7 @@ export class TransactionService { supplier, "", product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', + orderTransactionDto.bill_trx_id ); // let hitSupplier; @@ -677,6 +681,29 @@ export class TransactionService { hitSupplier = newHitSupplier; + if (orderTransactionDto.bill_trx_id !== null) { + hitSupplier.harga = product_price.price; + } + } else if (supplier.code == 'Digiflazz') { + let newHitSupplier; + + if (product.type == 'prepaid') { + newHitSupplier= { + success: hitSupplier.status.includes('Pending') || hitSupplier.status.includes('Sukses'), + harga: hitSupplier.price, + msg: hitSupplier.message, + }; + } else { + newHitSupplier= { + success: hitSupplier.status.includes('Pending') || hitSupplier.status.includes('Sukses'), + harga: hitSupplier.price, + msg: hitSupplier.message, + sn: hitSupplier.sn, + }; + } + + hitSupplier = newHitSupplier; + if (orderTransactionDto.bill_trx_id !== null) { hitSupplier.harga = product_price.price; } @@ -757,8 +784,18 @@ export class TransactionService { HttpStatus.INTERNAL_SERVER_ERROR, ); } else { - transactionData.status = statusTransaction.PENDING; - status = statusTransaction[transactionData.status]; + if ( + hitSupplier.sn != null || + hitSupplier.sn != '' || + hitSupplier.sn != undefined + ) { + transactionData.seri_number = hitSupplier.sn; + transactionData.status = statusTransaction.SUCCESS; + status = statusTransaction[transactionData.status]; + } else { + transactionData.status = statusTransaction.PENDING; + status = statusTransaction[transactionData.status]; + } } await manager.insert(Transactions, transactionData); @@ -882,6 +919,7 @@ export class TransactionService { supplier, hitLoginHemat.data, product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', + orderTransactionDto.bill_trx_id ) : await doTransaction( orderTransactionDto.productCode, orderTransactionDto.destination, @@ -889,6 +927,7 @@ export class TransactionService { supplier, "", product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', + orderTransactionDto.bill_trx_id ); if (supplier.code != 'IRS') { @@ -1030,21 +1069,39 @@ export class TransactionService { hitLoginHemat = await doAuthorizeHemat(supplier.irs_user, supplier.irs_pass, supplier); } - let hitSupplier = supplier.code == 'Hemat' ? await doTransaction( + let hitSupplier; + + if (supplier.code == 'Hemat') { + hitSupplier = await doTransaction( orderTransactionDto.productCode, orderTransactionDto.destination, trxId, supplier, hitLoginHemat.data, - 'INQUIRY' - ) : await doTransaction( - `CEK${orderTransactionDto.productCode.slice(3)}`, + 'INQUIRY', + orderTransactionDto.bill_trx_id + ) + } else if (supplier.code == 'Digiflazz') { + hitSupplier = await doTransaction( + orderTransactionDto.productCode, + orderTransactionDto.destination, + trxId, + supplier, + hitLoginHemat.data, + 'INQUIRY', + orderTransactionDto.bill_trx_id + ) + } else { + await doTransaction( + hitSupplier= `CEK${orderTransactionDto.productCode.slice(3)}`, orderTransactionDto.destination, trxId, supplier, "", - 'INQUIRY' + 'INQUIRY', + orderTransactionDto.bill_trx_id ); + } // const parsingResponse = hitSupplier.split(' '); if (supplier.code == 'Hemat') { @@ -1052,6 +1109,11 @@ export class TransactionService { success: hitSupplier.success == true, msg: hitSupplier.msg, }; + } else if (supplier.code == 'Digiflazz') { + hitSupplier = { + success: hitSupplier.status.includes('Sukses'), + msg: hitSupplier.message, + }; } else { hitSupplier = { success: hitSupplier.includes('diproses') || hitSupplier.includes('dalam proses'), @@ -1500,6 +1562,10 @@ export class TransactionService { } else { dataProductHistoryPrice.price = parseInt(callback['data']['additional']['harga']); } + } else if (supplier.code == 'Digiflazz') { + if (callback['sn']) { + dataTransaction.seri_number = callback['sn']; + } } else { if (callback['sn']) { dataTransaction.seri_number = callback['sn']; From 5463d1b12be42ea5636987cab7da649adc7262f6 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 19:07:32 +0700 Subject: [PATCH 02/31] - added digiflazz supplier --- src/helper/irs-api.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 7e83b8d..cec5509 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -31,7 +31,7 @@ export const doTransaction = async ( return res.data; } else if (supplier.code == 'Digiflazz') { if (typePaid == 'INQUIRY') { - const md5HashDigiflazz = `${irs_user}${irs_pass}${idtrx}`; + const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; const cryptoMd5 = require('crypto'); cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex'); @@ -41,7 +41,7 @@ export const doTransaction = async ( }; const data = { commands: 'inq-pasca', - username: irs_user, + username: supplier.irs_user, customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, @@ -49,14 +49,14 @@ export const doTransaction = async ( testing: true, }; const res = await axios.post( - `${supplier.url}/v1/transaction`, + `${supplier.url}/transaction`, data, options, ); return res.data; } else if (typePaid == 'PAYMENT') { - const md5HashDigiflazz = `${irs_user}${irs_pass}${idtrx}`; + const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; const cryptoMd5 = require('crypto'); cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex'); @@ -66,7 +66,7 @@ export const doTransaction = async ( }; const data = { commands: 'pay-pasca', - username: irs_user, + username: supplier.irs_user, customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${billTrxId}`, @@ -74,14 +74,14 @@ export const doTransaction = async ( testing: true, }; const res = await axios.post( - `${supplier.url}/v1/transaction`, + `${supplier.url}/transaction`, data, options, ); return res.data; } else { - const md5HashDigiflazz = `${irs_user}${irs_pass}${idtrx}`; + const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; const cryptoMd5 = require('crypto'); cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex'); @@ -90,7 +90,7 @@ export const doTransaction = async ( headers: {'Content-Type': 'application/json'}, }; const data = { - username: irs_user, + username: supplier.irs_user, customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, @@ -98,7 +98,7 @@ export const doTransaction = async ( testing: true, }; const res = await axios.post( - `${supplier.url}/v1/transaction`, + `${supplier.url}/transaction`, data, options, ); From cfb7d035f65e9dcebbb18e78c1f6b77cb545c93b Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 20:48:34 +0700 Subject: [PATCH 03/31] - added digiflazz supplier --- package-lock.json | 15 +++++++++++++++ package.json | 1 + src/helper/irs-api.ts | 19 +++++++------------ yarn.lock | 5 +++++ 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index de81b2d..4dcc4a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "class-transformer": "^0.4.0", "class-validator": "^0.13.1", "crypto": "^1.0.1", + "crypto-md5": "^1.0.0", "csv-parser": "^3.0.0", "decimal.js": "^10.3.1", "exceljs": "^4.3.0", @@ -3835,6 +3836,15 @@ "integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==", "deprecated": "This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in." }, + "node_modules/crypto-md5": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/crypto-md5/-/crypto-md5-1.0.0.tgz", + "integrity": "sha512-65Mtei8+EkSIK+5Ie4gpWXoJ/5bgpqPXFknHHXAyhDqKsEAAzUslGd8mOeawbfcuQ8fADNKcF4xQA3fqlZJ8Ig==", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.5.2" + } + }, "node_modules/cssom": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", @@ -13583,6 +13593,11 @@ "resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz", "integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==" }, + "crypto-md5": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/crypto-md5/-/crypto-md5-1.0.0.tgz", + "integrity": "sha512-65Mtei8+EkSIK+5Ie4gpWXoJ/5bgpqPXFknHHXAyhDqKsEAAzUslGd8mOeawbfcuQ8fADNKcF4xQA3fqlZJ8Ig==" + }, "cssom": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", diff --git a/package.json b/package.json index 16f66db..0b19eb4 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "class-transformer": "^0.4.0", "class-validator": "^0.13.1", "crypto": "^1.0.1", + "crypto-md5": "^1.0.0", "csv-parser": "^3.0.0", "decimal.js": "^10.3.1", "exceljs": "^4.3.0", diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index cec5509..727e7d3 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -32,9 +32,7 @@ export const doTransaction = async ( } else if (supplier.code == 'Digiflazz') { if (typePaid == 'INQUIRY') { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - const cryptoMd5 = require('crypto'); - - cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex'); + var cryptoMd5 = require('md5'); const options = { headers: { 'Content-Type': 'application/json' }, @@ -45,7 +43,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: cryptoMd5, + sign: cryptoMd5(md5HashDigiflazz, 'hex'), testing: true, }; const res = await axios.post( @@ -57,9 +55,7 @@ export const doTransaction = async ( return res.data; } else if (typePaid == 'PAYMENT') { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - const cryptoMd5 = require('crypto'); - - cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex'); + var cryptoMd5 = require('md5'); const options = { headers: { 'Content-Type': 'application/json' }, @@ -70,7 +66,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${billTrxId}`, - sign: cryptoMd5, + sign: cryptoMd5(md5HashDigiflazz, 'hex'), testing: true, }; const res = await axios.post( @@ -82,9 +78,7 @@ export const doTransaction = async ( return res.data; } else { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - const cryptoMd5 = require('crypto'); - - cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex'); + var cryptoMd5 = require('md5'); const options = { headers: {'Content-Type': 'application/json'}, @@ -94,7 +88,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: cryptoMd5, + sign: cryptoMd5(md5HashDigiflazz, 'hex'), testing: true, }; const res = await axios.post( @@ -103,6 +97,7 @@ export const doTransaction = async ( options, ); + console.log('resdigiflazz', res); return res.data; } } else if (supplier.code == 'Hemat') { diff --git a/yarn.lock b/yarn.lock index 1499c42..79dcc4d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2265,6 +2265,11 @@ "shebang-command" "^2.0.0" "which" "^2.0.1" +"crypto-md5@^1.0.0": + "integrity" "sha512-65Mtei8+EkSIK+5Ie4gpWXoJ/5bgpqPXFknHHXAyhDqKsEAAzUslGd8mOeawbfcuQ8fADNKcF4xQA3fqlZJ8Ig==" + "resolved" "https://registry.npmjs.org/crypto-md5/-/crypto-md5-1.0.0.tgz" + "version" "1.0.0" + "crypto@^1.0.1": "integrity" "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==" "resolved" "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz" From 576f57cd479f7a6094c8af27c729f2440eb21d4a Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 20:55:11 +0700 Subject: [PATCH 04/31] - add log for digiflazz --- src/helper/irs-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 727e7d3..5b8474d 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -79,7 +79,7 @@ export const doTransaction = async ( } else { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; var cryptoMd5 = require('md5'); - + console.log('hashmd5', cryptoMd5(md5HashDigiflazz, 'hex')); const options = { headers: {'Content-Type': 'application/json'}, }; From 23df6739076f36d1faa2017b8a2ffeb4a96684f3 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 21:24:09 +0700 Subject: [PATCH 05/31] - fix digiflazz supplier --- package-lock.json | 11 +++++++++++ package.json | 1 + src/helper/irs-api.ts | 13 +++++-------- yarn.lock | 5 +++++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4dcc4a1..7c7b60b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "fs-extra": "^10.0.0", "joi": "^17.4.2", "lodash": "^4.17.21", + "md5-hash": "^1.0.1", "moment": "^2.29.4", "nestjs-pino": "^2.3.1", "passport": "^0.4.0", @@ -7358,6 +7359,11 @@ "tmpl": "1.0.5" } }, + "node_modules/md5-hash": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/md5-hash/-/md5-hash-1.0.1.tgz", + "integrity": "sha512-McGTs7cIc3JSw9SJH5JxFCJRoI1bi9tKh89LZxpHobmY2YGGhYTnDZ2rxcvNv0Bs1gBbSwSQfCwbuFleZOkkYA==" + }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -16405,6 +16411,11 @@ "tmpl": "1.0.5" } }, + "md5-hash": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/md5-hash/-/md5-hash-1.0.1.tgz", + "integrity": "sha512-McGTs7cIc3JSw9SJH5JxFCJRoI1bi9tKh89LZxpHobmY2YGGhYTnDZ2rxcvNv0Bs1gBbSwSQfCwbuFleZOkkYA==" + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", diff --git a/package.json b/package.json index 0b19eb4..de09715 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "fs-extra": "^10.0.0", "joi": "^17.4.2", "lodash": "^4.17.21", + "md5-hash": "^1.0.1", "moment": "^2.29.4", "nestjs-pino": "^2.3.1", "passport": "^0.4.0", diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 5b8474d..9b1b644 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -1,5 +1,5 @@ import axios from 'axios'; -import cryptoMd5 from "crypto"; +import md5 from 'md5-hash'; const irs_url = 'http://h2h.elangpixiu.com/api/h2h'; const irs_id = 'PT0005'; @@ -32,7 +32,6 @@ export const doTransaction = async ( } else if (supplier.code == 'Digiflazz') { if (typePaid == 'INQUIRY') { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - var cryptoMd5 = require('md5'); const options = { headers: { 'Content-Type': 'application/json' }, @@ -43,7 +42,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: cryptoMd5(md5HashDigiflazz, 'hex'), + sign: md5(md5HashDigiflazz), testing: true, }; const res = await axios.post( @@ -55,7 +54,6 @@ export const doTransaction = async ( return res.data; } else if (typePaid == 'PAYMENT') { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - var cryptoMd5 = require('md5'); const options = { headers: { 'Content-Type': 'application/json' }, @@ -66,7 +64,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${billTrxId}`, - sign: cryptoMd5(md5HashDigiflazz, 'hex'), + sign: md5(md5HashDigiflazz), testing: true, }; const res = await axios.post( @@ -78,8 +76,7 @@ export const doTransaction = async ( return res.data; } else { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - var cryptoMd5 = require('md5'); - console.log('hashmd5', cryptoMd5(md5HashDigiflazz, 'hex')); + console.log('hashmd5', md5(md5HashDigiflazz)); const options = { headers: {'Content-Type': 'application/json'}, }; @@ -88,7 +85,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: cryptoMd5(md5HashDigiflazz, 'hex'), + sign: md5(md5HashDigiflazz), testing: true, }; const res = await axios.post( diff --git a/yarn.lock b/yarn.lock index 79dcc4d..cf4f6a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4386,6 +4386,11 @@ dependencies: "tmpl" "1.0.5" +"md5-hash@^1.0.1": + "integrity" "sha512-McGTs7cIc3JSw9SJH5JxFCJRoI1bi9tKh89LZxpHobmY2YGGhYTnDZ2rxcvNv0Bs1gBbSwSQfCwbuFleZOkkYA==" + "resolved" "https://registry.npmjs.org/md5-hash/-/md5-hash-1.0.1.tgz" + "version" "1.0.1" + "media-typer@0.3.0": "integrity" "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" "resolved" "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz" From 3705fbf151f17af45d741721d233a50db256e0e5 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 21:33:54 +0700 Subject: [PATCH 06/31] - log digiflazz supplier --- src/helper/irs-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 9b1b644..31221c2 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -131,7 +131,7 @@ export const doTransaction = async ( console.log('restranshemat', res); } catch (err) { - console.log('errtranshemat', err); + console.log('errtranshemat', err.data); if (err.includes('Maaf Saldo anda tidak mencukupi')) { throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; From fe801ef8161f85f4feab03a3655620591ccdee09 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 21:43:34 +0700 Subject: [PATCH 07/31] - log digiflazz supplier --- src/helper/irs-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 31221c2..ff5623f 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -131,7 +131,7 @@ export const doTransaction = async ( console.log('restranshemat', res); } catch (err) { - console.log('errtranshemat', err.data); + console.log('errtranshemat', err['data']); if (err.includes('Maaf Saldo anda tidak mencukupi')) { throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; From 69b77b7561bee5a8c44f1738d4bcfe7a7181e353 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 22:12:56 +0700 Subject: [PATCH 08/31] - log digiflazz supplier --- src/helper/irs-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index ff5623f..c2903d8 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -131,7 +131,7 @@ export const doTransaction = async ( console.log('restranshemat', res); } catch (err) { - console.log('errtranshemat', err['data']); + console.log('errtranshemat', err.message); if (err.includes('Maaf Saldo anda tidak mencukupi')) { throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; From 2cf3c8ad930115097938af875109737eab48b080 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 22:24:23 +0700 Subject: [PATCH 09/31] - log digiflazz supplier --- src/helper/irs-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index c2903d8..5440271 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -131,7 +131,7 @@ export const doTransaction = async ( console.log('restranshemat', res); } catch (err) { - console.log('errtranshemat', err.message); + console.log('errtranshemat', err.body); if (err.includes('Maaf Saldo anda tidak mencukupi')) { throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; From 8bd3fadefce2ae4cdd382e1b7822f1ae819ae5e1 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 22:28:39 +0700 Subject: [PATCH 10/31] - log digiflazz supplier --- src/helper/irs-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 5440271..9b1b644 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -131,7 +131,7 @@ export const doTransaction = async ( console.log('restranshemat', res); } catch (err) { - console.log('errtranshemat', err.body); + console.log('errtranshemat', err); if (err.includes('Maaf Saldo anda tidak mencukupi')) { throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; From deced5f847304a31446d2c620e221f4abfdf601c Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 22:40:04 +0700 Subject: [PATCH 11/31] - log digiflazz supplier --- src/helper/irs-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 9b1b644..220dee8 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -131,7 +131,7 @@ export const doTransaction = async ( console.log('restranshemat', res); } catch (err) { - console.log('errtranshemat', err); + console.log('errtranshemat', err.response.data); if (err.includes('Maaf Saldo anda tidak mencukupi')) { throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; From 55b27631bab51a67e55d1223c74491546d0136a8 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 22:52:44 +0700 Subject: [PATCH 12/31] - log digiflazz supplier --- src/helper/irs-api.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 220dee8..68d9763 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -42,7 +42,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: md5(md5HashDigiflazz), + sign: md5.default(md5HashDigiflazz), testing: true, }; const res = await axios.post( @@ -64,7 +64,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${billTrxId}`, - sign: md5(md5HashDigiflazz), + sign: md5.default(md5HashDigiflazz), testing: true, }; const res = await axios.post( @@ -76,7 +76,7 @@ export const doTransaction = async ( return res.data; } else { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - console.log('hashmd5', md5(md5HashDigiflazz)); + const options = { headers: {'Content-Type': 'application/json'}, }; @@ -85,7 +85,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: md5(md5HashDigiflazz), + sign: md5.default(md5HashDigiflazz), testing: true, }; const res = await axios.post( From 763d30f78933ead93ed0373f9c0c0eeab0b227b3 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 23:00:31 +0700 Subject: [PATCH 13/31] - log digiflazz supplier --- src/helper/irs-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 68d9763..aee11de 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -131,7 +131,7 @@ export const doTransaction = async ( console.log('restranshemat', res); } catch (err) { - console.log('errtranshemat', err.response.data); + console.log('errtranshemat', err); if (err.includes('Maaf Saldo anda tidak mencukupi')) { throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; From b645ed273c8ffaa69b883831edb4d87140180803 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 23:07:29 +0700 Subject: [PATCH 14/31] - log digiflazz supplier --- src/helper/irs-api.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index aee11de..1eda4b3 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -42,7 +42,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: md5.default(md5HashDigiflazz), + sign: md5(md5HashDigiflazz), testing: true, }; const res = await axios.post( @@ -64,7 +64,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${billTrxId}`, - sign: md5.default(md5HashDigiflazz), + sign: md5(md5HashDigiflazz), testing: true, }; const res = await axios.post( @@ -85,7 +85,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: md5.default(md5HashDigiflazz), + sign: md5(md5HashDigiflazz), testing: true, }; const res = await axios.post( From 62593684f6dbc50e8cd34664cefc8bec8c2fbbc5 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 23:12:53 +0700 Subject: [PATCH 15/31] - log digiflazz supplier --- src/helper/irs-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 1eda4b3..8a2e10c 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -76,7 +76,7 @@ export const doTransaction = async ( return res.data; } else { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - + console.log('hashmd5', md5HashDigiflazz); const options = { headers: {'Content-Type': 'application/json'}, }; From e7e3e09d889ea3532bb7aab1215df9f66ff8386e Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 23:30:49 +0700 Subject: [PATCH 16/31] - log digiflazz supplier --- src/helper/irs-api.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 8a2e10c..2a8354f 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -1,5 +1,5 @@ import axios from 'axios'; -import md5 from 'md5-hash'; +import cryptoMd5 from "crypto"; const irs_url = 'http://h2h.elangpixiu.com/api/h2h'; const irs_id = 'PT0005'; @@ -32,6 +32,7 @@ export const doTransaction = async ( } else if (supplier.code == 'Digiflazz') { if (typePaid == 'INQUIRY') { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; + const cryptoMd5 = require('crypto'); const options = { headers: { 'Content-Type': 'application/json' }, @@ -42,7 +43,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: md5(md5HashDigiflazz), + sign: cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex').toString(), testing: true, }; const res = await axios.post( @@ -54,6 +55,7 @@ export const doTransaction = async ( return res.data; } else if (typePaid == 'PAYMENT') { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; + const cryptoMd5 = require('crypto'); const options = { headers: { 'Content-Type': 'application/json' }, @@ -64,7 +66,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${billTrxId}`, - sign: md5(md5HashDigiflazz), + sign: cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex').toString(), testing: true, }; const res = await axios.post( @@ -76,7 +78,9 @@ export const doTransaction = async ( return res.data; } else { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; + const cryptoMd5 = require('crypto'); console.log('hashmd5', md5HashDigiflazz); + console.log('hashmd52', cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex').toString()); const options = { headers: {'Content-Type': 'application/json'}, }; @@ -85,7 +89,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: md5(md5HashDigiflazz), + sign: cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex').toString(), testing: true, }; const res = await axios.post( From 64ae88357f8997f6505391b2c83e23a0b0fa50fa Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 23:42:16 +0700 Subject: [PATCH 17/31] - log digiflazz supplier --- src/helper/irs-api.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 2a8354f..17f40d4 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -32,7 +32,7 @@ export const doTransaction = async ( } else if (supplier.code == 'Digiflazz') { if (typePaid == 'INQUIRY') { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - const cryptoMd5 = require('crypto'); + var md5Hash = require("md5-hash"); const options = { headers: { 'Content-Type': 'application/json' }, @@ -43,7 +43,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex').toString(), + sign: md5Hash.default(md5HashDigiflazz), testing: true, }; const res = await axios.post( @@ -55,7 +55,7 @@ export const doTransaction = async ( return res.data; } else if (typePaid == 'PAYMENT') { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - const cryptoMd5 = require('crypto'); + var md5Hash = require("md5-hash"); const options = { headers: { 'Content-Type': 'application/json' }, @@ -66,7 +66,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${billTrxId}`, - sign: cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex').toString(), + sign: md5Hash.default(md5HashDigiflazz), testing: true, }; const res = await axios.post( @@ -78,9 +78,8 @@ export const doTransaction = async ( return res.data; } else { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - const cryptoMd5 = require('crypto'); + var md5Hash = require("md5-hash"); console.log('hashmd5', md5HashDigiflazz); - console.log('hashmd52', cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex').toString()); const options = { headers: {'Content-Type': 'application/json'}, }; @@ -89,7 +88,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: cryptoMd5.createHash('md5').update(md5HashDigiflazz).digest('hex').toString(), + sign: md5Hash.default(md5HashDigiflazz), testing: true, }; const res = await axios.post( From b2edca7f392e57f1de60a12f51a83bacffd946b2 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 23:52:00 +0700 Subject: [PATCH 18/31] - log digiflazz supplier --- src/helper/irs-api.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 17f40d4..b81ff54 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -80,6 +80,7 @@ export const doTransaction = async ( const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; var md5Hash = require("md5-hash"); console.log('hashmd5', md5HashDigiflazz); + console.log('testmd5', md5Hash.default("String")); const options = { headers: {'Content-Type': 'application/json'}, }; From adabcaf98d54edc3d26b6b71d8e7b917a55fd47d Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 22 Feb 2023 23:57:18 +0700 Subject: [PATCH 19/31] - log digiflazz supplier --- src/helper/irs-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index b81ff54..87fe8fe 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -79,8 +79,8 @@ export const doTransaction = async ( } else { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; var md5Hash = require("md5-hash"); - console.log('hashmd5', md5HashDigiflazz); console.log('testmd5', md5Hash.default("String")); + console.log('hashmd5', md5HashDigiflazz); const options = { headers: {'Content-Type': 'application/json'}, }; From 21afb05910092a68fb4d9fbc03cae7b75adb18e6 Mon Sep 17 00:00:00 2001 From: Fadli Date: Thu, 23 Feb 2023 00:03:09 +0700 Subject: [PATCH 20/31] - log digiflazz supplier --- src/helper/irs-api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 87fe8fe..3ac716f 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -79,8 +79,8 @@ export const doTransaction = async ( } else { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; var md5Hash = require("md5-hash"); - console.log('testmd5', md5Hash.default("String")); - console.log('hashmd5', md5HashDigiflazz); + console.log('testmd5', md5HashDigiflazz); + console.log('hashmd5', md5Hash.default("String")); const options = { headers: {'Content-Type': 'application/json'}, }; From 7e83212df75fe14c665d3e1f56ec8ac1330506c1 Mon Sep 17 00:00:00 2001 From: Fadli Date: Thu, 23 Feb 2023 00:51:19 +0700 Subject: [PATCH 21/31] - log digiflazz supplier --- src/helper/irs-api.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 3ac716f..ae208de 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -43,7 +43,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: md5Hash.default(md5HashDigiflazz), + sign: md5Hash.default(`${supplier.irs_user}${supplier.irs_pass}${idtrx}`), testing: true, }; const res = await axios.post( @@ -66,7 +66,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${billTrxId}`, - sign: md5Hash.default(md5HashDigiflazz), + sign: md5Hash.default(`${supplier.irs_user}${supplier.irs_pass}${idtrx}`), testing: true, }; const res = await axios.post( @@ -89,7 +89,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: md5Hash.default(md5HashDigiflazz), + sign: md5Hash.default(`${supplier.irs_user}${supplier.irs_pass}${idtrx}`), testing: true, }; const res = await axios.post( From 8ebd2a6622f36c65b933d30ae779f75e92a4793b Mon Sep 17 00:00:00 2001 From: Fadli Date: Tue, 28 Feb 2023 14:38:49 +0700 Subject: [PATCH 22/31] - log digiflazz supplier --- src/helper/irs-api.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index ae208de..03b1cc1 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -135,7 +135,8 @@ export const doTransaction = async ( console.log('restranshemat', res); } catch (err) { - console.log('errtranshemat', err); + console.log('errtransaction', err); + console.log('errtransaction2', err.response.data); if (err.includes('Maaf Saldo anda tidak mencukupi')) { throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; From fe2b6aa264c3b9ccff51eeede47aa9ea4219aefb Mon Sep 17 00:00:00 2001 From: Fadli Date: Tue, 28 Feb 2023 15:13:31 +0700 Subject: [PATCH 23/31] - log digiflazz supplier --- src/helper/irs-api.ts | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 03b1cc1..0aa20a7 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -77,6 +77,31 @@ export const doTransaction = async ( return res.data; } else { + // const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; + // var md5Hash = require("md5-hash"); + // console.log('testmd5', md5HashDigiflazz); + // console.log('hashmd5', md5Hash.default("String")); + // const options = { + // headers: {'Content-Type': 'application/json'}, + // }; + // const data = { + // username: supplier.irs_user, + // customer_no: `${destination}`, + // buyer_sku_code: `${productCode}`, + // ref_id: `${idtrx}`, + // sign: md5Hash.default(`${supplier.irs_user}${supplier.irs_pass}${idtrx}`), + // testing: true, + // }; + // const res = await axios.post( + // `${supplier.url}/transaction`, + // data, + // options, + // ); + // + // console.log('resdigiflazz', res); + // return res.data; + + const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; var md5Hash = require("md5-hash"); console.log('testmd5', md5HashDigiflazz); @@ -85,15 +110,12 @@ export const doTransaction = async ( headers: {'Content-Type': 'application/json'}, }; const data = { + cmd: 'deposit', username: supplier.irs_user, - customer_no: `${destination}`, - buyer_sku_code: `${productCode}`, - ref_id: `${idtrx}`, - sign: md5Hash.default(`${supplier.irs_user}${supplier.irs_pass}${idtrx}`), - testing: true, + sign: md5Hash.default(`${supplier.irs_user}${supplier.irs_pass}depo`), }; const res = await axios.post( - `${supplier.url}/transaction`, + `${supplier.url}/cek-saldo`, data, options, ); From b1c2afe555ab2a3cdfb331d04ff8cde9e2bc13cc Mon Sep 17 00:00:00 2001 From: Fadli Date: Tue, 28 Feb 2023 16:11:11 +0700 Subject: [PATCH 24/31] - log digiflazz supplier --- src/helper/irs-api.ts | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 0aa20a7..373e765 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -77,45 +77,22 @@ export const doTransaction = async ( return res.data; } else { - // const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - // var md5Hash = require("md5-hash"); - // console.log('testmd5', md5HashDigiflazz); - // console.log('hashmd5', md5Hash.default("String")); - // const options = { - // headers: {'Content-Type': 'application/json'}, - // }; - // const data = { - // username: supplier.irs_user, - // customer_no: `${destination}`, - // buyer_sku_code: `${productCode}`, - // ref_id: `${idtrx}`, - // sign: md5Hash.default(`${supplier.irs_user}${supplier.irs_pass}${idtrx}`), - // testing: true, - // }; - // const res = await axios.post( - // `${supplier.url}/transaction`, - // data, - // options, - // ); - // - // console.log('resdigiflazz', res); - // return res.data; - - const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; var md5Hash = require("md5-hash"); console.log('testmd5', md5HashDigiflazz); - console.log('hashmd5', md5Hash.default("String")); const options = { headers: {'Content-Type': 'application/json'}, }; const data = { - cmd: 'deposit', username: supplier.irs_user, - sign: md5Hash.default(`${supplier.irs_user}${supplier.irs_pass}depo`), + customer_no: `${destination}`, + buyer_sku_code: `${productCode}`, + ref_id: `${idtrx}`, + sign: md5Hash.default(md5HashDigiflazz), + testing: true, }; const res = await axios.post( - `${supplier.url}/cek-saldo`, + `${supplier.url}/transaction`, data, options, ); From 4ce15f7499d62dfbe29261da671f6e643d333e97 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 1 Mar 2023 01:33:22 +0700 Subject: [PATCH 25/31] - push digiflazz supplier add md5 lib --- package-lock.json | 11 +++++++++++ package.json | 1 + src/helper/irs-api.ts | 13 ++++++------- yarn.lock | 5 +++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7c7b60b..541d78a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "@nestjs/typeorm": "^8.0.2", "axios": "^0.24.0", "bluebird": "^3.7.2", + "blueimp-md5": "^2.19.0", "class-transformer": "^0.4.0", "class-validator": "^0.13.1", "crypto": "^1.0.1", @@ -3105,6 +3106,11 @@ "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" }, + "node_modules/blueimp-md5": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz", + "integrity": "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==" + }, "node_modules/body-parser": { "version": "1.19.0", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", @@ -13028,6 +13034,11 @@ "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" }, + "blueimp-md5": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz", + "integrity": "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==" + }, "body-parser": { "version": "1.19.0", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", diff --git a/package.json b/package.json index de09715..ea2ed8f 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "@nestjs/typeorm": "^8.0.2", "axios": "^0.24.0", "bluebird": "^3.7.2", + "blueimp-md5": "^2.19.0", "class-transformer": "^0.4.0", "class-validator": "^0.13.1", "crypto": "^1.0.1", diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 373e765..59ebec3 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -1,5 +1,4 @@ import axios from 'axios'; -import cryptoMd5 from "crypto"; const irs_url = 'http://h2h.elangpixiu.com/api/h2h'; const irs_id = 'PT0005'; @@ -32,7 +31,7 @@ export const doTransaction = async ( } else if (supplier.code == 'Digiflazz') { if (typePaid == 'INQUIRY') { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - var md5Hash = require("md5-hash"); + const md5Hash = require("blueimp-md5"); const options = { headers: { 'Content-Type': 'application/json' }, @@ -43,7 +42,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: md5Hash.default(`${supplier.irs_user}${supplier.irs_pass}${idtrx}`), + sign: md5Hash(md5HashDigiflazz), testing: true, }; const res = await axios.post( @@ -55,7 +54,7 @@ export const doTransaction = async ( return res.data; } else if (typePaid == 'PAYMENT') { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - var md5Hash = require("md5-hash"); + const md5Hash = require("blueimp-md5"); const options = { headers: { 'Content-Type': 'application/json' }, @@ -66,7 +65,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${billTrxId}`, - sign: md5Hash.default(`${supplier.irs_user}${supplier.irs_pass}${idtrx}`), + sign: md5Hash(md5HashDigiflazz), testing: true, }; const res = await axios.post( @@ -78,7 +77,7 @@ export const doTransaction = async ( return res.data; } else { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; - var md5Hash = require("md5-hash"); + const md5Hash = require("blueimp-md5"); console.log('testmd5', md5HashDigiflazz); const options = { headers: {'Content-Type': 'application/json'}, @@ -88,7 +87,7 @@ export const doTransaction = async ( customer_no: `${destination}`, buyer_sku_code: `${productCode}`, ref_id: `${idtrx}`, - sign: md5Hash.default(md5HashDigiflazz), + sign: md5Hash(md5HashDigiflazz), testing: true, }; const res = await axios.post( diff --git a/yarn.lock b/yarn.lock index cf4f6a8..f70b82a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1765,6 +1765,11 @@ "resolved" "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz" "version" "3.4.7" +"blueimp-md5@^2.19.0": + "integrity" "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==" + "resolved" "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz" + "version" "2.19.0" + "body-parser@1.19.0": "integrity" "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==" "resolved" "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz" From fd8c50a01c98089f8a29d0b6e5831ad6758065c5 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 1 Mar 2023 02:04:58 +0700 Subject: [PATCH 26/31] - push digiflazz supplier add md5 lib --- src/helper/irs-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 59ebec3..5248901 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -97,7 +97,7 @@ export const doTransaction = async ( ); console.log('resdigiflazz', res); - return res.data; + return res.data.data; } } else if (supplier.code == 'Hemat') { if (authorization != '') { From 4df19347bb6c5ff085cb4cbd16451082aea8fd4f Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 1 Mar 2023 02:11:56 +0700 Subject: [PATCH 27/31] - push digiflazz supplier add md5 lib --- src/transaction/transaction.service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 2a51b5e..06b9ad0 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -769,10 +769,9 @@ export class TransactionService { transactionData.partner_trx_id = orderTransactionDto.trx_id; transactionData.supplier_trx_id = trxId; transactionData.check_bill = orderTransactionDto.bill_trx_id; - transactionData.balance_remaining = - coaAccount.amount - product_price.mark_up_price - costInventory; if (!hitSupplier.success) { + transactionData.balance_remaining = coaAccount.amount; transactionData.status = statusTransaction.FAILED; status = statusTransaction[transactionData.status]; await this.transactionRepository.insert(transactionData); @@ -784,6 +783,8 @@ export class TransactionService { HttpStatus.INTERNAL_SERVER_ERROR, ); } else { + transactionData.balance_remaining = + coaAccount.amount - product_price.mark_up_price - costInventory; if ( hitSupplier.sn != null || hitSupplier.sn != '' || From b31e36063368b38c0c16c68b5ed87751b6353f6c Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 1 Mar 2023 02:29:00 +0700 Subject: [PATCH 28/31] - fix digiflazz postpaid - fix digiflazz when receiving response --- src/helper/irs-api.ts | 4 ++-- src/transaction/transaction.service.ts | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 5248901..b5e8efa 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -51,7 +51,7 @@ export const doTransaction = async ( options, ); - return res.data; + return res.data.data; } else if (typePaid == 'PAYMENT') { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; const md5Hash = require("blueimp-md5"); @@ -74,7 +74,7 @@ export const doTransaction = async ( options, ); - return res.data; + return res.data.data; } else { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; const md5Hash = require("blueimp-md5"); diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 06b9ad0..bcb57a2 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -785,16 +785,12 @@ export class TransactionService { } else { transactionData.balance_remaining = coaAccount.amount - product_price.mark_up_price - costInventory; - if ( - hitSupplier.sn != null || - hitSupplier.sn != '' || - hitSupplier.sn != undefined - ) { - transactionData.seri_number = hitSupplier.sn; - transactionData.status = statusTransaction.SUCCESS; + if (hitSupplier.sn == '') { + transactionData.status = statusTransaction.PENDING; status = statusTransaction[transactionData.status]; } else { - transactionData.status = statusTransaction.PENDING; + transactionData.seri_number = hitSupplier.sn; + transactionData.status = statusTransaction.SUCCESS; status = statusTransaction[transactionData.status]; } } From 7d519f0510d1ef8a8b7016d67696fc57e2142791 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 1 Mar 2023 02:45:17 +0700 Subject: [PATCH 29/31] - fix digiflazz when receiving response and callback --- src/transaction/ppob_callback.controller.ts | 5 ++--- src/transaction/transaction.service.ts | 13 +++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/transaction/ppob_callback.controller.ts b/src/transaction/ppob_callback.controller.ts index 95fd0dc..3a91318 100644 --- a/src/transaction/ppob_callback.controller.ts +++ b/src/transaction/ppob_callback.controller.ts @@ -157,9 +157,8 @@ export class PpobCallbackController { @Post('/digiflazz') async getDigiflazz(@Req() request: FastifyRequest) { const response = request.body; - console.log('responsehemat', response); - console.log('responsehemat2', request.body); - if (response['msg'] != 'Transaksi Sukses') { + console.log('responsedigiflazz', response); + if (response['data']['message'] != 'Transaksi Sukses') { //TODO: UPDATE GAGAL await this.transactionService.checkCallbackOrderFailed( response['data']['ref_id'], diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index bcb57a2..a858600 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -690,6 +690,7 @@ export class TransactionService { if (product.type == 'prepaid') { newHitSupplier= { success: hitSupplier.status.includes('Pending') || hitSupplier.status.includes('Sukses'), + sn: hitSupplier.sn, harga: hitSupplier.price, msg: hitSupplier.message, }; @@ -785,13 +786,17 @@ export class TransactionService { } else { transactionData.balance_remaining = coaAccount.amount - product_price.mark_up_price - costInventory; - if (hitSupplier.sn == '') { - transactionData.status = statusTransaction.PENDING; - status = statusTransaction[transactionData.status]; - } else { + if ( + hitSupplier.sn != null || + hitSupplier.sn != '' || + hitSupplier.sn != undefined + ) { transactionData.seri_number = hitSupplier.sn; transactionData.status = statusTransaction.SUCCESS; status = statusTransaction[transactionData.status]; + } else { + transactionData.status = statusTransaction.PENDING; + status = statusTransaction[transactionData.status]; } } From 7e79075c1d98088b3bfb92ad05fc8e1514d7b18b Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 1 Mar 2023 02:51:00 +0700 Subject: [PATCH 30/31] - log digiflazz when receiving response --- src/transaction/transaction.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index a858600..6c67b69 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -688,7 +688,7 @@ export class TransactionService { let newHitSupplier; if (product.type == 'prepaid') { - newHitSupplier= { + newHitSupplier = { success: hitSupplier.status.includes('Pending') || hitSupplier.status.includes('Sukses'), sn: hitSupplier.sn, harga: hitSupplier.price, @@ -786,6 +786,8 @@ export class TransactionService { } else { transactionData.balance_remaining = coaAccount.amount - product_price.mark_up_price - costInventory; + console.log('hitsupplierstatus', hitSupplier.success) + console.log('hitsuppliersn', hitSupplier.sn) if ( hitSupplier.sn != null || hitSupplier.sn != '' || From c06ca8f2c0dbb126e2f0139737ba23b2b80fc8e9 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 1 Mar 2023 02:55:20 +0700 Subject: [PATCH 31/31] - fix digiflazz when receiving response --- src/transaction/transaction.service.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 6c67b69..a68de7b 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -786,18 +786,16 @@ export class TransactionService { } else { transactionData.balance_remaining = coaAccount.amount - product_price.mark_up_price - costInventory; - console.log('hitsupplierstatus', hitSupplier.success) - console.log('hitsuppliersn', hitSupplier.sn) if ( - hitSupplier.sn != null || - hitSupplier.sn != '' || - hitSupplier.sn != undefined + hitSupplier.sn == null || + hitSupplier.sn == '' || + hitSupplier.sn == undefined ) { - transactionData.seri_number = hitSupplier.sn; - transactionData.status = statusTransaction.SUCCESS; + transactionData.status = statusTransaction.PENDING; status = statusTransaction[transactionData.status]; } else { - transactionData.status = statusTransaction.PENDING; + transactionData.seri_number = hitSupplier.sn; + transactionData.status = statusTransaction.SUCCESS; status = statusTransaction[transactionData.status]; } }