@traxionpay/cbsmiddleware 0.0.4 → 0.0.6

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.4",
3
+ "version": "0.0.6",
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,
@@ -787,6 +787,24 @@ export class WelcomeBankService implements BankService {
787
787
  }, HttpStatus.UNPROCESSABLE_ENTITY);
788
788
  }
789
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
+ if (responseData.data.status === "99992") {
800
+ throw new HttpException({
801
+ statusCode: HttpStatus.BAD_REQUEST,
802
+ code: 400020616,
803
+ message: 'Daily transaction limit reached.',
804
+ data: { ...accountTransferDto }
805
+ }, HttpStatus.BAD_REQUEST);
806
+ }
807
+
790
808
  this.logger.log(`Response Data WelcomeBank Cashin , ${responseData}`);
791
809
 
792
810
  return {
@@ -973,6 +991,24 @@ export class WelcomeBankService implements BankService {
973
991
  }, HttpStatus.UNPROCESSABLE_ENTITY);
974
992
  }
975
993
 
994
+ if (responseData.data.status === "99998") {
995
+ throw new HttpException({
996
+ statusCode: HttpStatus.BAD_REQUEST,
997
+ code: 400020615,
998
+ message: 'Duplicate transaction within 1-minute window.',
999
+ data: { ...accountTransferDto }
1000
+ }, HttpStatus.BAD_REQUEST);
1001
+ }
1002
+
1003
+ if (responseData.data.status === "99992") {
1004
+ throw new HttpException({
1005
+ statusCode: HttpStatus.BAD_REQUEST,
1006
+ code: 400020616,
1007
+ message: 'Daily transaction limit reached.',
1008
+ data: { ...accountTransferDto }
1009
+ }, HttpStatus.BAD_REQUEST);
1010
+ }
1011
+
976
1012
  this.logger.log(`Response Data WelcomeBank Deposit , ${responseData}`);
977
1013
 
978
1014
  return {
@@ -1141,20 +1177,21 @@ export class WelcomeBankService implements BankService {
1141
1177
  responseData = this.decryptPayloadWithOTP(encryptedResponsePayload, totpPrevious);
1142
1178
  }
1143
1179
 
1144
- this.logger.log(`Decrypted Response Log: ${JSON.stringify(responseData)}`);
1145
1180
  this.logger.log(`Decrypted.data.transactions Response Log: ${JSON.stringify(responseData.data.transaction)}`);
1146
1181
 
1147
- responseData.data.transaction.forEach((txn, index) => {
1148
- const key = `${index + 1}`;
1149
-
1150
- reformattedTransactions[key] = {
1151
- dateTime: txn.dateTime,
1152
- amount: txn.amount,
1153
- type: txn.type,
1154
- description: txn.description,
1155
- transactionReference: txn.tranReference
1156
- };
1157
- });
1182
+ if (responseData.data.transaction && Array.isArray(responseData.data.transaction)) {
1183
+ responseData.data.transaction.forEach((txn, index) => {
1184
+ const key = `${index + 1}`;
1185
+
1186
+ reformattedTransactions[key] = {
1187
+ dateTime: txn.dateTime,
1188
+ amount: txn.amount,
1189
+ type: txn.type,
1190
+ description: txn.description,
1191
+ transactionReference: txn.tranReference
1192
+ };
1193
+ });
1194
+ }
1158
1195
 
1159
1196
  }
1160
1197
  else {