gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 02/03: refund awating is empty when puchase is paid,


From: gnunet
Subject: [taler-wallet-core] 02/03: refund awating is empty when puchase is paid, returning last refund id
Date: Mon, 20 Feb 2023 17:24:37 +0100

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a commit to branch master
in repository wallet-core.

commit 5ad96b178ee022199877b89683ceb0e930761b9d
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Mon Feb 20 13:23:49 2023 -0300

    refund awating is empty when puchase is paid, returning last refund id
---
 .../taler-wallet-core/src/operations/pay-merchant.ts | 20 ++++++++++++++++++--
 1 file 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),

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]