-check in integration test
This commit is contained in:
parent
143a4fe4ac
commit
3641e4cf0c
@ -2811,34 +2811,43 @@ 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;
|
||||||
}
|
}
|
||||||
await tx.purchases.put(purchase);
|
if (
|
||||||
await tx.operationRetries.delete(opId);
|
cancelImmediately &&
|
||||||
if (purchase.payInfo) {
|
oldStatus === PurchaseStatus.AbortingWithRefund
|
||||||
const coinSel = purchase.payInfo.payCoinSelection;
|
) {
|
||||||
const currency = Amounts.currencyOf(purchase.payInfo.totalPayCost);
|
purchase.purchaseStatus = PurchaseStatus.PaymentAbortFinished;
|
||||||
const refreshCoins: CoinRefreshRequest[] = [];
|
|
||||||
for (let i = 0; i < coinSel.coinPubs.length; i++) {
|
|
||||||
refreshCoins.push({
|
|
||||||
amount: coinSel.coinContributions[i],
|
|
||||||
coinPub: coinSel.coinPubs[i],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
await createRefreshGroup(
|
|
||||||
ws,
|
|
||||||
tx,
|
|
||||||
currency,
|
|
||||||
refreshCoins,
|
|
||||||
RefreshReason.AbortPay,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
await tx.purchases.put(purchase);
|
||||||
|
if (oldStatus === PurchaseStatus.Paying) {
|
||||||
|
if (purchase.payInfo) {
|
||||||
|
const coinSel = purchase.payInfo.payCoinSelection;
|
||||||
|
const currency = Amounts.currencyOf(purchase.payInfo.totalPayCost);
|
||||||
|
const refreshCoins: CoinRefreshRequest[] = [];
|
||||||
|
for (let i = 0; i < coinSel.coinPubs.length; i++) {
|
||||||
|
refreshCoins.push({
|
||||||
|
amount: coinSel.coinContributions[i],
|
||||||
|
coinPub: coinSel.coinPubs[i],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await createRefreshGroup(
|
||||||
|
ws,
|
||||||
|
tx,
|
||||||
|
currency,
|
||||||
|
refreshCoins,
|
||||||
|
RefreshReason.AbortPay,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await tx.operationRetries.delete(opId);
|
||||||
});
|
});
|
||||||
|
|
||||||
runOperationWithErrorReporting(ws, opId, async () => {
|
runOperationWithErrorReporting(ws, opId, async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user