Skip to content

Commit

Permalink
feat: add additional details for card transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
dragosp1011 committed Dec 17, 2024
1 parent 212336e commit bc256dc
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
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<void> }
*/
exports.down = function (knex) {
return knex.schema.table('transactions', function (table) {
table.dropColumn('txAmount')
table.dropColumn('txCurrency')
table.dropColumn('conversionRate')
})
}
3 changes: 3 additions & 0 deletions packages/wallet/backend/src/transaction/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions packages/wallet/backend/src/transaction/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
)
Expand Down
4 changes: 4 additions & 0 deletions packages/wallet/shared/src/types/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export interface ICardTransaction {
wallet: number
transactionDateTime: string
processDateTime: string | null
merchantName?: string
mastercardConversion?: {
convRate?: string
}
}

export interface IPagination {
Expand Down
3 changes: 3 additions & 0 deletions packages/wallet/shared/src/types/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit bc256dc

Please sign in to comment.