@traxionpay/cbsmiddleware 0.0.3 → 0.0.5

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.3",
3
+ "version": "0.0.5",
4
4
  "description": "This is a cbs middlware for RB Banks",
5
5
  "author": "Archer",
6
6
  "private": false,
@@ -679,19 +679,21 @@ export class ASPACService implements BankService {
679
679
 
680
680
  this.logger.log({ responseData: response.data }, 'Welcome Bank Transaction History Successful');
681
681
 
682
- response.data.data.transactions.forEach((txn, index) => {
683
- const key = `${index + 1}`;
684
- const dateTime = this.combineDateTime(txn.tranDate, txn.tranTime);
685
-
686
- reformattedTransactions[key] = {
687
- dateTime,
688
- amount: txn.tranAmount,
689
- type: txn.tranType,
690
- description: txn.description,
691
- transactionReference: txn.tranReference
692
- };
693
- });
694
-
682
+ if (response.data.data.transactions && Array.isArray(response.data.data.transactions)) {
683
+ response.data.data.transactions.forEach((txn, index) => {
684
+ const key = `${index + 1}`;
685
+ const dateTime = this.combineDateTime(txn.tranDate, txn.tranTime);
686
+
687
+ reformattedTransactions[key] = {
688
+ dateTime,
689
+ amount: txn.tranAmount,
690
+ type: txn.tranType,
691
+ description: txn.description,
692
+ transactionReference: txn.tranReference
693
+ };
694
+ });
695
+ }
696
+
695
697
  return {
696
698
  success: true,
697
699
  message: response.data.data.message,
@@ -313,6 +313,8 @@ export class WelcomeBankService implements BankService {
313
313
  }, HttpStatus.BAD_REQUEST);
314
314
  }
315
315
 
316
+ this.logger.log(`Response Data WelcomeBank Link , ${responseData}`);
317
+
316
318
  return {
317
319
  success: true,
318
320
  ...responseData,
@@ -456,6 +458,8 @@ export class WelcomeBankService implements BankService {
456
458
  }, HttpStatus.BAD_REQUEST);
457
459
  }
458
460
 
461
+ this.logger.log(`Response Data WelcomeBank Validate , ${responseData}`);
462
+
459
463
  return {
460
464
  success: true,
461
465
  ...responseData,
@@ -598,6 +602,8 @@ export class WelcomeBankService implements BankService {
598
602
  }, HttpStatus.BAD_REQUEST);
599
603
  }
600
604
 
605
+ this.logger.log(`Response Data WelcomeBank Balance Inquiry , ${responseData}`);
606
+
601
607
  return {
602
608
  success: true,
603
609
  ...responseData,
@@ -781,6 +787,17 @@ export class WelcomeBankService implements BankService {
781
787
  }, HttpStatus.UNPROCESSABLE_ENTITY);
782
788
  }
783
789
 
790
+ if (responseData.data.status === "99998") {
791
+ throw new HttpException({
792
+ statusCode: HttpStatus.BAD_REQUEST,
793
+ code: 400020615,
794
+ message: 'Duplicate transaction within 1-minute window.',
795
+ data: { ...accountTransferDto }
796
+ }, HttpStatus.BAD_REQUEST);
797
+ }
798
+
799
+ this.logger.log(`Response Data WelcomeBank Cashin , ${responseData}`);
800
+
784
801
  return {
785
802
  success: true,
786
803
  ...responseData,
@@ -965,6 +982,17 @@ export class WelcomeBankService implements BankService {
965
982
  }, HttpStatus.UNPROCESSABLE_ENTITY);
966
983
  }
967
984
 
985
+ if (responseData.data.status === "99998") {
986
+ throw new HttpException({
987
+ statusCode: HttpStatus.BAD_REQUEST,
988
+ code: 400020615,
989
+ message: 'Duplicate transaction within 1-minute window.',
990
+ data: { ...accountTransferDto }
991
+ }, HttpStatus.BAD_REQUEST);
992
+ }
993
+
994
+ this.logger.log(`Response Data WelcomeBank Deposit , ${responseData}`);
995
+
968
996
  return {
969
997
  success: true,
970
998
  ...responseData,
@@ -1131,20 +1159,21 @@ export class WelcomeBankService implements BankService {
1131
1159
  responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totpPrevious);
1132
1160
  }
1133
1161
 
1134
- this.logger.log(`Decrypted Response Log: ${JSON.stringify(responseData)}`);
1135
1162
  this.logger.log(`Decrypted.data.transactions Response Log: ${JSON.stringify(responseData.data.transaction)}`);
1136
-
1137
- responseData.data.transaction.forEach((txn, index) => {
1138
- const key = `${index + 1}`;
1139
-
1140
- reformattedTransactions[key] = {
1141
- dateTime: txn.dateTime,
1142
- amount: txn.amount,
1143
- type: txn.type,
1144
- description: txn.description,
1145
- transactionReference: txn.tranReference
1146
- };
1147
- });
1163
+
1164
+ if (responseData.data.transaction && Array.isArray(responseData.data.transaction)) {
1165
+ responseData.data.transaction.forEach((txn, index) => {
1166
+ const key = `${index + 1}`;
1167
+
1168
+ reformattedTransactions[key] = {
1169
+ dateTime: txn.dateTime,
1170
+ amount: txn.amount,
1171
+ type: txn.type,
1172
+ description: txn.description,
1173
+ transactionReference: txn.tranReference
1174
+ };
1175
+ });
1176
+ }
1148
1177
 
1149
1178
  }
1150
1179
  else {
@@ -1192,6 +1221,8 @@ export class WelcomeBankService implements BankService {
1192
1221
  }, HttpStatus.UNPROCESSABLE_ENTITY);
1193
1222
  }
1194
1223
 
1224
+ this.logger.log(`Response Data WelcomeBank History , ${responseData}`);
1225
+
1195
1226
  return {
1196
1227
  success: true,
1197
1228
  message: responseData.data.responseMessage,