From ce60f83bab1cae9745e19ad61e4a9f0be83b8531 Mon Sep 17 00:00:00 2001 From: martijn Date: Thu, 18 Mar 2021 11:56:01 +0100 Subject: [PATCH] fix(core): Made addPaymentToOrder channel aware solves #773 --- .../src/service/services/payment-method.service.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/core/src/service/services/payment-method.service.ts b/packages/core/src/service/services/payment-method.service.ts index bf7318ae47..e9eb0173d8 100644 --- a/packages/core/src/service/services/payment-method.service.ts +++ b/packages/core/src/service/services/payment-method.service.ts @@ -134,12 +134,13 @@ export class PaymentMethodService { handler: PaymentMethodHandler; checker: PaymentMethodEligibilityChecker | null; }> { - const paymentMethod = await this.connection.getRepository(ctx, PaymentMethod).findOne({ - where: { - code: method, - enabled: true, - }, - }); + const paymentMethod = await this.connection + .getRepository(ctx, PaymentMethod) + .createQueryBuilder('method') + .leftJoin('method.channels', 'channel') + .where('method.code = :code', { code: method }) + .andWhere('channel.id = :channelId', { channelId: ctx.channelId }) + .getOne(); if (!paymentMethod) { throw new UserInputError(`error.payment-method-not-found`, { method }); }