wallet-core: add pay-merchant suspended states
This commit is contained in:
parent
5f325aa4d3
commit
c3ef842df0
@ -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.
|
||||
*/
|
||||
|
@ -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,38 +1791,12 @@ export function computePayMerchantTransactionState(
|
||||
purchaseRecord: PurchaseRecord,
|
||||
): TransactionState {
|
||||
switch (purchaseRecord.purchaseStatus) {
|
||||
// Pending States
|
||||
case PurchaseStatus.DownloadingProposal:
|
||||
return {
|
||||
major: TransactionMajorState.Pending,
|
||||
minor: TransactionMinorState.ClaimProposal,
|
||||
};
|
||||
case PurchaseStatus.Done:
|
||||
return {
|
||||
major: TransactionMajorState.Done,
|
||||
};
|
||||
case PurchaseStatus.AbortedIncompletePayment:
|
||||
return {
|
||||
major: TransactionMajorState.Aborted,
|
||||
};
|
||||
case PurchaseStatus.Proposed:
|
||||
return {
|
||||
major: TransactionMajorState.Dialog,
|
||||
minor: TransactionMinorState.MerchantOrderProposed,
|
||||
};
|
||||
case PurchaseStatus.FailedClaim:
|
||||
return {
|
||||
major: TransactionMajorState.Failed,
|
||||
minor: TransactionMinorState.ClaimProposal,
|
||||
};
|
||||
case PurchaseStatus.RepurchaseDetected:
|
||||
return {
|
||||
major: TransactionMajorState.Failed,
|
||||
minor: TransactionMinorState.Repurchase,
|
||||
};
|
||||
case PurchaseStatus.AbortingWithRefund:
|
||||
return {
|
||||
major: TransactionMajorState.Aborting,
|
||||
};
|
||||
case PurchaseStatus.Paying:
|
||||
return {
|
||||
major: TransactionMajorState.Pending,
|
||||
@ -1827,11 +1807,6 @@ export function computePayMerchantTransactionState(
|
||||
major: TransactionMajorState.Pending,
|
||||
minor: TransactionMinorState.RebindSession,
|
||||
};
|
||||
case PurchaseStatus.AbortedProposalRefused:
|
||||
return {
|
||||
major: TransactionMajorState.Failed,
|
||||
minor: TransactionMinorState.Refused,
|
||||
};
|
||||
case PurchaseStatus.QueryingAutoRefund:
|
||||
return {
|
||||
major: TransactionMajorState.Pending,
|
||||
@ -1847,6 +1822,77 @@ export function computePayMerchantTransactionState(
|
||||
major: TransactionMajorState.Pending,
|
||||
minor: TransactionMinorState.AcceptRefund,
|
||||
};
|
||||
// Suspended Pending States
|
||||
case PurchaseStatus.SuspendedDownloadingProposal:
|
||||
return {
|
||||
major: TransactionMajorState.Suspended,
|
||||
minor: TransactionMinorState.ClaimProposal,
|
||||
};
|
||||
case PurchaseStatus.SuspendedPaying:
|
||||
return {
|
||||
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,
|
||||
};
|
||||
// Suspended Aborting States
|
||||
case PurchaseStatus.SuspendedAbortingWithRefund:
|
||||
return {
|
||||
major: TransactionMajorState.SuspendedAborting,
|
||||
};
|
||||
// Dialog States
|
||||
case PurchaseStatus.Proposed:
|
||||
return {
|
||||
major: TransactionMajorState.Dialog,
|
||||
minor: TransactionMinorState.MerchantOrderProposed,
|
||||
};
|
||||
// Final States
|
||||
case PurchaseStatus.AbortedProposalRefused:
|
||||
return {
|
||||
major: TransactionMajorState.Failed,
|
||||
minor: TransactionMinorState.Refused,
|
||||
};
|
||||
case PurchaseStatus.Done:
|
||||
return {
|
||||
major: TransactionMajorState.Done,
|
||||
};
|
||||
case PurchaseStatus.RepurchaseDetected:
|
||||
return {
|
||||
major: TransactionMajorState.Failed,
|
||||
minor: TransactionMinorState.Repurchase,
|
||||
};
|
||||
case PurchaseStatus.AbortedIncompletePayment:
|
||||
return {
|
||||
major: TransactionMajorState.Aborted,
|
||||
};
|
||||
case PurchaseStatus.FailedClaim:
|
||||
return {
|
||||
major: TransactionMajorState.Failed,
|
||||
minor: TransactionMinorState.ClaimProposal,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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}'`);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user