if the order is not found, marked the payment as failed
This commit is contained in:
parent
8d59e71724
commit
da5b42025a
@ -1942,50 +1942,6 @@ export async function processPurchasePay(
|
||||
};
|
||||
}
|
||||
|
||||
if (resp.status === HttpStatusCode.BadRequest) {
|
||||
const errDetails = await readUnexpectedResponseDetails(resp);
|
||||
logger.warn("unexpected 400 response for /pay");
|
||||
logger.warn(j2s(errDetails));
|
||||
await ws.db
|
||||
.mktx((x) => [x.purchases])
|
||||
.runReadWrite(async (tx) => {
|
||||
const purch = await tx.purchases.get(proposalId);
|
||||
if (!purch) {
|
||||
return;
|
||||
}
|
||||
// FIXME: Should be some "PayPermanentlyFailed" and error info should be stored
|
||||
purch.purchaseStatus = PurchaseStatus.PaymentAbortFinished;
|
||||
await tx.purchases.put(purch);
|
||||
});
|
||||
throw makePendingOperationFailedError(
|
||||
errDetails,
|
||||
TransactionType.Payment,
|
||||
proposalId,
|
||||
);
|
||||
}
|
||||
|
||||
if (resp.status === HttpStatusCode.Gone) {
|
||||
const errDetails = await readUnexpectedResponseDetails(resp);
|
||||
logger.warn("unexpected 410 response for /pay");
|
||||
logger.warn(j2s(errDetails));
|
||||
await ws.db
|
||||
.mktx((x) => [x.purchases])
|
||||
.runReadWrite(async (tx) => {
|
||||
const purch = await tx.purchases.get(proposalId);
|
||||
if (!purch) {
|
||||
return;
|
||||
}
|
||||
// FIXME: Should be some "PayPermanentlyFailed" and error info should be stored
|
||||
purch.purchaseStatus = PurchaseStatus.PaymentAbortFinished;
|
||||
await tx.purchases.put(purch);
|
||||
});
|
||||
throw makePendingOperationFailedError(
|
||||
errDetails,
|
||||
TransactionType.Payment,
|
||||
proposalId,
|
||||
);
|
||||
}
|
||||
|
||||
if (resp.status === HttpStatusCode.Conflict) {
|
||||
const err = await readTalerErrorResponse(resp);
|
||||
if (
|
||||
@ -2012,6 +1968,29 @@ export async function processPurchasePay(
|
||||
result: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
if (resp.status >= 400 && resp.status <= 499) {
|
||||
const errDetails = await readUnexpectedResponseDetails(resp);
|
||||
logger.warn(`server returned ${resp.status} response for /pay`);
|
||||
logger.warn(j2s(errDetails));
|
||||
await ws.db
|
||||
.mktx((x) => [x.purchases])
|
||||
.runReadWrite(async (tx) => {
|
||||
const purch = await tx.purchases.get(proposalId);
|
||||
if (!purch) {
|
||||
return;
|
||||
}
|
||||
// FIXME: Should be some "PayPermanentlyFailed" and error info should be stored
|
||||
purch.purchaseStatus = PurchaseStatus.PaymentAbortFinished;
|
||||
await tx.purchases.put(purch);
|
||||
});
|
||||
throw makePendingOperationFailedError(
|
||||
errDetails,
|
||||
TransactionType.Payment,
|
||||
proposalId,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const merchantResp = await readSuccessResponseJsonOrThrow(
|
||||
|
Loading…
Reference in New Issue
Block a user