Skip to content

Commit

Permalink
fix(payments-plugin): False positive error logging fix
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnvdbrug committed Nov 29, 2024
1 parent 0f1702f commit 3260fa6
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/payments-plugin/src/mollie/mollie.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,21 @@ export class MollieService {
`Unable to find order ${mollieOrder.orderNumber}, unable to process Mollie order ${mollieOrder.id}`,
);
}
if (mollieOrder.status === OrderStatus.expired) {
// Expired is fine, a customer can retry the payment later
const mollieStatesThatRequireAction: OrderStatus[] = [
OrderStatus.completed,
OrderStatus.authorized,
OrderStatus.paid,
];
if (!mollieStatesThatRequireAction.includes(mollieOrder.status)) {
// No need to handle this mollie webhook status
Logger.info(
`Ignoring Mollie status '${mollieOrder.status}' from incoming webhook for '${order.code}'`,
loggerCtx,
);
return;
}
if (order.orderPlacedAt) {
// Verify if the Vendure order isn't already paid for, and log if so
const paymentWithSameTransactionId = order.payments.find(
p => p.transactionId === mollieOrder.id && p.state === 'Settled',
);
const paymentWithSameTransactionId = order.payments.find(p => p.transactionId === mollieOrder.id);
if (!paymentWithSameTransactionId) {
// The order is paid for again, with another transaction ID. This means the customer paid twice
Logger.error(
Expand All @@ -297,14 +303,14 @@ export class MollieService {
return;
}
}
const statesThatRequireAction: OrderState[] = [
const vendureStatesThatRequireAction: OrderState[] = [
'AddingItems',
'ArrangingPayment',
'ArrangingAdditionalPayment',
'PaymentAuthorized',
'Draft',
];
if (!statesThatRequireAction.includes(order.state)) {
if (!vendureStatesThatRequireAction.includes(order.state)) {
// If order is not in one of these states, we don't need to handle the Mollie webhook
Logger.info(
`Order ${order.code} is already '${order.state}', no need for handling Mollie status '${mollieOrder.status}'`,
Expand Down

0 comments on commit 3260fa6

Please sign in to comment.