From cbd65eb6c8243868635df816e39c10092761b5ea Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Fri, 21 Apr 2023 11:20:56 +0700 Subject: [PATCH 1/8] - push logs --- 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 0349e3e..96167d9 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -126,8 +126,8 @@ export const doTransaction = async ( 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}`, ); - return res.data; console.log('restranshemat', res); + return res.data; } catch (e) { throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; } From de3ce1adab37d770bb377164417ea6a950781591 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Fri, 21 Apr 2023 11:26:59 +0700 Subject: [PATCH 2/8] - push logs --- src/helper/irs-api.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 96167d9..125507f 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -122,15 +122,20 @@ export const doTransaction = async ( } } - try { 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}`, - ); - console.log('restranshemat', res); - return res.data; - } catch (e) { - throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; - } + ) + .catch((error) => { + if (error.response) { + throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; + } else if (error.request) { + throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; + } else { + throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; + } + }); + + return res.data; } catch (err) { console.log('errtransaction', err); From 0fb2e1d6fa0141c6f3a474c9ec94087cf027ace7 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Fri, 21 Apr 2023 11:31:53 +0700 Subject: [PATCH 3/8] - push logs --- src/helper/irs-api.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 125507f..9408695 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -122,20 +122,15 @@ export const doTransaction = async ( } } + try { 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}`, - ) - .catch((error) => { - if (error.response) { - throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; - } else if (error.request) { - throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; - } else { - throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; - } - }); - - return res.data; + ); + console.log('restransini', res); + return res.data; + } catch (e) { + throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; + } } catch (err) { console.log('errtransaction', err); From 4570790514304e6c9b96286e906d5101a129ddc4 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Fri, 21 Apr 2023 11:37:40 +0700 Subject: [PATCH 4/8] - push logs --- 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 9408695..f9fd4e5 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -127,6 +127,7 @@ export const doTransaction = async ( `${supplier.url}?memberID=${supplier.irs_id}&pin=${supplier.irs_pin}&password=${supplier.irs_pass}&product=${productCode}&dest=${destination}&counter=1&refID=${idtrx}`, ); console.log('restransini', res); + console.log('restransini1', res.status); return res.data; } catch (e) { throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; From c6e0e4460842218c8e16f9cf7b0861e629e36476 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Fri, 21 Apr 2023 11:43:49 +0700 Subject: [PATCH 5/8] - fix error metro --- src/helper/irs-api.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index f9fd4e5..002c0b1 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -128,7 +128,11 @@ export const doTransaction = async ( ); console.log('restransini', res); console.log('restransini1', res.status); - return res.data; + if (res.data.includes('Saldo anda tidak mencukupi')) { + throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; + } else { + return res.data; + } } catch (e) { throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; } From 704fad08954a61eda0a8c66ca5d321bf657a6fdc Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Fri, 21 Apr 2023 12:01:24 +0700 Subject: [PATCH 6/8] - fix error metro --- src/helper/irs-api.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 002c0b1..b4e07a1 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -1,4 +1,5 @@ import axios from 'axios'; +import {NotFoundException} from "@nestjs/common"; const irs_url = 'http://h2h.elangpixiu.com/api/h2h'; const irs_id = 'PT0005'; @@ -140,6 +141,8 @@ export const doTransaction = async ( } catch (err) { console.log('errtransaction', err); console.log('errtransaction2', err.response.data); - throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; + throw new NotFoundException( + 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali', + ); } }; From 5cf8c7661cc027971b69df0711bff3c115fce5f8 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Fri, 21 Apr 2023 12:07:57 +0700 Subject: [PATCH 7/8] - fix error metro --- src/helper/irs-api.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index b4e07a1..8d23673 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -1,5 +1,5 @@ import axios from 'axios'; -import {NotFoundException} from "@nestjs/common"; +import {HttpException, HttpStatus, NotFoundException} from "@nestjs/common"; const irs_url = 'http://h2h.elangpixiu.com/api/h2h'; const irs_id = 'PT0005'; @@ -141,8 +141,13 @@ export const doTransaction = async ( } catch (err) { console.log('errtransaction', err); console.log('errtransaction2', err.response.data); - throw new NotFoundException( - 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali', + + throw new HttpException( + { + statusCode: HttpStatus.INTERNAL_SERVER_ERROR, + error: 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali', + }, + HttpStatus.INTERNAL_SERVER_ERROR, ); } }; From 8943d8b8acca7586db69f658fb3f63f147338753 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Fri, 21 Apr 2023 12:12:10 +0700 Subject: [PATCH 8/8] - fix error metro --- src/helper/irs-api.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 8d23673..1189aba 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -130,12 +130,24 @@ export const doTransaction = async ( console.log('restransini', res); console.log('restransini1', res.status); if (res.data.includes('Saldo anda tidak mencukupi')) { - throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; + throw new HttpException( + { + statusCode: HttpStatus.INTERNAL_SERVER_ERROR, + error: 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali', + }, + HttpStatus.INTERNAL_SERVER_ERROR, + ); } else { return res.data; } } catch (e) { - throw 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali'; + throw new HttpException( + { + statusCode: HttpStatus.INTERNAL_SERVER_ERROR, + error: 'maaf saat ini transaksi sedang tidak bisa diproses, silahkan hubungi WND Solutions untuk bisa di proses kembali', + }, + HttpStatus.INTERNAL_SERVER_ERROR, + ); } } catch (err) {