From bc256dc27bbf6519713dd058fded9ad89edc835f Mon Sep 17 00:00:00 2001 From: dragosp1011 Date: Tue, 17 Dec 2024 20:01:23 +0200 Subject: [PATCH] feat: add additional details for card transactions --- ...555_add_card_tx_details_to_transactions.js | 23 +++++++++++++++++++ .../wallet/backend/src/transaction/model.ts | 3 +++ .../wallet/backend/src/transaction/service.ts | 6 +++++ packages/wallet/shared/src/types/card.ts | 4 ++++ .../wallet/shared/src/types/transaction.ts | 3 +++ 5 files changed, 39 insertions(+) create mode 100644 packages/wallet/backend/migrations/20241217130555_add_card_tx_details_to_transactions.js diff --git a/packages/wallet/backend/migrations/20241217130555_add_card_tx_details_to_transactions.js b/packages/wallet/backend/migrations/20241217130555_add_card_tx_details_to_transactions.js new file mode 100644 index 000000000..e703076df --- /dev/null +++ b/packages/wallet/backend/migrations/20241217130555_add_card_tx_details_to_transactions.js @@ -0,0 +1,23 @@ +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.up = function (knex) { + return knex.schema.table('transactions', function (table) { + table.bigint('txAmount').nullable() + table.string('txCurrency').nullable() + table.string('conversionRate').nullable() + }) +} + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +exports.down = function (knex) { + return knex.schema.table('transactions', function (table) { + table.dropColumn('txAmount') + table.dropColumn('txCurrency') + table.dropColumn('conversionRate') + }) +} diff --git a/packages/wallet/backend/src/transaction/model.ts b/packages/wallet/backend/src/transaction/model.ts index b384a0ce2..be96175c9 100644 --- a/packages/wallet/backend/src/transaction/model.ts +++ b/packages/wallet/backend/src/transaction/model.ts @@ -32,6 +32,9 @@ export class Transaction value!: bigint | null walletAddress!: WalletAddress isCard?: boolean + txAmount?: bigint + txCurrency?: string + conversionRate?: string // Merchant name for card transactions // Receiver or sender WA for ilp payments diff --git a/packages/wallet/backend/src/transaction/service.ts b/packages/wallet/backend/src/transaction/service.ts index 22ed94cd5..1f8e5d8c3 100644 --- a/packages/wallet/backend/src/transaction/service.ts +++ b/packages/wallet/backend/src/transaction/service.ts @@ -168,6 +168,12 @@ export class TransactionService implements ITransactionService { status: 'COMPLETED', description: '', isCard: true, + secondParty: transaction.merchantName, + txAmount: transaction.transactionAmount + ? transformBalance(Number(transaction.transactionAmount), 2) + : undefined, + conversionRate: transaction.mastercardConversion?.convRate, + txCurrency: transaction.transactionCurrency, createdAt: new Date(transaction.createdAt) }) ) diff --git a/packages/wallet/shared/src/types/card.ts b/packages/wallet/shared/src/types/card.ts index 29e967b6f..8b14cb9d1 100644 --- a/packages/wallet/shared/src/types/card.ts +++ b/packages/wallet/shared/src/types/card.ts @@ -49,6 +49,10 @@ export interface ICardTransaction { wallet: number transactionDateTime: string processDateTime: string | null + merchantName?: string + mastercardConversion?: { + convRate?: string + } } export interface IPagination { diff --git a/packages/wallet/shared/src/types/transaction.ts b/packages/wallet/shared/src/types/transaction.ts index ae5b36eab..04bf2150a 100644 --- a/packages/wallet/shared/src/types/transaction.ts +++ b/packages/wallet/shared/src/types/transaction.ts @@ -24,6 +24,9 @@ export interface TransactionResponse { // Merchant name for card transactions // Receiver or sender WA for ilp payments secondParty?: string + txAmount?: bigint + txCurrency?: string + conversionRate?: string createdAt: Date updatedAt: Date }