getFinalizeUrl example



    /** * @return array<string> */
    public function getUrls(): array
    {
        $urls = [];

        foreach ($this->paymentMethods as $paymentMethod) {
            $urls[] = $paymentMethod->getCaptureUrl();
            $urls[] = $paymentMethod->getFinalizeUrl();
            $urls[] = $paymentMethod->getValidateUrl();
            $urls[] = $paymentMethod->getPayUrl();
        }

        return array_filter($urls);
    }

    /** * @return PaymentMethod[] */
    private static function parsePaymentMethods(\DOMElement $element): array
    {
static::assertNotNull($paymentMethod);
        static::assertSame('The app payment method', $paymentMethod->getName());
        static::assertSame('handler_app_test_mymethod', $paymentMethod->getFormattedHandlerIdentifier());
        static::assertNotNull($paymentMethod->getMediaId());
        $fileLoader = $this->getContainer()->get(FileLoader::class);
        static::assertNotEmpty($fileLoader->loadMediaFile($paymentMethod->getMediaId()$this->context));
        $appPaymentMethod = $paymentMethod->getAppPaymentMethod();
        static::assertNotNull($appPaymentMethod);
        static::assertSame('test', $appPaymentMethod->getAppName());
        static::assertSame('myMethod', $appPaymentMethod->getIdentifier());
        static::assertSame('https://payment.app/payment/process', $appPaymentMethod->getPayUrl());
        static::assertSame('https://payment.app/payment/finalize', $appPaymentMethod->getFinalizeUrl());
    }

    private function assertDefaultCmsBlocks(string $appId): void
    {
        /** @var EntityRepository $cmsBlockRepository */
        $cmsBlockRepository = $this->getContainer()->get('app_cms_block.repository');

        $criteria = new Criteria();
        $criteria->addFilter(
            new EqualsFilter('appId', $appId)
        );

        
public function finalize(AsyncPaymentTransactionStruct $transaction, Request $request, SalesChannelContext $salesChannelContext): void
    {
        $queryParameters = $request->query->all();
        unset($queryParameters['_sw_payment_token']);

        $payload = $this->buildFinalizePayload($transaction$queryParameters);
        $app = $this->getAppPaymentMethod($transaction->getOrderTransaction())->getApp();
        if ($app === null) {
            throw PaymentException::asyncFinalizeInterrupted($transaction->getOrderTransaction()->getId(), 'App not defined');
        }

        $url = $this->getAppPaymentMethod($transaction->getOrderTransaction())->getFinalizeUrl();
        if ($url === null) {
            throw PaymentException::asyncFinalizeInterrupted($transaction->getOrderTransaction()->getId(), 'Finalize URL not defined');
        }

        try {
            $response = $this->payloadService->request($url$payload$app, AsyncFinalizeResponse::class$salesChannelContext->getContext());
        } catch (ClientExceptionInterface $exception) {
            throw PaymentException::asyncFinalizeInterrupted($transaction->getOrderTransaction()->getId()sprintf('App error: %s', $exception->getMessage()));
        }

        if (!$response instanceof AsyncFinalizeResponse) {
            
public function testFromXml(): void
    {
        $manifest = Manifest::createFromXmlFile(__DIR__ . '/../_fixtures/test/manifest.xml');

        static::assertNotNull($manifest->getPayments());
        static::assertCount(2, $manifest->getPayments()->getPaymentMethods());

        $firstWebhook = $manifest->getPayments()->getPaymentMethods()[0];
        static::assertNotNull($firstWebhook);
        static::assertSame('myMethod', $firstWebhook->getIdentifier());
        static::assertSame('https://payment.app/payment/process', $firstWebhook->getPayUrl());
        static::assertSame('https://payment.app/payment/finalize', $firstWebhook->getFinalizeUrl());
        static::assertSame('https://payment.app/payment/refund', $firstWebhook->getRefundUrl());
        static::assertSame('https://payment.app/payment/recurring', $firstWebhook->getRecurringUrl());
        static::assertSame('Resources/payment.png', $firstWebhook->getIcon());
        static::assertSame([
            'en-GB' => 'The app payment method',
            'de-DE' => 'Die App Zahlungsmethode',
        ]$firstWebhook->getName());
        static::assertSame([
            'en-GB' => 'This is a description',
            'de-DE' => 'Die Zahlungsmethoden-Beschreibung',
        ]$firstWebhook->getDescription());

        
public function testFromXml(): void
    {
        $manifest = Manifest::createFromXmlFile(__DIR__ . '/../_fixtures/test-manifest.xml');

        static::assertNotNull($manifest->getPayments());
        static::assertCount(2, $manifest->getPayments()->getPaymentMethods());

        $firstWebhook = $manifest->getPayments()->getPaymentMethods()[0];
        static::assertNotNull($firstWebhook);
        static::assertSame('myMethod', $firstWebhook->getIdentifier());
        static::assertSame('https://payment.app/payment/process', $firstWebhook->getPayUrl());
        static::assertSame('https://payment.app/payment/finalize', $firstWebhook->getFinalizeUrl());
        static::assertSame('https://payment.app/payment/refund', $firstWebhook->getRefundUrl());
        static::assertSame('https://payment.app/payment/recurring', $firstWebhook->getRecurringUrl());
        static::assertSame('Resources/payment.png', $firstWebhook->getIcon());
        static::assertSame([
            'en-GB' => 'The app payment method',
            'de-DE' => 'Die App Zahlungsmethode',
        ]$firstWebhook->getName());
        static::assertSame([
            'en-GB' => 'This is a description',
            'de-DE' => 'Die Zahlungsmethoden-Beschreibung',
        ]$firstWebhook->getDescription());

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