aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-wallet-core/src/operations/pay-merchant.ts20
1 files changed, 18 insertions, 2 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts
index 19cd9c9e8..19eb40f3a 100644
--- a/packages/taler-wallet-core/src/operations/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts
@@ -2321,7 +2321,6 @@ async function acceptRefunds(
}
const refreshCoinsMap: Record<string, CoinRefreshRequest> = {};
-
for (const refundStatus of refunds) {
const refundKey = getRefundKey(refundStatus);
const existingRefundInfo = p.refunds[refundKey];
@@ -2412,6 +2411,7 @@ async function acceptRefunds(
}
} else if (p.purchaseStatus === PurchaseStatus.QueryingRefund) {
p.purchaseStatus = PurchaseStatus.Paid;
+ p.refundAmountAwaiting = undefined;
}
logger.trace("refund query done");
ws.notify({
@@ -2572,10 +2572,26 @@ export async function applyRefundFromPurchaseId(
const summary = await calculateRefundSummary(ws, purchase);
const download = await expectProposalDownload(ws, purchase);
+ const lastExec = Object.values(purchase.refunds).reduce(
+ (prev, cur) => {
+ return TalerProtocolTimestamp.max(cur.executionTime, prev);
+ },
+ { t_s: 0 } as TalerProtocolTimestamp,
+ );
+
+ const transactionId =
+ lastExec.t_s === "never" || lastExec.t_s === 0
+ ? makeTransactionId(TransactionType.Payment, proposalId)
+ : makeTransactionId(
+ TransactionType.Refund,
+ proposalId,
+ String(lastExec.t_s),
+ );
+
return {
contractTermsHash: download.contractData.contractTermsHash,
proposalId: purchase.proposalId,
- transactionId: makeTransactionId(TransactionType.Payment, proposalId), //FIXME: can we have the tx id of the refund
+ transactionId,
amountEffectivePaid: Amounts.stringify(summary.amountEffectivePaid),
amountRefundGone: Amounts.stringify(summary.amountRefundGone),
amountRefundGranted: Amounts.stringify(summary.amountRefundGranted),