diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/taler-util/src/transactions-types.ts | 20 | ||||
-rw-r--r-- | packages/taler-util/src/wallet-types.ts | 41 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-merchant.ts | 7 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/transactions.ts | 32 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet-api-types.ts | 6 |
5 files changed, 54 insertions, 52 deletions
diff --git a/packages/taler-util/src/transactions-types.ts b/packages/taler-util/src/transactions-types.ts index 02e95c208..aaf527b89 100644 --- a/packages/taler-util/src/transactions-types.ts +++ b/packages/taler-util/src/transactions-types.ts @@ -545,17 +545,31 @@ export interface RefundInfoShort { amountRaw: AmountString; } +/** + * Summary information about the payment that we got a refund for. + */ +export interface RefundPaymentInfo { + summary: string; + summary_i18n?: InternationalizedString; + /** + * More information about the merchant + */ + merchant: MerchantInfo; +} + export interface TransactionRefund extends TransactionCommon { type: TransactionType.Refund; - // ID for the transaction that is refunded - refundedTransactionId: string; - // Amount that has been refunded by the merchant amountRaw: AmountString; // Amount will be added to the wallet's balance after fees and refreshing amountEffective: AmountString; + + // ID for the transaction that is refunded + refundedTransactionId: string; + + paymentInfo: RefundPaymentInfo | undefined; } export interface TransactionTip extends TransactionCommon { diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 82f62ceb7..bc43652d9 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -1518,7 +1518,6 @@ export interface WithdrawTestBalanceRequest { forcedDenomSel?: ForcedDenomSel; } - /** * Request to the crypto worker to make a sync signature. */ @@ -1590,36 +1589,6 @@ export const codecForWithdrawTestBalance = .property("bankAccessApiBaseUrl", codecForString()) .build("WithdrawTestBalanceRequest"); -export interface ApplyRefundResponse { - contractTermsHash: string; - - transactionId: string; - - proposalId: string; - - amountEffectivePaid: AmountString; - - amountRefundGranted: AmountString; - - amountRefundGone: AmountString; - - pendingAtExchange: boolean; - - info: OrderShortInfo; -} - -export const codecForApplyRefundResponse = (): Codec<ApplyRefundResponse> => - buildCodecForObject<ApplyRefundResponse>() - .property("amountEffectivePaid", codecForAmountString()) - .property("amountRefundGone", codecForAmountString()) - .property("amountRefundGranted", codecForAmountString()) - .property("contractTermsHash", codecForString()) - .property("pendingAtExchange", codecForBoolean()) - .property("proposalId", codecForString()) - .property("transactionId", codecForString()) - .property("info", codecForOrderShortInfo()) - .build("ApplyRefundResponse"); - export interface SetCoinSuspendedRequest { coinPub: string; suspended: boolean; @@ -1658,11 +1627,11 @@ export interface StartRefundQueryRequest { transactionId: string; } -export const codecForStartRefundQueryRequest = (): Codec<StartRefundQueryRequest> => - buildCodecForObject<StartRefundQueryRequest>() - .property("transactionId", codecForString()) - .build("StartRefundQueryRequest"); - +export const codecForStartRefundQueryRequest = + (): Codec<StartRefundQueryRequest> => + buildCodecForObject<StartRefundQueryRequest>() + .property("transactionId", codecForString()) + .build("StartRefundQueryRequest"); export interface PrepareTipRequest { talerTipUri: string; diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts index a7e9c4e80..733da8394 100644 --- a/packages/taler-wallet-core/src/operations/pay-merchant.ts +++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts @@ -30,7 +30,6 @@ import { AbsoluteTime, AmountJson, Amounts, - ApplyRefundResponse, codecForAbortResponse, codecForMerchantContractTerms, codecForMerchantOrderRefundPickupResponse, @@ -39,7 +38,6 @@ import { codecForProposal, CoinDepositPermission, CoinRefreshRequest, - CoinStatus, ConfirmPayResult, ConfirmPayResultType, constructPayUri, @@ -53,20 +51,15 @@ import { Logger, makeErrorDetail, makePendingOperationFailedError, - MerchantCoinRefundFailureStatus, MerchantCoinRefundStatus, - MerchantCoinRefundSuccessStatus, MerchantContractTerms, MerchantPayResponse, - MerchantRefundResponse, NotificationType, parsePayUri, - parseRefundUri, parseTalerUri, PayCoinSelection, PreparePayResult, PreparePayResultType, - PrepareRefundResult, randomBytes, RefreshReason, StartRefundQueryForUriResponse, diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index ac82dc96d..a89557c1d 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -30,6 +30,7 @@ import { PaymentStatus, PeerContractTerms, RefundInfoShort, + RefundPaymentInfo, TalerErrorCode, TalerProtocolTimestamp, Transaction, @@ -64,6 +65,7 @@ import { PeerPushPaymentIncomingStatus, PeerPullPaymentInitiationRecord, RefundGroupRecord, + ContractTermsRecord, } from "../db.js"; import { InternalWalletState } from "../internal-wallet-state.js"; import { PendingTaskType } from "../pending-types.js"; @@ -648,7 +650,18 @@ function buildTransactionForManualWithdraw( function buildTransactionForRefund( refundRecord: RefundGroupRecord, + maybeContractData: WalletContractData | undefined, ): Transaction { + let paymentInfo: RefundPaymentInfo | undefined = undefined; + + if (maybeContractData) { + paymentInfo = { + merchant: maybeContractData.merchant, + summary: maybeContractData.summary, + summary_i18n: maybeContractData.summaryI18n, + }; + } + return { type: TransactionType.Refund, amountEffective: refundRecord.amountEffective, @@ -666,6 +679,7 @@ function buildTransactionForRefund( extendedStatus: ExtendedStatus.Done, frozen: false, pending: false, + paymentInfo, } } @@ -1022,7 +1036,23 @@ export async function getTransactions( if (shouldSkipCurrency(transactionsRequest, currency)) { return; } - transactions.push(buildTransactionForRefund(refundGroup)) + let contractData: WalletContractData | undefined = undefined; + const purchaseTx = await tx.purchases.get(refundGroup.proposalId); + if (purchaseTx && purchaseTx.download) { + const download = purchaseTx.download; + const contractTermsRecord = await tx.contractTerms.get( + download.contractTermsHash, + ); + if (!contractTermsRecord) { + return; + } + contractData = extractContractData( + contractTermsRecord?.contractTermsRaw, + download.contractTermsHash, + download.contractTermsMerchantSig, + ); + } + transactions.push(buildTransactionForRefund(refundGroup, contractData)); }); tx.refreshGroups.iter().forEachAsync(async (rg) => { diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index 850098daa..928831ed5 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -35,9 +35,6 @@ import { AddExchangeRequest, AddKnownBankAccountsRequest, ApplyDevExperimentRequest, - ApplyRefundFromPurchaseIdRequest, - AcceptRefundRequest, - ApplyRefundResponse, BackupRecovery, BalancesResponse, CancelAbortingTransactionRequest, @@ -83,13 +80,13 @@ import { PreparePeerPushCredit, PreparePeerPushCreditResponse, PrepareRefundRequest, - PrepareRefundResult, PrepareTipRequest, PrepareTipResult, RecoveryLoadRequest, RetryTransactionRequest, SetCoinSuspendedRequest, SetWalletDeviceIdRequest, + StartRefundQueryForUriResponse, StartRefundQueryRequest, TestPayArgs, TestPayResult, @@ -110,7 +107,6 @@ import { WithdrawFakebankRequest, WithdrawTestBalanceRequest, WithdrawUriInfoResponse, - StartRefundQueryForUriResponse, } from "@gnu-taler/taler-util"; import { AuditorTrustRecord, WalletContractData } from "./db.js"; import { |