diff options
author | Florian Dold <florian@dold.me> | 2023-05-25 11:52:20 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-05-25 11:52:20 +0200 |
commit | c3ef842df0ca80c5fe8deb5dabea44d5c817d7ed (patch) | |
tree | 37942171cf5a4f2f0518ba5955b258eb155efa68 /packages | |
parent | 5f325aa4d33b4f33a2afd7d7f8aa33807c521017 (diff) | |
download | wallet-core-c3ef842df0ca80c5fe8deb5dabea44d5c817d7ed.tar.xz |
wallet-core: add pay-merchant suspended states
Diffstat (limited to 'packages')
-rw-r--r-- | packages/taler-wallet-core/src/db.ts | 8 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-merchant.ts | 102 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/transactions.ts | 4 |
3 files changed, 86 insertions, 28 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 92781d2ed..d2a91aac4 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -1106,6 +1106,14 @@ export enum PurchaseStatus { PendingAcceptRefund = 16, + SuspendedDownloadingProposal = 20, + SuspendedPaying = 21, + SuspendedAbortingWithRefund = 22, + SuspendedPayingReplay = 23, + SuspendedQueryingRefund = 24, + SuspendedQueryingAutoRefund = 25, + SuspendedPendingAcceptRefund = 26, + /** * Proposal downloaded, but the user needs to accept/reject it. */ diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts index 1614677ed..4473b0be6 100644 --- a/packages/taler-wallet-core/src/operations/pay-merchant.ts +++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts @@ -373,7 +373,6 @@ async function processDownloadProposal( return tx.operationRetries.get(opId); }); - // FIXME: Do this in the background using the new return value const httpResponse = await ws.http.fetch(orderClaimUrl, { body: requestBody, timeout: getProposalRequestTimeout(retryRecord?.retryInfo), @@ -1499,6 +1498,13 @@ export async function processPurchase( case PurchaseStatus.Proposed: case PurchaseStatus.AbortedProposalRefused: case PurchaseStatus.AbortedIncompletePayment: + case PurchaseStatus.SuspendedAbortingWithRefund: + case PurchaseStatus.SuspendedDownloadingProposal: + case PurchaseStatus.SuspendedPaying: + case PurchaseStatus.SuspendedPayingReplay: + case PurchaseStatus.SuspendedPendingAcceptRefund: + case PurchaseStatus.SuspendedQueryingAutoRefund: + case PurchaseStatus.SuspendedQueryingRefund: return { type: OperationAttemptResultType.Finished, result: undefined, @@ -1785,67 +1791,107 @@ export function computePayMerchantTransactionState( purchaseRecord: PurchaseRecord, ): TransactionState { switch (purchaseRecord.purchaseStatus) { + // Pending States case PurchaseStatus.DownloadingProposal: return { major: TransactionMajorState.Pending, minor: TransactionMinorState.ClaimProposal, }; - case PurchaseStatus.Done: + case PurchaseStatus.Paying: return { - major: TransactionMajorState.Done, + major: TransactionMajorState.Pending, + minor: TransactionMinorState.SubmitPayment, }; - case PurchaseStatus.AbortedIncompletePayment: + case PurchaseStatus.PayingReplay: return { - major: TransactionMajorState.Aborted, + major: TransactionMajorState.Pending, + minor: TransactionMinorState.RebindSession, }; - case PurchaseStatus.Proposed: + case PurchaseStatus.QueryingAutoRefund: return { - major: TransactionMajorState.Dialog, - minor: TransactionMinorState.MerchantOrderProposed, + major: TransactionMajorState.Pending, + minor: TransactionMinorState.AutoRefund, }; - case PurchaseStatus.FailedClaim: + case PurchaseStatus.QueryingRefund: return { - major: TransactionMajorState.Failed, + major: TransactionMajorState.Pending, + minor: TransactionMinorState.CheckRefund, + }; + case PurchaseStatus.PendingAcceptRefund: + return { + major: TransactionMajorState.Pending, + minor: TransactionMinorState.AcceptRefund, + }; + // Suspended Pending States + case PurchaseStatus.SuspendedDownloadingProposal: + return { + major: TransactionMajorState.Suspended, minor: TransactionMinorState.ClaimProposal, }; - case PurchaseStatus.RepurchaseDetected: + case PurchaseStatus.SuspendedPaying: return { - major: TransactionMajorState.Failed, - minor: TransactionMinorState.Repurchase, + major: TransactionMajorState.Suspended, + minor: TransactionMinorState.SubmitPayment, + }; + case PurchaseStatus.SuspendedPayingReplay: + return { + major: TransactionMajorState.Suspended, + minor: TransactionMinorState.RebindSession, + }; + case PurchaseStatus.SuspendedQueryingAutoRefund: + return { + major: TransactionMajorState.Suspended, + minor: TransactionMinorState.AutoRefund, + }; + case PurchaseStatus.SuspendedQueryingRefund: + return { + major: TransactionMajorState.Suspended, + minor: TransactionMinorState.CheckRefund, + }; + case PurchaseStatus.SuspendedPendingAcceptRefund: + return { + major: TransactionMajorState.Suspended, + minor: TransactionMinorState.AcceptRefund, }; + // Aborting States case PurchaseStatus.AbortingWithRefund: return { major: TransactionMajorState.Aborting, }; - case PurchaseStatus.Paying: + // Suspended Aborting States + case PurchaseStatus.SuspendedAbortingWithRefund: return { - major: TransactionMajorState.Pending, - minor: TransactionMinorState.SubmitPayment, + major: TransactionMajorState.SuspendedAborting, }; - case PurchaseStatus.PayingReplay: + // Dialog States + case PurchaseStatus.Proposed: return { - major: TransactionMajorState.Pending, - minor: TransactionMinorState.RebindSession, + major: TransactionMajorState.Dialog, + minor: TransactionMinorState.MerchantOrderProposed, }; + // Final States case PurchaseStatus.AbortedProposalRefused: return { major: TransactionMajorState.Failed, minor: TransactionMinorState.Refused, }; - case PurchaseStatus.QueryingAutoRefund: + case PurchaseStatus.Done: return { - major: TransactionMajorState.Pending, - minor: TransactionMinorState.AutoRefund, + major: TransactionMajorState.Done, }; - case PurchaseStatus.QueryingRefund: + case PurchaseStatus.RepurchaseDetected: return { - major: TransactionMajorState.Pending, - minor: TransactionMinorState.CheckRefund, + major: TransactionMajorState.Failed, + minor: TransactionMinorState.Repurchase, }; - case PurchaseStatus.PendingAcceptRefund: + case PurchaseStatus.AbortedIncompletePayment: return { - major: TransactionMajorState.Pending, - minor: TransactionMinorState.AcceptRefund, + major: TransactionMajorState.Aborted, + }; + case PurchaseStatus.FailedClaim: + return { + major: TransactionMajorState.Failed, + minor: TransactionMinorState.ClaimProposal, }; } } diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index e11b628db..2eb8b202d 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -76,6 +76,7 @@ import { import { computeDepositTransactionStatus, processDepositGroup, + resumeDepositGroup, suspendDepositGroup, } from "./deposits.js"; import { getExchangeDetails } from "./exchanges.js"; @@ -1429,6 +1430,9 @@ export async function resumeTransaction( throw Error("invalid transaction ID"); } switch (tx.tag) { + case TransactionType.Deposit: + await resumeDepositGroup(ws, tx.depositGroupId); + return; default: logger.warn(`unable to resume transaction of type '${tx.tag}'`); } |