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