fix: withdrawal error when creating an invoice
This commit is contained in:
parent
b0258d1909
commit
5e129abe9e
@ -29,6 +29,7 @@ import {
|
|||||||
PaymentStatus,
|
PaymentStatus,
|
||||||
PeerContractTerms,
|
PeerContractTerms,
|
||||||
RefundInfoShort,
|
RefundInfoShort,
|
||||||
|
TalerErrorCode,
|
||||||
TalerProtocolTimestamp,
|
TalerProtocolTimestamp,
|
||||||
Transaction,
|
Transaction,
|
||||||
TransactionByIdRequest,
|
TransactionByIdRequest,
|
||||||
@ -402,8 +403,23 @@ function buildTransactionForPullPaymentCredit(
|
|||||||
wsr: WithdrawalGroupRecord,
|
wsr: WithdrawalGroupRecord,
|
||||||
ort?: OperationRetryRecord,
|
ort?: OperationRetryRecord,
|
||||||
): Transaction {
|
): Transaction {
|
||||||
if (wsr.wgInfo.withdrawalType !== WithdrawalRecordType.PeerPullCredit)
|
if (wsr.wgInfo.withdrawalType !== WithdrawalRecordType.PeerPullCredit) {
|
||||||
throw Error("");
|
throw Error(`Unexpected withdrawalType: ${wsr.wgInfo.withdrawalType}`);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* FIXME: this should be handled in the withdrawal process.
|
||||||
|
* PeerPull withdrawal fails until reserve have funds but it is not
|
||||||
|
* an error from the user perspective.
|
||||||
|
*/
|
||||||
|
const silentWithdrawalErrorForInvoice =
|
||||||
|
ort?.lastError &&
|
||||||
|
ort.lastError.code === TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE &&
|
||||||
|
Object.values(ort.lastError.errorsPerCoin ?? {}).every((e) => {
|
||||||
|
return (
|
||||||
|
e.code === TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR &&
|
||||||
|
e.httpStatusCode === 409
|
||||||
|
);
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
type: TransactionType.PeerPullCredit,
|
type: TransactionType.PeerPullCredit,
|
||||||
amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
|
amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
|
||||||
@ -427,7 +443,9 @@ function buildTransactionForPullPaymentCredit(
|
|||||||
wsr.withdrawalGroupId,
|
wsr.withdrawalGroupId,
|
||||||
),
|
),
|
||||||
frozen: false,
|
frozen: false,
|
||||||
...(ort?.lastError ? { error: ort.lastError } : {}),
|
...(ort?.lastError
|
||||||
|
? { error: silentWithdrawalErrorForInvoice ? undefined : ort.lastError }
|
||||||
|
: {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user