getPaymentMethodHandler example

// a specific handler type was requested         if ($expectedHandlerType !== null && !\is_a($handler$expectedHandlerType, true)) {
            return null;
        }

        return $this->handlers[$handlerIdentifier];
    }

    public function getSyncPaymentHandler(string $paymentMethodId): ?SynchronousPaymentHandlerInterface
    {
        $handler = $this->getPaymentMethodHandler($paymentMethodId, SynchronousPaymentHandlerInterface::class);

        if (!$handler instanceof SynchronousPaymentHandlerInterface) {
            return null;
        }

        return $handler;
    }

    public function getAsyncPaymentHandler(string $paymentMethodId): ?AsynchronousPaymentHandlerInterface
    {
        $handler = $this->getPaymentMethodHandler($paymentMethodId, AsynchronousPaymentHandlerInterface::class);

        
$appLifecycle->install($manifest, true, Context::createDefaultContext());
    }

    /** * @dataProvider paymentMethodDataProvider * * @param class-string<PaymentHandlerInterface> $handlerClass */
    public function testGetHandler(string $handlerName, string $handlerClass): void
    {
        $paymentMethod = $this->getPaymentMethod($handlerName);
        $handler = $this->paymentHandlerRegistry->getPaymentMethodHandler($paymentMethod->getId());
        static::assertInstanceOf($handlerClass$handler);
    }

    /** * @param array<class-string<PaymentHandlerInterface>> $handlerInstances * * @dataProvider paymentMethodDataProvider */
    public function testGetAsyncHandler(string $handlerName, string $handlerClass, array $handlerInstances): void
    {
        $paymentMethod = $this->getPaymentMethod($handlerName);
        


        $transactions = $transactions->filterByStateId(
            $this->initialStateIdLoader->get(OrderTransactionStates::STATE_MACHINE)
        );

        $transaction = $transactions->last();
        if ($transaction === null) {
            return null;
        }

        $paymentHandler = $this->paymentHandlerRegistry->getPaymentMethodHandler($transaction->getPaymentMethodId());
        if (!$paymentHandler) {
            throw PaymentException::unknownPaymentMethod($transaction->getPaymentMethodId());
        }

        if ($paymentHandler instanceof SynchronousPaymentHandlerInterface) {
            $paymentTransaction = $this->paymentTransactionStructFactory->sync($transaction$order);
            $paymentHandler->pay($paymentTransaction$dataBag$salesChannelContext);

            return null;
        }

        
return $transactions->last();
    }

    private function getPaymentHandlerFromTransaction(OrderTransactionEntity $transaction): PaymentHandlerInterface
    {
        $paymentMethod = $transaction->getPaymentMethod();
        if ($paymentMethod === null) {
            throw PaymentException::unknownPaymentMethod($transaction->getPaymentMethodId());
        }

        $paymentHandler = $this->paymentHandlerRegistry->getPaymentMethodHandler($paymentMethod->getId());
        if (!$paymentHandler) {
            throw PaymentException::unknownPaymentMethod($paymentMethod->getId());
        }

        return $paymentHandler;
    }

    private function getPaymentHandlerFromSalesChannelContext(SalesChannelContext $salesChannelContext): ?PaymentHandlerInterface
    {
        $paymentMethod = $salesChannelContext->getPaymentMethod();

        
->willReturn($qb);

        $registry = new PaymentHandlerRegistry(
            new ServiceLocator([]),
            new ServiceLocator([]),
            new ServiceLocator([]),
            new ServiceLocator([]),
            new ServiceLocator([]),
            $connection,
        );

        $registry->getPaymentMethodHandler($uuid, 'foo');
    }

    /** * @dataProvider appPaymentMethodUrlProvider * * @param array<string> $urls * @param class-string<PaymentHandlerInterface>|null $expectedResult */
    public function testRegistryAppPaymentMethodResolve(array $urls, ?string $testedType, ?string $expectedResult): void
    {
        $result = $this->createMock(Result::class);
        
Home | Imprint | This part of the site doesn't use cookies.