[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: wallet-core: fix payment abor
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: wallet-core: fix payment abort state machine |
Date: |
Mon, 05 Jun 2023 10:29:07 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new f3d4ff4e3 wallet-core: fix payment abort state machine
f3d4ff4e3 is described below
commit f3d4ff4e3a44141ad387ef68a9083b01bf1c818a
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Jun 5 10:29:04 2023 +0200
wallet-core: fix payment abort state machine
---
packages/taler-wallet-core/src/db.ts | 2 ++
.../src/operations/pay-merchant.ts | 26 +++++++++++++++++++---
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/packages/taler-wallet-core/src/db.ts
b/packages/taler-wallet-core/src/db.ts
index afc7e2bf8..0e5d1c100 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -1161,6 +1161,8 @@ export enum PurchaseStatus {
Done = 54,
FailedAbort = 55,
+
+ AbortedRefunded = 56,
}
/**
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts
b/packages/taler-wallet-core/src/operations/pay-merchant.ts
index 0097f5bcc..c3f288ff7 100644
--- a/packages/taler-wallet-core/src/operations/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts
@@ -1505,6 +1505,7 @@ export async function processPurchase(
case PurchaseStatus.DialogProposed:
case PurchaseStatus.AbortedProposalRefused:
case PurchaseStatus.AbortedIncompletePayment:
+ case PurchaseStatus.AbortedRefunded:
case PurchaseStatus.SuspendedAbortingWithRefund:
case PurchaseStatus.SuspendedDownloadingProposal:
case PurchaseStatus.SuspendedPaying:
@@ -2038,6 +2039,10 @@ export function computePayMerchantTransactionState(
major: TransactionMajorState.Failed,
minor: TransactionMinorState.Refused,
};
+ case PurchaseStatus.AbortedRefunded:
+ return {
+ major: TransactionMajorState.Aborted,
+ };
case PurchaseStatus.Done:
return {
major: TransactionMajorState.Done,
@@ -2113,6 +2118,8 @@ export function computePayMerchantTransactionActions(
// Final States
case PurchaseStatus.AbortedProposalRefused:
return [TransactionAction.Delete];
+ case PurchaseStatus.AbortedRefunded:
+ return [TransactionAction.Delete];
case PurchaseStatus.Done:
return [TransactionAction.Delete];
case PurchaseStatus.RepurchaseDetected:
@@ -2559,8 +2566,17 @@ async function storeRefunds(
logger.warn("purchase group not found anymore");
return;
}
- if (myPurchase.purchaseStatus !== PurchaseStatus.PendingAcceptRefund) {
- return;
+ let isAborting: boolean;
+ switch (myPurchase.purchaseStatus) {
+ case PurchaseStatus.PendingAcceptRefund:
+ isAborting = false;
+ break;
+ case PurchaseStatus.AbortingWithRefund:
+ isAborting = true;
+ break;
+ default:
+ logger.warn("wrong state, not accepting refund");
+ return;
}
let newGroup: RefundGroupRecord | undefined = undefined;
@@ -2686,7 +2702,11 @@ async function storeRefunds(
const oldTxState = computePayMerchantTransactionState(myPurchase);
if (numPendingItemsTotal === 0) {
- myPurchase.purchaseStatus = PurchaseStatus.Done;
+ if (isAborting) {
+ myPurchase.purchaseStatus = PurchaseStatus.AbortedRefunded;
+ } else {
+ myPurchase.purchaseStatus = PurchaseStatus.Done;
+ }
}
await tx.purchases.put(myPurchase);
const newTxState = computePayMerchantTransactionState(myPurchase);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: wallet-core: fix payment abort state machine,
gnunet <=