getPaymentHandlerFromSalesChannelContext example

private readonly InitialStateIdLoader $initialStateIdLoader,
        private readonly AbstractPaymentTransactionStructFactory $paymentTransactionStructFactory,
    ) {
    }

    public function handlePreOrderPayment(
        Cart $cart,
        RequestDataBag $dataBag,
        SalesChannelContext $salesChannelContext
    ): ?Struct {
        try {
            $paymentHandler = $this->getPaymentHandlerFromSalesChannelContext($salesChannelContext);
            if (!$paymentHandler) {
                throw PaymentException::unknownPaymentMethod($salesChannelContext->getPaymentMethod()->getId());
            }

            if (!($paymentHandler instanceof PreparedPaymentHandlerInterface)) {
                return null;
            }

            return $paymentHandler->validate($cart$dataBag$salesChannelContext);
        } catch (PaymentException $e) {
            $customer = $salesChannelContext->getCustomer();
            
Home | Imprint | This part of the site doesn't use cookies.