getHandlerIdentifier example

$this->paymentRepository->create($paymentMethod$defaultContext);

        $criteria = new Criteria([$this->paymentMethodId]);

        $resultSet = $this->paymentRepository->search($criteria$defaultContext);

        /** @var PaymentMethodEntity $paymentMethod */
        $paymentMethod = $resultSet->filterByProperty('id', $this->paymentMethodId)
            ->getElements()[$this->paymentMethodId];

        static::assertSame(DefaultPayment::class$paymentMethod->getHandlerIdentifier());
    }

    public function testThrowsExceptionIfNotAllRequiredValuesAreGiven(): void
    {
        $defaultContext = Context::createDefaultContext();
        $paymentMethod = $this->createPaymentMethodDummyArray();

        unset($paymentMethod[0]['name']);

        try {
            $this->paymentRepository->create($paymentMethod$defaultContext);

            
if ($transaction === null) {
            return;
        }

        $paymentMethod = $transaction->getPaymentMethod();
        if ($paymentMethod === null) {
            throw PaymentException::unknownPaymentMethod($transaction->getPaymentMethodId());
        }

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

        $struct = $this->paymentTransactionStructFactory->recurring($transaction$order);

        try {
            $paymentHandler->captureRecurring($struct$context);
        } catch (PaymentException $e) {
            $this->stateHandler->fail($transaction->getId()$context);

            throw $e;
        }
    }
PaymentEvents::PAYMENT_METHOD_LOADED_EVENT => 'formatHandlerIdentifier',
            'payment_method.partial_loaded' => 'formatHandlerIdentifier',
        ];
    }

    public function formatHandlerIdentifier(EntityLoadedEvent $event): void
    {
        /** @var Entity $entity */
        foreach ($event->getEntities() as $entity) {
            $entity->assign([
                'shortName' => $this->getShortName($entity),
                'formattedHandlerIdentifier' => $this->getHandlerIdentifier($entity),
                'synchronous' => $this->isSynchronous($entity),
                'asynchronous' => $this->isAsynchronous($entity),
                'prepared' => $this->isPrepared($entity),
                'refundable' => $this->isRefundable($entity),
                'recurring' => $this->isRecurring($entity),
            ]);
        }
    }

    private function getHandlerIdentifier(Entity $entity): string
    {
        
Home | Imprint | This part of the site doesn't use cookies.