Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(payments-plugin): False positive error logging fix #3245

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
);
michaelbromley marked this conversation as resolved.
Show resolved Hide resolved
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)) {
michaelbromley marked this conversation as resolved.
Show resolved Hide resolved
// 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
Loading