diff options
author | Florian Dold <florian@dold.me> | 2024-03-27 20:08:23 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-03-27 20:08:23 +0100 |
commit | d13d465c4bdcd2462c916676ac9247fd241dbd9c (patch) | |
tree | 9a2fc89b52f117173c9e3a0e683ccd8bc6a3df2a /packages/taler-wallet-core/src | |
parent | a9c315eba0f802f092cca43ffbc50ace8a2c389e (diff) | |
download | wallet-core-d13d465c4bdcd2462c916676ac9247fd241dbd9c.tar.xz |
wallet-core: implement abort for more payment states
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r-- | packages/taler-wallet-core/src/pay-merchant.ts | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts index 40abd44a0..62309a300 100644 --- a/packages/taler-wallet-core/src/pay-merchant.ts +++ b/packages/taler-wallet-core/src/pay-merchant.ts @@ -284,11 +284,6 @@ export class PayMerchantTransactionContext implements TransactionContext { } const oldTxState = computePayMerchantTransactionState(purchase); const oldStatus = purchase.purchaseStatus; - if (purchase.timestampFirstSuccessfulPay) { - // No point in aborting it. We don't even report an error. - logger.warn(`tried to abort successful payment`); - return; - } switch (oldStatus) { case PurchaseStatus.Done: return; @@ -318,9 +313,22 @@ export class PayMerchantTransactionContext implements TransactionContext { } break; } + case PurchaseStatus.PendingQueryingAutoRefund: + case PurchaseStatus.SuspendedQueryingAutoRefund: + case PurchaseStatus.PendingAcceptRefund: + case PurchaseStatus.SuspendedPendingAcceptRefund: + case PurchaseStatus.PendingQueryingRefund: + case PurchaseStatus.SuspendedQueryingRefund: + if (!purchase.timestampFirstSuccessfulPay) { + throw Error("invalid state"); + } + purchase.purchaseStatus = PurchaseStatus.Done; + break; case PurchaseStatus.DialogProposed: purchase.purchaseStatus = PurchaseStatus.AbortedProposalRefused; break; + default: + return; } await tx.purchases.put(purchase); await tx.operationRetries.delete(this.taskId); |