@traxionpay/cbsmiddleware 0.0.13 → 0.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@traxionpay/cbsmiddleware",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "This is a cbs middlware for RB Banks",
5
5
  "author": "Archer",
6
6
  "private": false,
@@ -250,9 +250,7 @@ export class WelcomeBankService implements BankService {
250
250
  }
251
251
  );
252
252
  }
253
-
254
- this.logger.log({ responseData: response.data }, 'Welcome Bank Link Account Successful');
255
-
253
+
256
254
  if (String(this.config.WELCOMBANK_ENABLEENCRYPTION).toLowerCase() === 'true') {
257
255
 
258
256
  const encryptedResponsePayload = response.data.data;
@@ -285,45 +283,19 @@ export class WelcomeBankService implements BankService {
285
283
 
286
284
  AxiosErrorHelper.handleAxiosError(error);
287
285
  }
286
+ this.logger.log(`Response Data WelcomeBank Link , ${responseData}`);
288
287
 
289
- if (responseData.data.status === "99994") {
290
- throw new HttpException({
291
- statusCode: HttpStatus.BAD_REQUEST,
292
- code: 400020309,
293
- message: 'The customer\'s account is a corporate account / joint account',
294
- data: { ...accountDto }
295
- }, HttpStatus.BAD_REQUEST);
296
- }
297
-
298
- if (responseData.data.status === "99997") {
299
- throw new HttpException({
300
- statusCode: HttpStatus.BAD_REQUEST,
301
- code: 400020303,
302
- message: 'Account not found',
303
- data: { ...accountDto }
304
- }, HttpStatus.BAD_REQUEST);
305
- }
306
-
307
- if (responseData.data.status === "00001") {
308
- throw new HttpException({
309
- statusCode: HttpStatus.BAD_REQUEST,
310
- code: 400020305,
311
- message: 'Account type is not supported.',
312
- data: { ...accountDto }
313
- }, HttpStatus.BAD_REQUEST);
314
- }
315
-
316
- if (responseData.data.status === "00007") {
288
+ if (responseData.data.status != "00000") {
317
289
  throw new HttpException({
318
290
  statusCode: HttpStatus.BAD_REQUEST,
319
- code: 400020307,
320
- message: 'Mobile number is not registered in the account.',
321
- data: { ...accountDto }
291
+ code: responseData.data.status,
292
+ message: responseData.data.responseMessage,
293
+ data: { params:accountDto,
294
+ responseData
295
+ }
322
296
  }, HttpStatus.BAD_REQUEST);
323
297
  }
324
-
325
- this.logger.log(`Response Data WelcomeBank Link , ${responseData}`);
326
-
298
+
327
299
  return {
328
300
  success: true,
329
301
  ...responseData,
@@ -441,43 +413,18 @@ export class WelcomeBankService implements BankService {
441
413
  AxiosErrorHelper.handleAxiosError(error);
442
414
  }
443
415
 
444
- if (responseData.data.status === "99994") {
445
- throw new HttpException({
446
- statusCode: HttpStatus.BAD_REQUEST,
447
- code: 400020309,
448
- message: 'The customer\'s account is a corporate account / joint account',
449
- data: { ...validateOtp }
450
- }, HttpStatus.BAD_REQUEST);
451
- }
452
-
453
- if (responseData.data.status === "99997") {
454
- throw new HttpException({
455
- statusCode: HttpStatus.BAD_REQUEST,
456
- code: 400020403,
457
- message: 'Account number is required.',
458
- data: { ...validateOtp }
459
- }, HttpStatus.BAD_REQUEST);
460
- }
461
-
462
- if (responseData.data.status === "00001") {
463
- throw new HttpException({
464
- statusCode: HttpStatus.BAD_REQUEST,
465
- code: 400020405,
466
- message: '00001 Account type is not supported.',
467
- data: { ...validateOtp }
468
- }, HttpStatus.BAD_REQUEST);
469
- }
470
-
471
- if (responseData.data.status === "00005") {
416
+ this.logger.log(`Response Data WelcomeBank Validate , ${responseData}`);
417
+
418
+ if (responseData.data.status != "00000") {
472
419
  throw new HttpException({
473
420
  statusCode: HttpStatus.BAD_REQUEST,
474
- code: 400020407,
475
- message: 'Invalid or expired OTP.',
476
- data: { ...validateOtp }
421
+ code: responseData.data.status,
422
+ message: responseData.data.responseMessage,
423
+ data: { params:validateOtp,
424
+ responseData
425
+ }
477
426
  }, HttpStatus.BAD_REQUEST);
478
- }
479
-
480
- this.logger.log(`Response Data WelcomeBank Validate , ${responseData}`);
427
+ }
481
428
 
482
429
  return {
483
430
  success: true,
@@ -594,34 +541,19 @@ export class WelcomeBankService implements BankService {
594
541
  catch (error) {
595
542
  AxiosErrorHelper.handleAxiosError(error);
596
543
  }
597
- if (responseData.data.status === "99999") {
598
- throw new HttpException({
599
- statusCode: HttpStatus.FORBIDDEN,
600
- code: 403020503,
601
- message: 'Invalid permission key.',
602
- data: { ...fetchBalanceDto }
603
- }, HttpStatus.FORBIDDEN);
604
- }
605
544
 
606
- if (responseData.data.status === "99997") {
607
- throw new HttpException({
608
- statusCode: HttpStatus.BAD_REQUEST,
609
- code: 400020505,
610
- message: 'Account not found.',
611
- data: { ...fetchBalanceDto }
612
- }, HttpStatus.BAD_REQUEST);
613
- }
545
+ this.logger.log(`Response Data WelcomeBank Balance Inquiry , ${responseData}`);
614
546
 
615
- if (responseData.data.status === "00001") {
547
+ if (responseData.data.status != "00000") {
616
548
  throw new HttpException({
617
549
  statusCode: HttpStatus.BAD_REQUEST,
618
- code: 400020507,
619
- message: 'Account type is not supported.',
620
- data: { ...fetchBalanceDto }
550
+ code: responseData.data.status,
551
+ message: responseData.data.responseMessage,
552
+ data: { params:fetchBalanceDto,
553
+ responseData
554
+ }
621
555
  }, HttpStatus.BAD_REQUEST);
622
- }
623
-
624
- this.logger.log(`Response Data WelcomeBank Balance Inquiry , ${responseData}`);
556
+ }
625
557
 
626
558
  return {
627
559
  success: true,
@@ -770,88 +702,19 @@ export class WelcomeBankService implements BankService {
770
702
  catch (error) {
771
703
  AxiosErrorHelper.handleAxiosError(error);
772
704
  }
773
- if (responseData.data.status === "99999") {
774
- throw new HttpException({
775
- statusCode: HttpStatus.FORBIDDEN,
776
- code: 403020603,
777
- message: 'Invalid permission key.',
778
- data: { ...accountTransferDto }
779
- }, HttpStatus.FORBIDDEN);
780
- }
781
-
782
- if (responseData.data.status === "99997") {
783
- throw new HttpException({
784
- statusCode: HttpStatus.BAD_REQUEST,
785
- code: 400020605,
786
- message: 'Account not found.',
787
- data: { ...accountTransferDto }
788
- }, HttpStatus.BAD_REQUEST);
789
- }
790
-
791
- if (responseData.data.status === "00001") {
792
- throw new HttpException({
793
- statusCode: HttpStatus.BAD_REQUEST,
794
- code: 400020607,
795
- message: 'Account type is not supported.',
796
- data: { ...accountTransferDto }
797
- }, HttpStatus.BAD_REQUEST);
798
- }
799
-
800
- if (responseData.data.status === "00004") {
801
- throw new HttpException({
802
- statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
803
- code: 422020614,
804
- message: 'Invalid transaction amount value.',
805
- data: { ...accountTransferDto }
806
- }, HttpStatus.UNPROCESSABLE_ENTITY);
807
- }
705
+
706
+ this.logger.log(`Response Data WelcomeBank Cashin , ${responseData}`);
808
707
 
809
- if (responseData.data.status === "99998") {
708
+ if (responseData.data.status != "00000") {
810
709
  throw new HttpException({
811
710
  statusCode: HttpStatus.BAD_REQUEST,
812
- code: 400020615,
813
- message: 'Duplicate transaction within 1-minute window.',
814
- data: { ...accountTransferDto }
711
+ code: responseData.data.status,
712
+ message: responseData.data.responseMessage,
713
+ data: { params:accountTransferDto,
714
+ responseData
715
+ }
815
716
  }, HttpStatus.BAD_REQUEST);
816
- }
817
-
818
- if (responseData.data.status === "99990") {
819
- throw new HttpException({
820
- statusCode: HttpStatus.BAD_REQUEST,
821
- code: 400020616,
822
- message: 'Daily transaction limit reached.',
823
- data: { ...accountTransferDto }
824
- }, HttpStatus.BAD_REQUEST);
825
- }
826
-
827
- if (responseData.data.status === "99995") {
828
- throw new HttpException({
829
- statusCode: HttpStatus.BAD_REQUEST,
830
- code: 400020617,
831
- message: 'Invalid transaction.',
832
- data: { ...accountTransferDto }
833
- }, HttpStatus.BAD_REQUEST);
834
- }
835
-
836
- if (responseData.data.status === "XXXXX") {
837
- throw new HttpException({
838
- statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
839
- code: 400020618,
840
- message: 'Unknown Error',
841
- data: { ...accountTransferDto }
842
- }, HttpStatus.UNPROCESSABLE_ENTITY);
843
- }
844
-
845
- if (responseData.data.status !== "00000") {
846
- throw new HttpException({
847
- statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
848
- code: 400020618,
849
- message: 'Unknown Error',
850
- data: { ...accountTransferDto }
851
- }, HttpStatus.UNPROCESSABLE_ENTITY);
852
- }
853
-
854
- this.logger.log(`Response Data WelcomeBank Cashin , ${responseData}`);
717
+ }
855
718
 
856
719
  return {
857
720
  success: true,
@@ -1001,89 +864,19 @@ export class WelcomeBankService implements BankService {
1001
864
  catch (error) {
1002
865
  AxiosErrorHelper.handleAxiosError(error);
1003
866
  }
1004
- if (responseData.data.status === "99999") {
1005
- throw new HttpException({
1006
- statusCode: HttpStatus.FORBIDDEN,
1007
- code: 403020703,
1008
- message: 'Invalid permission key.',
1009
- data: { ...accountTransferDto }
1010
- }, HttpStatus.FORBIDDEN);
1011
- }
1012
-
1013
- if (responseData.data.status === "99997") {
1014
- throw new HttpException({
1015
- statusCode: HttpStatus.BAD_REQUEST,
1016
- code: 400020709,
1017
- message: 'Account not found.',
1018
- data: { ...accountTransferDto }
1019
- }, HttpStatus.BAD_REQUEST);
1020
- }
1021
867
 
1022
- if (responseData.data.status === "00001") {
1023
- throw new HttpException({
1024
- statusCode: HttpStatus.BAD_REQUEST,
1025
- code: 400020711,
1026
- message: 'Account type is not supported.',
1027
- data: { ...accountTransferDto }
1028
- }, HttpStatus.BAD_REQUEST);
1029
- }
1030
-
1031
- if (responseData.data.status === "00004") {
1032
- throw new HttpException({
1033
- statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
1034
- code: 422020714,
1035
- message: 'Invalid transaction amount value.',
1036
- data: { ...accountTransferDto }
1037
- }, HttpStatus.UNPROCESSABLE_ENTITY);
1038
- }
1039
-
1040
- if (responseData.data.status === "99998") {
1041
- throw new HttpException({
1042
- statusCode: HttpStatus.BAD_REQUEST,
1043
- code: 400020615,
1044
- message: 'Duplicate transaction within 1-minute window.',
1045
- data: { ...accountTransferDto }
1046
- }, HttpStatus.BAD_REQUEST);
1047
- }
1048
-
1049
- if (responseData.data.status === "99992") {
1050
- throw new HttpException({
1051
- statusCode: HttpStatus.BAD_REQUEST,
1052
- code: 400020616,
1053
- message: 'Daily transaction limit reached.',
1054
- data: { ...accountTransferDto }
1055
- }, HttpStatus.BAD_REQUEST);
1056
- }
1057
-
1058
- if (responseData.data.status === "99995") {
868
+ this.logger.log(`Response Data WelcomeBank Deposit , ${responseData}`);
869
+
870
+ if (responseData.data.status != "00000") {
1059
871
  throw new HttpException({
1060
872
  statusCode: HttpStatus.BAD_REQUEST,
1061
- code: 400020616,
1062
- message: 'Invalid transaction.',
1063
- data: { ...accountTransferDto }
873
+ code: responseData.data.status,
874
+ message: responseData.data.responseMessage,
875
+ data: { params:accountTransferDto,
876
+ responseData
877
+ }
1064
878
  }, HttpStatus.BAD_REQUEST);
1065
- }
1066
-
1067
- if (responseData.data.status === "XXXXX") {
1068
- throw new HttpException({
1069
- statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
1070
- code: 400020617,
1071
- message: 'Unknown Error',
1072
- data: { ...accountTransferDto }
1073
- }, HttpStatus.UNPROCESSABLE_ENTITY);
1074
- }
1075
-
1076
- if (responseData.data.status !== "00000") {
1077
- throw new HttpException({
1078
- statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
1079
- code: 400020617,
1080
- message: 'Unknown Error',
1081
- data: { ...accountTransferDto }
1082
- }, HttpStatus.UNPROCESSABLE_ENTITY);
1083
- }
1084
-
1085
-
1086
- this.logger.log(`Response Data WelcomeBank Deposit , ${responseData}`);
879
+ }
1087
880
 
1088
881
  return {
1089
882
  success: true,
@@ -1276,45 +1069,20 @@ export class WelcomeBankService implements BankService {
1276
1069
  catch (error) {
1277
1070
  AxiosErrorHelper.handleAxiosError(error);
1278
1071
  }
1279
-
1280
- if (responseData.data.status === "99999") {
1281
- throw new HttpException({
1282
- statusCode: HttpStatus.FORBIDDEN,
1283
- code: 403020803,
1284
- message: 'Invalid permission key.',
1285
- data: { ...transactionHistoryDto }
1286
- }, HttpStatus.FORBIDDEN);
1287
- }
1288
-
1289
- if (responseData.data.status === "99997") {
1290
- throw new HttpException({
1291
- statusCode: HttpStatus.BAD_REQUEST,
1292
- code: 400020805,
1293
- message: 'Account not found.',
1294
- data: { ...transactionHistoryDto }
1295
- }, HttpStatus.BAD_REQUEST);
1296
- }
1297
-
1298
- if (responseData.data.status === "00001") {
1072
+
1073
+ this.logger.log(`Response Data WelcomeBank History , ${responseData}`);
1074
+
1075
+ if (responseData.data.status != "00000") {
1299
1076
  throw new HttpException({
1300
1077
  statusCode: HttpStatus.BAD_REQUEST,
1301
- code: 400020807,
1302
- message: 'Account type is not supported.',
1303
- data: { ...transactionHistoryDto }
1078
+ code: responseData.data.status,
1079
+ message: responseData.data.responseMessage,
1080
+ data: { params:transactionHistoryDto,
1081
+ responseData
1082
+ }
1304
1083
  }, HttpStatus.BAD_REQUEST);
1305
- }
1306
-
1307
- if (responseData.data.status === "XXXXX") {
1308
- throw new HttpException({
1309
- statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
1310
- code: 422020813,
1311
- message: 'Invalid page number format.',
1312
- data: { ...transactionHistoryDto }
1313
- }, HttpStatus.UNPROCESSABLE_ENTITY);
1314
- }
1315
-
1316
- this.logger.log(`Response Data WelcomeBank History , ${responseData}`);
1317
-
1084
+ }
1085
+
1318
1086
  return {
1319
1087
  success: true,
1320
1088
  message: responseData.data.responseMessage,