@traxionpay/cbsmiddleware 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/banking/dto/account-transfer.dto.d.ts +1 -1
- package/dist/banking/dto/account-transfer.dto.js +2 -2
- package/dist/banking/dto/account.dto.d.ts +1 -1
- package/dist/banking/dto/account.dto.js +2 -2
- package/dist/banking/dto/fetch-bank-balance.dto.d.ts +1 -1
- package/dist/banking/dto/fetch-bank-balance.dto.d.ts.map +1 -1
- package/dist/banking/dto/fetch-bank-balance.dto.js +2 -2
- package/dist/banking/dto/fetch-bank-balance.dto.js.map +1 -1
- package/dist/banking/dto/transaction-history.dto.d.ts +1 -1
- package/dist/banking/dto/transaction-history.dto.js +2 -2
- package/dist/banking/services/ASPAC.service.d.ts +8 -1
- package/dist/banking/services/ASPAC.service.d.ts.map +1 -1
- package/dist/banking/services/ASPAC.service.js +208 -76
- package/dist/banking/services/ASPAC.service.js.map +1 -1
- package/dist/banking/services/WelcomeBank.service.d.ts +6 -1
- package/dist/banking/services/WelcomeBank.service.d.ts.map +1 -1
- package/dist/banking/services/WelcomeBank.service.js +317 -127
- package/dist/banking/services/WelcomeBank.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/banking/dto/account-transfer.dto.ts +2 -2
- package/src/banking/dto/account.dto.ts +2 -2
- package/src/banking/dto/fetch-bank-balance.dto.ts +4 -3
- package/src/banking/dto/transaction-history.dto.ts +2 -2
- package/src/banking/services/ASPAC.service.ts +256 -79
- package/src/banking/services/WelcomeBank.service.ts +399 -158
|
@@ -123,8 +123,8 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
123
123
|
if (!refreshToken) {
|
|
124
124
|
throw new common_1.HttpException({
|
|
125
125
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
126
|
-
code:
|
|
127
|
-
message: '
|
|
126
|
+
code: 400020205,
|
|
127
|
+
message: 'Refresh token is required.',
|
|
128
128
|
data: { refreshToken }
|
|
129
129
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
130
130
|
}
|
|
@@ -144,6 +144,14 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
144
144
|
httpsAgent,
|
|
145
145
|
});
|
|
146
146
|
this.logger.log({ responseData: response }, 'Welcome Bank Refresh Token Successful');
|
|
147
|
+
if (response.data.message === "Unable to Process this request. Please check your payload.") {
|
|
148
|
+
throw new common_1.HttpException({
|
|
149
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
150
|
+
code: 400020206,
|
|
151
|
+
message: 'Invalid refresh token.',
|
|
152
|
+
data: { refreshToken }
|
|
153
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
154
|
+
}
|
|
147
155
|
return {
|
|
148
156
|
success: true,
|
|
149
157
|
...response.data,
|
|
@@ -167,15 +175,15 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
167
175
|
throw new common_1.HttpException({
|
|
168
176
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
169
177
|
code: 400020304,
|
|
170
|
-
message: '
|
|
178
|
+
message: 'Account number is required.',
|
|
171
179
|
data: { accountDto }
|
|
172
180
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
173
181
|
}
|
|
174
182
|
if (!accountType) {
|
|
175
183
|
throw new common_1.HttpException({
|
|
176
184
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
177
|
-
code:
|
|
178
|
-
message: '
|
|
185
|
+
code: 400020306,
|
|
186
|
+
message: 'Account type is required.',
|
|
179
187
|
data: { accountDto }
|
|
180
188
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
181
189
|
}
|
|
@@ -183,7 +191,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
183
191
|
throw new common_1.HttpException({
|
|
184
192
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
185
193
|
code: 4000203009,
|
|
186
|
-
message: 'Mobile
|
|
194
|
+
message: 'Mobile number is required.',
|
|
187
195
|
data: { accountDto }
|
|
188
196
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
189
197
|
}
|
|
@@ -194,6 +202,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
194
202
|
const totpPrevious = this.generateTOTP(timeInSeconds - 30);
|
|
195
203
|
this.logger.log(`TOTP GENERATED FOR WELCOMEBANK LINK ACCOUNT: ${totp}, For Time stamp: ${isoTimestamp}`);
|
|
196
204
|
this.logger.log(`TOTP GENERATED FOR PREVIOUS TIME: ${totpPrevious}`);
|
|
205
|
+
let responseData;
|
|
197
206
|
try {
|
|
198
207
|
const headers = {
|
|
199
208
|
'Authorization': `Bearer ${token}`,
|
|
@@ -204,13 +213,17 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
204
213
|
rejectUnauthorized: false,
|
|
205
214
|
});
|
|
206
215
|
let response;
|
|
216
|
+
let formattedMobile = mobile;
|
|
217
|
+
if (mobile.startsWith("63") && mobile.length > 2) {
|
|
218
|
+
formattedMobile = "0" + mobile.slice(2);
|
|
219
|
+
}
|
|
207
220
|
if (String(this.config.WELCOMBANK_ENABLEENCRYPTION).toLowerCase() === 'true') {
|
|
208
221
|
let payload;
|
|
209
222
|
payload = {
|
|
210
223
|
"acc": account,
|
|
211
224
|
"br": branch,
|
|
212
225
|
"accType": accountType,
|
|
213
|
-
"mobile":
|
|
226
|
+
"mobile": formattedMobile
|
|
214
227
|
};
|
|
215
228
|
payload = this.encryptPayloadWithOTP(payload, totp);
|
|
216
229
|
const encodedPayload = encodeURIComponent(payload);
|
|
@@ -220,43 +233,69 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
220
233
|
});
|
|
221
234
|
}
|
|
222
235
|
else {
|
|
223
|
-
response = await axios_1.default.get(`${this.config.WELCOMEBANK_URL}:${this.config.WELCOMEBANK_PORT}/api/linkaccount?acc=${account}&br=${branch}&accType=${accountType}&mobile=${
|
|
236
|
+
response = await axios_1.default.get(`${this.config.WELCOMEBANK_URL}:${this.config.WELCOMEBANK_PORT}/api/linkaccount?acc=${account}&br=${branch}&accType=${accountType}&mobile=${formattedMobile}`, {
|
|
224
237
|
headers: headers,
|
|
225
238
|
httpsAgent
|
|
226
239
|
});
|
|
227
240
|
}
|
|
228
|
-
|
|
229
|
-
this.logger.log({ responseData: response }, 'Welcome Bank Link Account Successful');
|
|
241
|
+
this.logger.log({ responseData: response.data }, 'Welcome Bank Link Account Successful');
|
|
230
242
|
if (String(this.config.WELCOMBANK_ENABLEENCRYPTION).toLowerCase() === 'true') {
|
|
231
|
-
const encryptedResponsePayload =
|
|
243
|
+
const encryptedResponsePayload = response.data.data;
|
|
232
244
|
if (!encryptedResponsePayload) {
|
|
233
245
|
throw new Error("Encrypted response expected but not found");
|
|
234
246
|
}
|
|
235
|
-
let decryptedResponse;
|
|
236
247
|
try {
|
|
237
|
-
|
|
248
|
+
responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totp);
|
|
238
249
|
}
|
|
239
250
|
catch (error) {
|
|
240
251
|
this.logger.warn("Decryption with current OTP failed, trying with previous OTP");
|
|
252
|
+
responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totpPrevious);
|
|
241
253
|
}
|
|
242
|
-
if (!decryptedResponse) {
|
|
243
|
-
decryptedResponse = this.decryptPayloadWithOTP(encryptedResponsePayload, totpPrevious);
|
|
244
|
-
}
|
|
245
|
-
return {
|
|
246
|
-
success: true,
|
|
247
|
-
data: decryptedResponse,
|
|
248
|
-
};
|
|
249
254
|
}
|
|
250
255
|
else {
|
|
251
|
-
|
|
252
|
-
success: true,
|
|
253
|
-
...responseData,
|
|
254
|
-
};
|
|
256
|
+
responseData = response.data;
|
|
255
257
|
}
|
|
256
258
|
}
|
|
257
259
|
catch (error) {
|
|
260
|
+
if (error.response.data.message === "Mobile number is not registered in the account.") {
|
|
261
|
+
throw new common_1.HttpException({
|
|
262
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
263
|
+
code: 400020307,
|
|
264
|
+
message: 'Mobile number is not registered in the account.',
|
|
265
|
+
data: { accountDto }
|
|
266
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
267
|
+
}
|
|
258
268
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
259
269
|
}
|
|
270
|
+
if (responseData.data.status === "99997") {
|
|
271
|
+
throw new common_1.HttpException({
|
|
272
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
273
|
+
code: 400020303,
|
|
274
|
+
message: 'Account not found',
|
|
275
|
+
data: { ...accountDto }
|
|
276
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
277
|
+
}
|
|
278
|
+
if (responseData.data.status === "00001") {
|
|
279
|
+
throw new common_1.HttpException({
|
|
280
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
281
|
+
code: 400020305,
|
|
282
|
+
message: 'Account type is not supported.',
|
|
283
|
+
data: { ...accountDto }
|
|
284
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
285
|
+
}
|
|
286
|
+
if (responseData.data.status === "00007") {
|
|
287
|
+
throw new common_1.HttpException({
|
|
288
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
289
|
+
code: 400020307,
|
|
290
|
+
message: 'Mobile number is not registered in the account.',
|
|
291
|
+
data: { ...accountDto }
|
|
292
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
293
|
+
}
|
|
294
|
+
this.logger.log(`Response Data WelcomeBank Link , ${responseData}`);
|
|
295
|
+
return {
|
|
296
|
+
success: true,
|
|
297
|
+
...responseData,
|
|
298
|
+
};
|
|
260
299
|
}
|
|
261
300
|
async validateOtp(validateOtp) {
|
|
262
301
|
const { token, account, branch, accountType, otp } = validateOtp;
|
|
@@ -272,7 +311,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
272
311
|
throw new common_1.HttpException({
|
|
273
312
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
274
313
|
code: 400020404,
|
|
275
|
-
message: '
|
|
314
|
+
message: 'Account number is required.',
|
|
276
315
|
data: { validateOtp }
|
|
277
316
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
278
317
|
}
|
|
@@ -280,7 +319,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
280
319
|
throw new common_1.HttpException({
|
|
281
320
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
282
321
|
code: 400020406,
|
|
283
|
-
message: '
|
|
322
|
+
message: 'Account type is required.',
|
|
284
323
|
data: { validateOtp }
|
|
285
324
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
286
325
|
}
|
|
@@ -288,7 +327,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
288
327
|
throw new common_1.HttpException({
|
|
289
328
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
290
329
|
code: 400020408,
|
|
291
|
-
message: '
|
|
330
|
+
message: 'OTP is required.',
|
|
292
331
|
data: { validateOtp }
|
|
293
332
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
294
333
|
}
|
|
@@ -299,6 +338,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
299
338
|
const totpPrevious = this.generateTOTP(timeInSeconds - 30);
|
|
300
339
|
this.logger.log(`TOTP GENERATED FOR WELCOME BANK VALIDATE OTP: ${totp}, For Time stamp: ${isoTimestamp}`);
|
|
301
340
|
this.logger.log(`TOTP GENERATED FOR PREVIOUS TIME: ${totpPrevious}`);
|
|
341
|
+
let responseData;
|
|
302
342
|
try {
|
|
303
343
|
const headers = {
|
|
304
344
|
'Authorization': `Bearer ${token}`,
|
|
@@ -322,38 +362,56 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
322
362
|
headers: headers,
|
|
323
363
|
httpsAgent
|
|
324
364
|
});
|
|
325
|
-
|
|
326
|
-
this.logger.log({ responseData: response }, 'Welcome Bank Validate OTP Successful');
|
|
365
|
+
this.logger.log({ responseData: response.data }, 'Welcome Bank Validate OTP Successful');
|
|
327
366
|
if (String(this.config.WELCOMBANK_ENABLEENCRYPTION).toLowerCase() === 'true') {
|
|
328
|
-
const encryptedResponsePayload =
|
|
367
|
+
const encryptedResponsePayload = response.data.data;
|
|
329
368
|
if (!encryptedResponsePayload) {
|
|
330
369
|
throw new Error("Encrypted response expected but not found");
|
|
331
370
|
}
|
|
332
|
-
let decryptedResponse;
|
|
333
371
|
try {
|
|
334
|
-
|
|
372
|
+
responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totp);
|
|
335
373
|
}
|
|
336
374
|
catch (error) {
|
|
337
375
|
this.logger.warn("Decryption with current OTP failed, trying with previous OTP");
|
|
376
|
+
responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totpPrevious);
|
|
338
377
|
}
|
|
339
|
-
if (!decryptedResponse) {
|
|
340
|
-
decryptedResponse = this.decryptPayloadWithOTP(encryptedResponsePayload, totpPrevious);
|
|
341
|
-
}
|
|
342
|
-
return {
|
|
343
|
-
success: true,
|
|
344
|
-
data: decryptedResponse,
|
|
345
|
-
};
|
|
346
378
|
}
|
|
347
379
|
else {
|
|
348
|
-
|
|
349
|
-
success: true,
|
|
350
|
-
...responseData,
|
|
351
|
-
};
|
|
380
|
+
responseData = response.data;
|
|
352
381
|
}
|
|
353
382
|
}
|
|
354
383
|
catch (error) {
|
|
355
384
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
356
385
|
}
|
|
386
|
+
if (responseData.data.status === "99997") {
|
|
387
|
+
throw new common_1.HttpException({
|
|
388
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
389
|
+
code: 400020403,
|
|
390
|
+
message: 'Account number is required.',
|
|
391
|
+
data: { ...validateOtp }
|
|
392
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
393
|
+
}
|
|
394
|
+
if (responseData.data.status === "00001") {
|
|
395
|
+
throw new common_1.HttpException({
|
|
396
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
397
|
+
code: 400020405,
|
|
398
|
+
message: 'Account type is not supported.',
|
|
399
|
+
data: { ...validateOtp }
|
|
400
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
401
|
+
}
|
|
402
|
+
if (responseData.data.status === "00005") {
|
|
403
|
+
throw new common_1.HttpException({
|
|
404
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
405
|
+
code: 400020407,
|
|
406
|
+
message: 'Invalid or expired OTP.',
|
|
407
|
+
data: { ...validateOtp }
|
|
408
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
409
|
+
}
|
|
410
|
+
this.logger.log(`Response Data WelcomeBank Validate , ${responseData}`);
|
|
411
|
+
return {
|
|
412
|
+
success: true,
|
|
413
|
+
...responseData,
|
|
414
|
+
};
|
|
357
415
|
}
|
|
358
416
|
async processBalanceTransaction(fetchBalanceDto) {
|
|
359
417
|
const { token, permissionKey, account, branch, accountType } = fetchBalanceDto;
|
|
@@ -367,17 +425,17 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
367
425
|
}
|
|
368
426
|
if (!permissionKey) {
|
|
369
427
|
throw new common_1.HttpException({
|
|
370
|
-
statusCode: common_1.HttpStatus.
|
|
428
|
+
statusCode: common_1.HttpStatus.FORBIDDEN,
|
|
371
429
|
code: 403020504,
|
|
372
|
-
message: '
|
|
430
|
+
message: 'Permission key is required.',
|
|
373
431
|
data: { fetchBalanceDto }
|
|
374
|
-
}, common_1.HttpStatus.
|
|
432
|
+
}, common_1.HttpStatus.FORBIDDEN);
|
|
375
433
|
}
|
|
376
434
|
if (!account) {
|
|
377
435
|
throw new common_1.HttpException({
|
|
378
436
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
379
437
|
code: 400020506,
|
|
380
|
-
message: '
|
|
438
|
+
message: 'Account number is required.',
|
|
381
439
|
data: { fetchBalanceDto }
|
|
382
440
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
383
441
|
}
|
|
@@ -385,7 +443,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
385
443
|
throw new common_1.HttpException({
|
|
386
444
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
387
445
|
code: 400020508,
|
|
388
|
-
message: '
|
|
446
|
+
message: 'Account type is required.',
|
|
389
447
|
data: { fetchBalanceDto }
|
|
390
448
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
391
449
|
}
|
|
@@ -396,6 +454,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
396
454
|
const totpPrevious = this.generateTOTP(timeInSeconds - 30);
|
|
397
455
|
this.logger.log(`TOTP GENERATED FOR WELCOME BANK BALANCE INQUIRY: ${totp}, For Time stamp: ${isoTimestamp}`);
|
|
398
456
|
this.logger.log(`TOTP GENERATED FOR PREVIOUS TIME: ${totpPrevious}`);
|
|
457
|
+
let responseData;
|
|
399
458
|
try {
|
|
400
459
|
const headers = {
|
|
401
460
|
'Authorization': `Bearer ${token}`,
|
|
@@ -419,38 +478,56 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
419
478
|
headers: headers,
|
|
420
479
|
httpsAgent
|
|
421
480
|
});
|
|
422
|
-
|
|
423
|
-
this.logger.log({ responseData: response }, 'Welcome Bank Balance Inquiry Successful');
|
|
481
|
+
this.logger.log({ responseData: response.data }, 'Welcome Bank Balance Inquiry Successful');
|
|
424
482
|
if (String(this.config.WELCOMBANK_ENABLEENCRYPTION).toLowerCase() === 'true') {
|
|
425
|
-
const encryptedResponsePayload =
|
|
483
|
+
const encryptedResponsePayload = response.data.data;
|
|
426
484
|
if (!encryptedResponsePayload) {
|
|
427
485
|
throw new Error("Encrypted response expected but not found");
|
|
428
486
|
}
|
|
429
|
-
let decryptedResponse;
|
|
430
487
|
try {
|
|
431
|
-
|
|
488
|
+
responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totp);
|
|
432
489
|
}
|
|
433
490
|
catch (error) {
|
|
434
491
|
this.logger.warn("Decryption with current OTP failed, trying with previous OTP");
|
|
492
|
+
responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totpPrevious);
|
|
435
493
|
}
|
|
436
|
-
if (!decryptedResponse) {
|
|
437
|
-
decryptedResponse = this.decryptPayloadWithOTP(encryptedResponsePayload, totpPrevious);
|
|
438
|
-
}
|
|
439
|
-
return {
|
|
440
|
-
success: true,
|
|
441
|
-
data: decryptedResponse,
|
|
442
|
-
};
|
|
443
494
|
}
|
|
444
495
|
else {
|
|
445
|
-
|
|
446
|
-
success: true,
|
|
447
|
-
...responseData,
|
|
448
|
-
};
|
|
496
|
+
responseData = response.data;
|
|
449
497
|
}
|
|
450
498
|
}
|
|
451
499
|
catch (error) {
|
|
452
500
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
453
501
|
}
|
|
502
|
+
if (responseData.data.status === "99999") {
|
|
503
|
+
throw new common_1.HttpException({
|
|
504
|
+
statusCode: common_1.HttpStatus.FORBIDDEN,
|
|
505
|
+
code: 403020503,
|
|
506
|
+
message: 'Invalid permission key.',
|
|
507
|
+
data: { ...fetchBalanceDto }
|
|
508
|
+
}, common_1.HttpStatus.FORBIDDEN);
|
|
509
|
+
}
|
|
510
|
+
if (responseData.data.status === "99997") {
|
|
511
|
+
throw new common_1.HttpException({
|
|
512
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
513
|
+
code: 400020505,
|
|
514
|
+
message: 'Account not found.',
|
|
515
|
+
data: { ...fetchBalanceDto }
|
|
516
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
517
|
+
}
|
|
518
|
+
if (responseData.data.status === "00001") {
|
|
519
|
+
throw new common_1.HttpException({
|
|
520
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
521
|
+
code: 400020507,
|
|
522
|
+
message: 'Account type is not supported.',
|
|
523
|
+
data: { ...fetchBalanceDto }
|
|
524
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
525
|
+
}
|
|
526
|
+
this.logger.log(`Response Data WelcomeBank Balance Inquiry , ${responseData}`);
|
|
527
|
+
return {
|
|
528
|
+
success: true,
|
|
529
|
+
...responseData,
|
|
530
|
+
};
|
|
454
531
|
}
|
|
455
532
|
async accountCashIn(accountTransferDto) {
|
|
456
533
|
const { token, permissionKey, sourceAccount, sourceBranch, sourceAccountType, destinationAccount, destinationBranch, destinationAccountType, amount } = accountTransferDto;
|
|
@@ -466,7 +543,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
466
543
|
throw new common_1.HttpException({
|
|
467
544
|
statusCode: common_1.HttpStatus.FORBIDDEN,
|
|
468
545
|
code: 403020604,
|
|
469
|
-
message: '
|
|
546
|
+
message: 'Permission key is required.',
|
|
470
547
|
data: { accountTransferDto }
|
|
471
548
|
}, common_1.HttpStatus.FORBIDDEN);
|
|
472
549
|
}
|
|
@@ -474,7 +551,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
474
551
|
throw new common_1.HttpException({
|
|
475
552
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
476
553
|
code: 400020606,
|
|
477
|
-
message: '
|
|
554
|
+
message: 'Source account number is required.',
|
|
478
555
|
data: { accountTransferDto }
|
|
479
556
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
480
557
|
}
|
|
@@ -482,7 +559,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
482
559
|
throw new common_1.HttpException({
|
|
483
560
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
484
561
|
code: 400020608,
|
|
485
|
-
message: '
|
|
562
|
+
message: 'Source account type is required.',
|
|
486
563
|
data: { accountTransferDto }
|
|
487
564
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
488
565
|
}
|
|
@@ -490,7 +567,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
490
567
|
throw new common_1.HttpException({
|
|
491
568
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
492
569
|
code: 400020610,
|
|
493
|
-
message: '
|
|
570
|
+
message: 'Destination account number is required.',
|
|
494
571
|
data: { accountTransferDto }
|
|
495
572
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
496
573
|
}
|
|
@@ -498,7 +575,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
498
575
|
throw new common_1.HttpException({
|
|
499
576
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
500
577
|
code: 400020612,
|
|
501
|
-
message: '
|
|
578
|
+
message: 'Destination account type is required.',
|
|
502
579
|
data: { accountTransferDto }
|
|
503
580
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
504
581
|
}
|
|
@@ -506,7 +583,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
506
583
|
throw new common_1.HttpException({
|
|
507
584
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
508
585
|
code: 400020613,
|
|
509
|
-
message: '
|
|
586
|
+
message: 'Transaction amount is required.',
|
|
510
587
|
data: { accountTransferDto }
|
|
511
588
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
512
589
|
}
|
|
@@ -517,6 +594,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
517
594
|
const totpPrevious = this.generateTOTP(timeInSeconds - 30);
|
|
518
595
|
this.logger.log(`TOTP GENERATED FOR WELCOME BANK CASH IN: ${totp}, For Time stamp: ${isoTimestamp}`);
|
|
519
596
|
this.logger.log(`TOTP GENERATED FOR PREVIOUS TIME: ${totpPrevious}`);
|
|
597
|
+
let responseData;
|
|
520
598
|
try {
|
|
521
599
|
const headers = {
|
|
522
600
|
'Authorization': `Bearer ${token}`,
|
|
@@ -544,38 +622,64 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
544
622
|
headers: headers,
|
|
545
623
|
httpsAgent
|
|
546
624
|
});
|
|
547
|
-
|
|
548
|
-
this.logger.log({ responseData: response }, 'Welcome Bank Cash In Successful');
|
|
625
|
+
this.logger.log({ responseData: response.data }, 'Welcome Bank Cash In Successful');
|
|
549
626
|
if (String(this.config.WELCOMBANK_ENABLEENCRYPTION).toLowerCase() === 'true') {
|
|
550
|
-
const encryptedResponsePayload =
|
|
627
|
+
const encryptedResponsePayload = response.data.data;
|
|
551
628
|
if (!encryptedResponsePayload) {
|
|
552
629
|
throw new Error("Encrypted response expected but not found");
|
|
553
630
|
}
|
|
554
|
-
let decryptedResponse;
|
|
555
631
|
try {
|
|
556
|
-
|
|
632
|
+
responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totp);
|
|
557
633
|
}
|
|
558
634
|
catch (error) {
|
|
559
635
|
this.logger.warn("Decryption with current OTP failed, trying with previous OTP");
|
|
636
|
+
responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totpPrevious);
|
|
560
637
|
}
|
|
561
|
-
if (!decryptedResponse) {
|
|
562
|
-
decryptedResponse = this.decryptPayloadWithOTP(encryptedResponsePayload, totpPrevious);
|
|
563
|
-
}
|
|
564
|
-
return {
|
|
565
|
-
success: true,
|
|
566
|
-
data: decryptedResponse,
|
|
567
|
-
};
|
|
568
638
|
}
|
|
569
639
|
else {
|
|
570
|
-
|
|
571
|
-
success: true,
|
|
572
|
-
...responseData,
|
|
573
|
-
};
|
|
640
|
+
responseData = response.data;
|
|
574
641
|
}
|
|
575
642
|
}
|
|
576
643
|
catch (error) {
|
|
577
644
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
578
645
|
}
|
|
646
|
+
if (responseData.data.status === "99999") {
|
|
647
|
+
throw new common_1.HttpException({
|
|
648
|
+
statusCode: common_1.HttpStatus.FORBIDDEN,
|
|
649
|
+
code: 403020603,
|
|
650
|
+
message: 'Invalid permission key.',
|
|
651
|
+
data: { ...accountTransferDto }
|
|
652
|
+
}, common_1.HttpStatus.FORBIDDEN);
|
|
653
|
+
}
|
|
654
|
+
if (responseData.data.status === "99997") {
|
|
655
|
+
throw new common_1.HttpException({
|
|
656
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
657
|
+
code: 400020605,
|
|
658
|
+
message: 'Account not found.',
|
|
659
|
+
data: { ...accountTransferDto }
|
|
660
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
661
|
+
}
|
|
662
|
+
if (responseData.data.status === "00001") {
|
|
663
|
+
throw new common_1.HttpException({
|
|
664
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
665
|
+
code: 400020607,
|
|
666
|
+
message: 'Account type is not supported.',
|
|
667
|
+
data: { ...accountTransferDto }
|
|
668
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
669
|
+
}
|
|
670
|
+
if (responseData.data.status === "00004") {
|
|
671
|
+
throw new common_1.HttpException({
|
|
672
|
+
statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
|
|
673
|
+
code: 422020614,
|
|
674
|
+
message: 'Invalid transaction amount value.',
|
|
675
|
+
data: { ...accountTransferDto }
|
|
676
|
+
}, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
677
|
+
}
|
|
678
|
+
this.logger.log(`Response Data WelcomeBank Cashin , ${responseData}`);
|
|
679
|
+
return {
|
|
680
|
+
success: true,
|
|
681
|
+
...responseData,
|
|
682
|
+
};
|
|
579
683
|
}
|
|
580
684
|
async accountDeposit(accountTransferDto) {
|
|
581
685
|
const { token, permissionKey, sourceAccount, sourceBranch, sourceAccountType, destinationAccount, destinationBranch, destinationAccountType, amount } = accountTransferDto;
|
|
@@ -591,7 +695,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
591
695
|
throw new common_1.HttpException({
|
|
592
696
|
statusCode: common_1.HttpStatus.FORBIDDEN,
|
|
593
697
|
code: 403020704,
|
|
594
|
-
message: '
|
|
698
|
+
message: 'Permission key is required.',
|
|
595
699
|
data: { accountTransferDto }
|
|
596
700
|
}, common_1.HttpStatus.FORBIDDEN);
|
|
597
701
|
}
|
|
@@ -599,7 +703,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
599
703
|
throw new common_1.HttpException({
|
|
600
704
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
601
705
|
code: 400020706,
|
|
602
|
-
message: '
|
|
706
|
+
message: 'Source account number is required',
|
|
603
707
|
data: { accountTransferDto }
|
|
604
708
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
605
709
|
}
|
|
@@ -607,7 +711,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
607
711
|
throw new common_1.HttpException({
|
|
608
712
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
609
713
|
code: 400020708,
|
|
610
|
-
message: '
|
|
714
|
+
message: 'Source account type is required.',
|
|
611
715
|
data: { accountTransferDto }
|
|
612
716
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
613
717
|
}
|
|
@@ -615,7 +719,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
615
719
|
throw new common_1.HttpException({
|
|
616
720
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
617
721
|
code: 400020710,
|
|
618
|
-
message: '
|
|
722
|
+
message: 'Destination account number is required',
|
|
619
723
|
data: { accountTransferDto }
|
|
620
724
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
621
725
|
}
|
|
@@ -631,7 +735,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
631
735
|
throw new common_1.HttpException({
|
|
632
736
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
633
737
|
code: 400020713,
|
|
634
|
-
message: '
|
|
738
|
+
message: 'Transaction amount is required.',
|
|
635
739
|
data: { accountTransferDto }
|
|
636
740
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
637
741
|
}
|
|
@@ -642,6 +746,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
642
746
|
const totpPrevious = this.generateTOTP(timeInSeconds - 30);
|
|
643
747
|
this.logger.log(`TOTP GENERATED FOR WELCOME BANK DEPOSIT: ${totp}, For Time stamp: ${isoTimestamp}`);
|
|
644
748
|
this.logger.log(`TOTP GENERATED FOR PREVIOUS TIME: ${totpPrevious}`);
|
|
749
|
+
let responseData;
|
|
645
750
|
try {
|
|
646
751
|
const headers = {
|
|
647
752
|
'Authorization': `Bearer ${token}`,
|
|
@@ -669,41 +774,69 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
669
774
|
headers: headers,
|
|
670
775
|
httpsAgent
|
|
671
776
|
});
|
|
672
|
-
let responseData = response.data;
|
|
673
777
|
this.logger.log({ responseData: response.data }, 'Welcom Bank Deposit Successful');
|
|
674
778
|
if (String(this.config.WELCOMBANK_ENABLEENCRYPTION).toLowerCase() === 'true') {
|
|
675
|
-
const encryptedResponsePayload =
|
|
779
|
+
const encryptedResponsePayload = response.data.data;
|
|
676
780
|
if (!encryptedResponsePayload) {
|
|
677
781
|
throw new Error("Encrypted response expected but not found");
|
|
678
782
|
}
|
|
679
|
-
let decryptedResponse;
|
|
680
783
|
try {
|
|
681
|
-
|
|
784
|
+
responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totp);
|
|
682
785
|
}
|
|
683
786
|
catch (error) {
|
|
684
787
|
this.logger.warn("Decryption with current OTP failed, trying with previous OTP");
|
|
788
|
+
responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totpPrevious);
|
|
685
789
|
}
|
|
686
|
-
if (!decryptedResponse) {
|
|
687
|
-
decryptedResponse = this.decryptPayloadWithOTP(encryptedResponsePayload, totpPrevious);
|
|
688
|
-
}
|
|
689
|
-
return {
|
|
690
|
-
success: true,
|
|
691
|
-
data: decryptedResponse,
|
|
692
|
-
};
|
|
693
790
|
}
|
|
694
791
|
else {
|
|
695
|
-
|
|
696
|
-
success: true,
|
|
697
|
-
...responseData,
|
|
698
|
-
};
|
|
792
|
+
responseData = response.data;
|
|
699
793
|
}
|
|
700
794
|
}
|
|
701
795
|
catch (error) {
|
|
702
796
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
703
797
|
}
|
|
798
|
+
if (responseData.data.status === "99999") {
|
|
799
|
+
throw new common_1.HttpException({
|
|
800
|
+
statusCode: common_1.HttpStatus.FORBIDDEN,
|
|
801
|
+
code: 403020703,
|
|
802
|
+
message: 'Invalid permission key.',
|
|
803
|
+
data: { ...accountTransferDto }
|
|
804
|
+
}, common_1.HttpStatus.FORBIDDEN);
|
|
805
|
+
}
|
|
806
|
+
if (responseData.data.status === "99997") {
|
|
807
|
+
throw new common_1.HttpException({
|
|
808
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
809
|
+
code: 400020709,
|
|
810
|
+
message: 'Account not found.',
|
|
811
|
+
data: { ...accountTransferDto }
|
|
812
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
813
|
+
}
|
|
814
|
+
if (responseData.data.status === "00001") {
|
|
815
|
+
throw new common_1.HttpException({
|
|
816
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
817
|
+
code: 400020711,
|
|
818
|
+
message: 'Account type is not supported.',
|
|
819
|
+
data: { ...accountTransferDto }
|
|
820
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
821
|
+
}
|
|
822
|
+
if (responseData.data.status === "00004") {
|
|
823
|
+
throw new common_1.HttpException({
|
|
824
|
+
statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
|
|
825
|
+
code: 422020714,
|
|
826
|
+
message: 'Invalid transaction amount value.',
|
|
827
|
+
data: { ...accountTransferDto }
|
|
828
|
+
}, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
829
|
+
}
|
|
830
|
+
this.logger.log(`Response Data WelcomeBank Deposit , ${responseData}`);
|
|
831
|
+
return {
|
|
832
|
+
success: true,
|
|
833
|
+
...responseData,
|
|
834
|
+
};
|
|
704
835
|
}
|
|
705
836
|
async getTransactionHistory(transactionHistoryDto) {
|
|
706
837
|
const { token, permissionKey, account, branch, accountType, dateFrom, dateTo, page } = transactionHistoryDto;
|
|
838
|
+
const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
839
|
+
const reformattedTransactions = {};
|
|
707
840
|
if (!token) {
|
|
708
841
|
throw new common_1.HttpException({
|
|
709
842
|
statusCode: common_1.HttpStatus.UNAUTHORIZED,
|
|
@@ -716,7 +849,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
716
849
|
throw new common_1.HttpException({
|
|
717
850
|
statusCode: common_1.HttpStatus.FORBIDDEN,
|
|
718
851
|
code: 403020804,
|
|
719
|
-
message: '
|
|
852
|
+
message: 'Permission key is required.',
|
|
720
853
|
data: { transactionHistoryDto }
|
|
721
854
|
}, common_1.HttpStatus.FORBIDDEN);
|
|
722
855
|
}
|
|
@@ -724,7 +857,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
724
857
|
throw new common_1.HttpException({
|
|
725
858
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
726
859
|
code: 400020806,
|
|
727
|
-
message: '
|
|
860
|
+
message: 'Account number is required',
|
|
728
861
|
data: { transactionHistoryDto }
|
|
729
862
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
730
863
|
}
|
|
@@ -732,7 +865,7 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
732
865
|
throw new common_1.HttpException({
|
|
733
866
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
734
867
|
code: 400020808,
|
|
735
|
-
message: '
|
|
868
|
+
message: 'Account type is required.',
|
|
736
869
|
data: { transactionHistoryDto }
|
|
737
870
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
738
871
|
}
|
|
@@ -740,25 +873,42 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
740
873
|
throw new common_1.HttpException({
|
|
741
874
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
742
875
|
code: 400020810,
|
|
743
|
-
message: '
|
|
876
|
+
message: 'Starting date is required.',
|
|
744
877
|
data: { transactionHistoryDto }
|
|
745
878
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
746
879
|
}
|
|
880
|
+
if (!dateRegex.test(dateFrom)) {
|
|
881
|
+
throw new common_1.HttpException({
|
|
882
|
+
statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
|
|
883
|
+
code: 422020809,
|
|
884
|
+
message: 'Invalid starting date format. Format should be in YYYY-MM-DD.',
|
|
885
|
+
data: { ...transactionHistoryDto }
|
|
886
|
+
}, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
887
|
+
}
|
|
747
888
|
if (!dateTo) {
|
|
748
889
|
throw new common_1.HttpException({
|
|
749
890
|
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
750
891
|
code: 400020812,
|
|
751
|
-
message: '
|
|
892
|
+
message: 'Ending date is required.',
|
|
752
893
|
data: { transactionHistoryDto }
|
|
753
894
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
754
895
|
}
|
|
896
|
+
if (!dateRegex.test(dateTo)) {
|
|
897
|
+
throw new common_1.HttpException({
|
|
898
|
+
statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
|
|
899
|
+
code: 422020811,
|
|
900
|
+
message: 'Invalid starting date format. Format should be in YYYY-MM-DD.',
|
|
901
|
+
data: { ...transactionHistoryDto }
|
|
902
|
+
}, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
903
|
+
}
|
|
755
904
|
this.logger.log("Welcome Bank transaction history");
|
|
756
905
|
const isoTimestamp = new Date().toISOString();
|
|
757
906
|
const timeInSeconds = Math.floor(Date.parse(isoTimestamp) / 1000);
|
|
758
907
|
const totp = this.generateTOTP(timeInSeconds);
|
|
759
908
|
const totpPrevious = this.generateTOTP(timeInSeconds - 30);
|
|
760
|
-
this.logger.log(`TOTP GENERATED FOR WELCOME BANK
|
|
909
|
+
this.logger.log(`TOTP GENERATED FOR WELCOME BANK TRANSACTION HISTORY: ${totp}, For Time stamp: ${isoTimestamp}`);
|
|
761
910
|
this.logger.log(`TOTP GENERATED FOR PREVIOUS TIME: ${totpPrevious}`);
|
|
911
|
+
let responseData;
|
|
762
912
|
try {
|
|
763
913
|
const headers = {
|
|
764
914
|
'Authorization': `Bearer ${token}`,
|
|
@@ -785,38 +935,78 @@ let WelcomeBankService = class WelcomeBankService {
|
|
|
785
935
|
headers: headers,
|
|
786
936
|
httpsAgent
|
|
787
937
|
});
|
|
788
|
-
let responseData = response.data;
|
|
789
938
|
this.logger.log({ responseData: response.data }, 'Welcome Bank Transaction History Successful');
|
|
790
939
|
if (String(this.config.WELCOMBANK_ENABLEENCRYPTION).toLowerCase() === 'true') {
|
|
791
|
-
const encryptedResponsePayload =
|
|
940
|
+
const encryptedResponsePayload = response.data.data;
|
|
792
941
|
if (!encryptedResponsePayload) {
|
|
793
942
|
throw new Error("Encrypted response expected but not found");
|
|
794
943
|
}
|
|
795
|
-
let decryptedResponse;
|
|
796
944
|
try {
|
|
797
|
-
|
|
945
|
+
responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totp);
|
|
798
946
|
}
|
|
799
947
|
catch (error) {
|
|
800
948
|
this.logger.warn("Decryption with current OTP failed, trying with previous OTP");
|
|
949
|
+
responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totpPrevious);
|
|
801
950
|
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
951
|
+
this.logger.log(`Decrypted Response Log: ${JSON.stringify(responseData)}`);
|
|
952
|
+
this.logger.log(`Decrypted.data.transactions Response Log: ${JSON.stringify(responseData.data.transaction)}`);
|
|
953
|
+
responseData.data.transaction.forEach((txn, index) => {
|
|
954
|
+
const key = `${index + 1}`;
|
|
955
|
+
reformattedTransactions[key] = {
|
|
956
|
+
dateTime: txn.dateTime,
|
|
957
|
+
amount: txn.amount,
|
|
958
|
+
type: txn.type,
|
|
959
|
+
description: txn.description,
|
|
960
|
+
transactionReference: txn.tranReference
|
|
961
|
+
};
|
|
962
|
+
});
|
|
809
963
|
}
|
|
810
964
|
else {
|
|
811
|
-
|
|
812
|
-
success: true,
|
|
813
|
-
...responseData,
|
|
814
|
-
};
|
|
965
|
+
responseData = response.data;
|
|
815
966
|
}
|
|
816
967
|
}
|
|
817
968
|
catch (error) {
|
|
818
969
|
axios_error_helper_1.AxiosErrorHelper.handleAxiosError(error);
|
|
819
970
|
}
|
|
971
|
+
if (responseData.data.status === "99999") {
|
|
972
|
+
throw new common_1.HttpException({
|
|
973
|
+
statusCode: common_1.HttpStatus.FORBIDDEN,
|
|
974
|
+
code: 403020803,
|
|
975
|
+
message: 'Invalid permission key.',
|
|
976
|
+
data: { ...transactionHistoryDto }
|
|
977
|
+
}, common_1.HttpStatus.FORBIDDEN);
|
|
978
|
+
}
|
|
979
|
+
if (responseData.data.status === "99997") {
|
|
980
|
+
throw new common_1.HttpException({
|
|
981
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
982
|
+
code: 400020805,
|
|
983
|
+
message: 'Account not found.',
|
|
984
|
+
data: { ...transactionHistoryDto }
|
|
985
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
986
|
+
}
|
|
987
|
+
if (responseData.data.status === "00001") {
|
|
988
|
+
throw new common_1.HttpException({
|
|
989
|
+
statusCode: common_1.HttpStatus.BAD_REQUEST,
|
|
990
|
+
code: 400020807,
|
|
991
|
+
message: 'Account type is not supported.',
|
|
992
|
+
data: { ...transactionHistoryDto }
|
|
993
|
+
}, common_1.HttpStatus.BAD_REQUEST);
|
|
994
|
+
}
|
|
995
|
+
if (responseData.data.status === "XXXXX") {
|
|
996
|
+
throw new common_1.HttpException({
|
|
997
|
+
statusCode: common_1.HttpStatus.UNPROCESSABLE_ENTITY,
|
|
998
|
+
code: 422020813,
|
|
999
|
+
message: 'Invalid page number format.',
|
|
1000
|
+
data: { ...transactionHistoryDto }
|
|
1001
|
+
}, common_1.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
1002
|
+
}
|
|
1003
|
+
this.logger.log(`Response Data WelcomeBank History , ${responseData}`);
|
|
1004
|
+
return {
|
|
1005
|
+
success: true,
|
|
1006
|
+
message: responseData.data.responseMessage,
|
|
1007
|
+
timestamp: responseData.timestamp,
|
|
1008
|
+
transactions: reformattedTransactions,
|
|
1009
|
+
};
|
|
820
1010
|
}
|
|
821
1011
|
async findAccountDetailsRaw(token, userid) {
|
|
822
1012
|
return "Sorry Service Currently Unavaible";
|