Skip to content

Commit

Permalink
fix(payments-plugin): Mollie - ignore completed state to prevent unne…
Browse files Browse the repository at this point in the history
…ccesary error throwing (#2569)
  • Loading branch information
martijnvdbrug authored Dec 11, 2023
1 parent 40ac416 commit ed80c68
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/payments-plugin/src/mollie/mollie.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class MollieService {
orderInput.method = molliePaymentMethodCode as MollieClientMethod;
}
const mollieOrder = await mollieClient.orders.create(orderInput);
Logger.info(`Created Mollie order ${mollieOrder.id} for order ${order.code}`);
Logger.info(`Created Mollie order ${mollieOrder.id} for order ${order.code}`, loggerCtx);
const url = mollieOrder.getCheckoutUrl();
if (!url) {
throw Error('Unable to getCheckoutUrl() from Mollie order');
Expand Down Expand Up @@ -255,6 +255,11 @@ export class MollieService {
if (order.state === 'PaymentAuthorized' && mollieOrder.status === OrderStatus.completed) {
return this.settleExistingPayment(ctx, order, mollieOrder.id);
}
if (autoCapture && mollieOrder.status === OrderStatus.completed) {
// When autocapture is enabled, we should not handle the completed status from Mollie,
// because the order will be transitioned to PaymentSettled during auto capture
return;
}
// Any other combination of Mollie status and Vendure status indicates something is wrong.
throw Error(
`Unhandled incoming Mollie status '${mollieOrder.status}' for order ${order.code} with status '${order.state}'`,
Expand Down

0 comments on commit ed80c68

Please sign in to comment.