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, Mollie): Ignore completed state to prevent unneccesary error throwing #2569

Merged
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
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