getPaymentHandlerById example

throw PaymentException::invalidToken($paymentToken);
        }

        $transactionId = $token->getTransactionId();

        if ($transactionId === null || !Uuid::isValid($transactionId)) {
            throw PaymentException::asyncProcessInterrupted((string) $transactionId, 'Payment JWT didn\'t contain a valid orderTransactionId');
        }

        $transaction = $this->getPaymentTransactionStruct($transactionId$context);

        $paymentHandler = $this->getPaymentHandlerById($token->getPaymentMethodId());

        try {
            $paymentHandler->finalize($transaction$request$context);
        } catch (CustomerCanceledAsyncPaymentException|PaymentException $e) {
            if ($e->getErrorCode() === PaymentException::PAYMENT_CUSTOMER_CANCELED_EXTERNAL) {
                $this->transactionStateHandler->cancel($transactionId$context->getContext());
            } else {
                $this->logger->error('An error occurred during finalizing async payment', ['orderTransactionId' => $transactionId, 'exceptionMessage' => $e->getMessage()]);
                $this->transactionStateHandler->fail($transactionId$context->getContext());
            }
            $token->setException($e);
        }
Home | Imprint | This part of the site doesn't use cookies.