wallet-core: report pay-merchant DD37 state

This commit is contained in:
Florian Dold 2023-05-02 13:24:51 +02:00
parent 16d30adf0d
commit 23fca6d867
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
3 changed files with 72 additions and 3 deletions

View File

@ -89,6 +89,8 @@ export enum TransactionMajorState {
Aborting = "aborting", Aborting = "aborting",
Aborted = "aborted", Aborted = "aborted",
Suspended = "suspended", Suspended = "suspended",
SuspendedDeletable = "suspended-deletable",
Dialog = "dialog",
SuspendedAborting = "suspended-aborting", SuspendedAborting = "suspended-aborting",
Failed = "failed", Failed = "failed",
// Only used for the notification, never in the transaction history // Only used for the notification, never in the transaction history
@ -104,15 +106,22 @@ export enum TransactionMinorState {
KycRequired = "kyc", KycRequired = "kyc",
AmlRequired = "aml", AmlRequired = "aml",
Track = "track", Track = "track",
Pay = "pay",
RebindSession = "rebind-session",
Refresh = "refresh", Refresh = "refresh",
Pickup = "pickup", Pickup = "pickup",
AutoRefund = "auto-refund",
User = "user", User = "user",
Bank = "bank", Bank = "bank",
ClaimProposal = "claim-proposal",
CheckRefunds = "check-refunds",
Repurchase = "repurchase",
BankRegisterReserve = "bank-register-reserve", BankRegisterReserve = "bank-register-reserve",
BankConfirmTransfer = "bank-confirm-transfer", BankConfirmTransfer = "bank-confirm-transfer",
WithdrawCoins = "withdraw-coins", WithdrawCoins = "withdraw-coins",
ExchangeWaitReserve = "exchange-wait-reserve", ExchangeWaitReserve = "exchange-wait-reserve",
AbortingBank = "aborting-bank", AbortingBank = "aborting-bank",
Refused = "refused",
} }
export interface TransactionsResponse { export interface TransactionsResponse {

View File

@ -71,6 +71,8 @@ import {
TalerErrorDetail, TalerErrorDetail,
TalerProtocolTimestamp, TalerProtocolTimestamp,
TalerProtocolViolationError, TalerProtocolViolationError,
TransactionMajorState,
TransactionMinorState,
TransactionState, TransactionState,
TransactionType, TransactionType,
URL, URL,
@ -2477,8 +2479,65 @@ export async function abortPay(
}); });
} }
export function computeWithdrawalTransactionStatus( export function computePayMerchantTransactionState(
purchaseRecord: PurchaseRecord, purchaseRecord: PurchaseRecord,
): TransactionState { ): TransactionState {
throw Error("not implemented"); switch (purchaseRecord.purchaseStatus) {
case PurchaseStatus.DownloadingProposal:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.ClaimProposal,
};
case PurchaseStatus.Paid:
return {
major: TransactionMajorState.Done,
};
case PurchaseStatus.PaymentAbortFinished:
return {
major: TransactionMajorState.Aborted,
};
case PurchaseStatus.Proposed:
return {
major: TransactionMajorState.Dialog,
};
case PurchaseStatus.ProposalDownloadFailed:
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,
minor: TransactionMinorState.Pay,
};
case PurchaseStatus.PayingReplay:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.RebindSession,
};
case PurchaseStatus.ProposalRefused:
return {
major: TransactionMajorState.Failed,
minor: TransactionMinorState.Refused,
};
case PurchaseStatus.QueryingAutoRefund:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.AutoRefund,
};
case PurchaseStatus.QueryingRefund:
return {
major: TransactionMajorState.Pending,
minor: TransactionMinorState.CheckRefunds,
};
}
} }

View File

@ -88,6 +88,7 @@ import {
import { getExchangeDetails } from "./exchanges.js"; import { getExchangeDetails } from "./exchanges.js";
import { import {
abortPay, abortPay,
computePayMerchantTransactionState,
expectProposalDownload, expectProposalDownload,
extractContractData, extractContractData,
processPurchasePay, processPurchasePay,
@ -1030,7 +1031,7 @@ async function buildTransactionForPurchase(
return { return {
type: TransactionType.Payment, type: TransactionType.Payment,
txState: mkTxStateUnknown(), txState: computePayMerchantTransactionState(purchaseRecord),
amountRaw: Amounts.stringify(contractData.amount), amountRaw: Amounts.stringify(contractData.amount),
amountEffective: Amounts.stringify(purchaseRecord.payInfo.totalPayCost), amountEffective: Amounts.stringify(purchaseRecord.payInfo.totalPayCost),
totalRefundRaw: Amounts.stringify(totalRefund.raw), totalRefundRaw: Amounts.stringify(totalRefund.raw),