Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add additional details for card transactions #1876

Merged
merged 6 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @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()
table.integer('cardTxType').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')
table.dropColumn('cardTxType')
})
}
4 changes: 4 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,10 @@ export class Transaction
value!: bigint | null
walletAddress!: WalletAddress
isCard?: boolean
txAmount?: bigint
txCurrency?: string
conversionRate?: string
cardTxType?: number

// Merchant name for card transactions
// Receiver or sender WA for ilp payments
Expand Down
7 changes: 7 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,13 @@ 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,
cardTxType: transaction.type,
createdAt: new Date(transaction.createdAt)
})
)
Expand Down
8 changes: 3 additions & 5 deletions packages/wallet/backend/tests/gatehub/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,9 @@ describe('GateHub Service', (): void => {
{ email: '[email protected]' }
])

const result = await gateHubService.addUserToGateway(user.id)
expect(result).toEqual({
customerId: undefined,
isApproved: undefined
})
expect(gateHubService.addUserToGateway(user.id)).rejects.toThrowError(
`GateHub user with email ${user.email} not found`
)
})
})
})
Expand Down
8 changes: 7 additions & 1 deletion packages/wallet/shared/src/types/card.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { CardTrxTypeEnum } from './transaction'

export type LockReasonCode =
| 'ClientRequestedLock'
| 'LostCard'
Expand Down Expand Up @@ -34,7 +36,7 @@ export interface ICardTransaction {
transactionId: string
ghResponseCode: string
cardScheme: number
type: number
type: CardTrxTypeEnum
createdAt: string
txStatus: string
vaultId: number
Expand All @@ -49,6 +51,10 @@ export interface ICardTransaction {
wallet: number
transactionDateTime: string
processDateTime: string | null
merchantName?: string
mastercardConversion?: {
convRate?: string
}
}

export interface IPagination {
Expand Down
20 changes: 20 additions & 0 deletions packages/wallet/shared/src/types/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ enum TRANSACTION_STATUS {
}
type TransactionStatus = keyof typeof TRANSACTION_STATUS

export enum CardTrxTypeEnum {
Purchase = 0,
ATMWithdrawal = 1,
CardVerificationInquiry = 6,
CashAdvance = 17,
RefundCreditPayment = 20,
BalanceInquiryOnATM = 30,
PINUnblock = 91,
PINChange = 92,
Preauthorization = 101,
PreauthorizationIncremental = 102,
PreauthorizationCompletion = 103,
TransferToAccount = 107,
TransferFromAccount = 108
}

export interface TransactionResponse {
id: string
paymentId: string
Expand All @@ -24,6 +40,10 @@ export interface TransactionResponse {
// Merchant name for card transactions
// Receiver or sender WA for ilp payments
secondParty?: string
txAmount?: bigint
txCurrency?: string
conversionRate?: string
cardTxType?: CardTrxTypeEnum
createdAt: Date
updatedAt: Date
}
Expand Down
Loading