Skip to content

Commit

Permalink
Fix(payments-plugin): Only find payment methods in the current channel (
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnvdbrug authored Jul 25, 2023
1 parent 2814142 commit bbea693
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/payments-plugin/src/stripe/stripe.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
Order,
OrderService,
PaymentMethod,
PaymentMethodService,
RequestContext,
RequestContextService,
TransactionalConnection,
} from '@vendure/core';
import { OrderStateTransitionError } from '@vendure/core/dist/common/error/generated-graphql-shop-errors';
import { Response } from 'express';
Expand All @@ -26,7 +26,7 @@ const noPaymentIntentErrorMessage = 'No payment intent in the event payload';
@Controller('payments')
export class StripeController {
constructor(
private connection: TransactionalConnection,
private paymentMethodService: PaymentMethodService,
private orderService: OrderService,
private stripeService: StripeService,
private requestContextService: RequestContextService,
Expand Down Expand Up @@ -124,10 +124,9 @@ export class StripeController {
}

private async getPaymentMethod(ctx: RequestContext): Promise<PaymentMethod> {
const method = (await this.connection.getRepository(ctx, PaymentMethod).find()).find(
const method = (await this.paymentMethodService.findAll(ctx)).items.find(
m => m.handler.code === stripePaymentMethodHandler.code,
);

if (!method) {
throw new InternalServerError(`[${loggerCtx}] Could not find Stripe PaymentMethod`);
}
Expand Down

0 comments on commit bbea693

Please sign in to comment.