@traxionpay/cbsmiddleware 0.0.15 → 0.0.16

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.15",
3
+ "version": "0.0.16",
4
4
  "description": "This is a cbs middlware for RB Banks",
5
5
  "author": "Archer",
6
6
  "private": false,
@@ -695,7 +695,23 @@ export class MBWINService implements BankService {
695
695
  }
696
696
  }
697
697
 
698
- async getTransactionHistory(transactionHistoryDto: TransactionHistoryDto) {
698
+ combineDateTime(date: string, time: string): string {
699
+ const isoString = `${date}T${time.padEnd(8, '0')}.000Z`; // ensure time is HH:mm:ss
700
+ const d = new Date(isoString);
701
+
702
+ // Format as: 2025-09-26T05:35:36.320+00:00
703
+ const isoWithOffset = d.toISOString().replace('Z', '+00:00');
704
+
705
+ return isoWithOffset;
706
+ }
707
+
708
+ async getTransactionHistory(transactionHistoryDto: TransactionHistoryDto):
709
+ Promise<{
710
+ success: boolean;
711
+ message: any;
712
+ timestamp: any;
713
+ transactions: any;
714
+ }> {
699
715
 
700
716
  const { token, account, dateFrom, dateTo, page, branch, accountType, fullName, birthDate, mobile, permissionKey } = transactionHistoryDto;
701
717
  const mobileFormatted = mobile? formatTo09(mobile) : '';
@@ -819,21 +835,51 @@ export class MBWINService implements BankService {
819
835
 
820
836
  const responseData = response.data;
821
837
 
822
- if(responseData?.data && !responseData?.data?.success) {
823
- this.logger.error({ payload: payload, responseData: response.data }, 'MBWIN transaction history Error');
838
+ this.logger.log({ responseData: response.data }, 'MBWIN transaction history Successful');
839
+
840
+ interface ReformattedTransaction {
841
+ dateTime: string;
842
+ amount: number;
843
+ type: string;
844
+ description: string;
845
+ transactionReference: string;
846
+ allDetails?: any
847
+ }
848
+
849
+ const reformattedTransactions: Record<string, ReformattedTransaction> = {};
850
+
851
+ if(!responseData?.data.success){
852
+ this.logger.error({ payload: payload, responseData }, 'MBWIN transaction history Error');
824
853
  throw new HttpException({
825
854
  statusCode: HttpStatus.BAD_REQUEST,
826
855
  code: 4000, //TBD
827
- message: responseData?.data?.message || "Something went wrong!",
828
- data: { payload, response: responseData?.data }
856
+ message: responseData?.message || "Something went wrong!",
857
+ data: { payload, response: responseData }
829
858
  }, HttpStatus.BAD_REQUEST);
830
859
  }
831
860
 
832
- this.logger.log({ responseData: response.data }, 'MBWIN transaction history Successful');
833
-
861
+ if (responseData?.data && Array.isArray(responseData?.data?.trans)) {
862
+ responseData?.data?.trans.forEach((txn, index) => {
863
+ const key = `${index + 1}`;
864
+ // const dateTime = this.combineDateTime(txn.trnDate, txn.tranTime);
865
+
866
+ reformattedTransactions[key] = {
867
+ dateTime: txn.computerDate,
868
+ amount: txn.trnPriAmt,
869
+ type: txn.trnType,
870
+ description: txn.trnDesc,
871
+ transactionReference: '',
872
+ allDetails: {
873
+ ...txn
874
+ }
875
+ };
876
+ });
877
+ }
834
878
  return {
835
879
  success: true,
836
- ...response.data,
880
+ message: response.data.data.message,
881
+ timestamp: response.data.timestamp,
882
+ transactions: reformattedTransactions,
837
883
  }
838
884
  }
839
885
  catch (error) {