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

Revert "fix: Use default channel in Stripe webhook calls to reach all orders" #3139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 2 additions & 9 deletions packages/payments-plugin/src/stripe/stripe.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Controller, Headers, HttpStatus, Post, Req, Res } from '@nestjs/common';
import type { PaymentMethod, RequestContext } from '@vendure/core';
import { ChannelService } from '@vendure/core';
import {
InternalServerError,
LanguageCode,
Expand Down Expand Up @@ -32,7 +31,6 @@ export class StripeController {
private stripeService: StripeService,
private requestContextService: RequestContextService,
private connection: TransactionalConnection,
private channelService: ChannelService,
) {}

@Post('stripe')
Expand All @@ -59,7 +57,7 @@ export class StripeController {
const { metadata: { channelToken, orderCode, orderId } = {} } = paymentIntent;
const outerCtx = await this.createContext(channelToken, request);

await this.connection.withTransaction(outerCtx, async (ctx: RequestContext) => {
await this.connection.withTransaction(outerCtx, async ctx => {
const order = await this.orderService.findOneByCode(ctx, orderCode);

if (!order) {
Expand Down Expand Up @@ -92,13 +90,8 @@ export class StripeController {
}

if (order.state !== 'ArrangingPayment') {
// Orders can switch channels (e.g., global to UK store), causing lookups by the original
// channel to fail. Using a default channel avoids "entity-with-id-not-found" errors.
// See https://github.com/vendure-ecommerce/vendure/issues/3072
const defaultChannel = await this.channelService.getDefaultChannel(ctx);
const ctxWithDefaultChannel = await this.createContext(defaultChannel.token, request);
const transitionToStateResult = await this.orderService.transitionToState(
ctxWithDefaultChannel,
ctx,
orderId,
'ArrangingPayment',
);
Expand Down
Loading