aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-02-20 13:23:49 -0300
committerSebastian <sebasjm@gmail.com>2023-02-20 13:23:49 -0300
commit5ad96b178ee022199877b89683ceb0e930761b9d (patch)
treed390afd82ef46e7ecb95193f1d6e1a01241c7bea
parent26aca142fef3ec92d80dadc6ff741d070737fb08 (diff)
refund awating is empty when puchase is paid, returning last refund id
-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),