-check in integration test

This commit is contained in:
Florian Dold 2023-01-11 17:16:15 +01:00
parent 143a4fe4ac
commit 3641e4cf0c
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -2811,16 +2811,23 @@ export async function abortPay(
if (!purchase) { if (!purchase) {
throw Error("purchase not found"); throw Error("purchase not found");
} }
const oldStatus = purchase.purchaseStatus;
if (purchase.timestampFirstSuccessfulPay) { if (purchase.timestampFirstSuccessfulPay) {
// No point in aborting it. We don't even report an error. // No point in aborting it. We don't even report an error.
logger.warn(`tried to abort successful payment`); logger.warn(`tried to abort successful payment`);
return; return;
} }
if (purchase.purchaseStatus === PurchaseStatus.Paying) { if (oldStatus === PurchaseStatus.Paying) {
purchase.purchaseStatus = PurchaseStatus.AbortingWithRefund; purchase.purchaseStatus = PurchaseStatus.AbortingWithRefund;
} }
if (
cancelImmediately &&
oldStatus === PurchaseStatus.AbortingWithRefund
) {
purchase.purchaseStatus = PurchaseStatus.PaymentAbortFinished;
}
await tx.purchases.put(purchase); await tx.purchases.put(purchase);
await tx.operationRetries.delete(opId); if (oldStatus === PurchaseStatus.Paying) {
if (purchase.payInfo) { if (purchase.payInfo) {
const coinSel = purchase.payInfo.payCoinSelection; const coinSel = purchase.payInfo.payCoinSelection;
const currency = Amounts.currencyOf(purchase.payInfo.totalPayCost); const currency = Amounts.currencyOf(purchase.payInfo.totalPayCost);
@ -2839,6 +2846,8 @@ export async function abortPay(
RefreshReason.AbortPay, RefreshReason.AbortPay,
); );
} }
}
await tx.operationRetries.delete(opId);
}); });
runOperationWithErrorReporting(ws, opId, async () => { runOperationWithErrorReporting(ws, opId, async () => {