diff options
author | Florian Dold <florian@dold.me> | 2023-05-16 19:03:22 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-05-16 19:03:22 +0200 |
commit | acf0dda83f3974187cacf58e7d81c2115f6d950d (patch) | |
tree | 6ca65c874d33f21a3a81435ff2429c08e28a03e5 /packages/taler-wallet-core/src | |
parent | 72d0230a2ec34d83bfbbd0c7f731e25c76da3a45 (diff) | |
download | wallet-core-acf0dda83f3974187cacf58e7d81c2115f6d950d.tar.xz |
wallet-core: return purchase information in refund if available
Diffstat (limited to 'packages/taler-wallet-core/src')
3 files changed, 32 insertions, 13 deletions
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 { |