loadOrder example

$this->expectException(PaymentException::class);
        $this->expectExceptionMessageMatches('/Invalid app response/');
        $this->preparedPaymentService->handlePreOrderPayment($cartnew RequestDataBag()$salesChannelContext);
    }

    public function testCapture(): void
    {
        $paymentMethodId = $this->getPaymentMethodId('prepared');
        $orderId = $this->createOrder($paymentMethodId);
        $transactionId = $this->createTransaction($orderId$paymentMethodId);
        $salesChannelContext = $this->getSalesChannelContext($paymentMethodId);
        $order = $this->loadOrder($orderId$salesChannelContext);

        $response = new CaptureResponse();
        $this->appendNewResponse($this->signResponse($response->jsonSerialize()));

        $this->preparedPaymentService->handlePostOrderPayment($ordernew RequestDataBag()$salesChannelContextnew ArrayStruct(['test' => 'test']));

        /** @var Request $request */
        $request = $this->getLastRequest();
        $body = $request->getBody()->getContents();

        $appSecret = $this->app->getAppSecret();
        
public function load(array $args): ?OrderEntity
    {
        Feature::triggerDeprecationOrThrow(
            'v6_6_0_0',
            Feature::deprecatedMethodMessage(self::class, __METHOD__, '6.6.0.0')
        );

        [$orderId$context] = $args;

        $criteria = new Criteria([$orderId]);

        return $this->loadOrder($criteria$context$orderId);
    }

    private function lazyLoad(StorableFlow $storableFlow): ?OrderEntity
    {
        $id = $storableFlow->getStore(OrderAware::ORDER_ID);
        if ($id === null) {
            return null;
        }

        $criteria = new Criteria([$id]);

        
$this->expectExceptionMessage(\sprintf('The payment method %s could not be found.', $paymentMethodId));
        $this->paymentService->handlePreOrderPayment($cartnew RequestDataBag()$salesChannelContext);
    }

    public function testHandlePostOrderPayment(): void
    {
        $paymentMethodId = $this->createPaymentMethod($this->context);
        $customerId = $this->createCustomer($this->context);
        $salesChannelContext = $this->getSalesChannelContext($paymentMethodId);
        $orderId = $this->createOrder($customerId$paymentMethodId$salesChannelContext->getContext());
        $this->createTransaction($orderId$paymentMethodId$salesChannelContext->getContext());
        $order = $this->loadOrder($orderId$salesChannelContext);
        $struct = new ArrayStruct(['testStruct']);

        $this->paymentService->handlePostOrderPayment($ordernew RequestDataBag()$salesChannelContext$struct);

        static::assertSame($struct, PreparedTestPaymentHandler::$preOrderPaymentStruct);
    }

    public function testHandlePostOrderPaymentWithoutStruct(): void
    {
        $paymentMethodId = $this->createPaymentMethod($this->context);
        $customerId = $this->createCustomer($this->context);
        


    /** * @phpstan-ignore-next-line setter name is misleading, but kept for BC */
    #[Route(path: '/store-api/order/payment', name: 'store-api.order.set-payment', methods: ['POST'], defaults: ['_loginRequired' => true, '_loginRequiredAllowGuest' => true])]     public function setPayment(Request $request, SalesChannelContext $context): SetPaymentOrderRouteResponse
    {
        $paymentMethodId = (string) $request->request->get('paymentMethodId');

        $orderId = (string) $request->request->get('orderId');
        $order = $this->loadOrder($orderId$context);

        $context = $this->orderConverter->assembleSalesChannelContext(
            $order,
            $context->getContext(),
            [SalesChannelContextService::PAYMENT_METHOD_ID => $paymentMethodId]
        );

        $this->validateRequest($context$paymentMethodId);

        $this->validatePaymentState($order);

        
Home | Imprint | This part of the site doesn't use cookies.