getProcessUrl example



    private function buildTaxes(
        TaxProviderCollection $providers,
        Cart $cart,
        SalesChannelContext $context,
        TaxProviderExceptions $exceptions,
    ): ?TaxProviderResult {
        /** @var TaxProviderEntity $providerEntity */
        foreach ($providers->getElements() as $providerEntity) {
            // app providers             if ($providerEntity->getApp() && $providerEntity->getProcessUrl()) {
                return $this->handleAppRequest($providerEntity->getApp()$providerEntity->getProcessUrl()$cart$context);
            }

            $provider = $this->registry->get($providerEntity->getIdentifier());

            if (!$provider) {
                $exceptions->add(
                    $providerEntity->getIdentifier(),
                    new NotFoundHttpException(\sprintf('No tax provider found for identifier %s', $providerEntity->getIdentifier()))
                );

                
$taxProvider->getIdentifier()
            );

            /** @var TaxProviderEntity|null $existing */
            $existing = $existingTaxProviders->filterByProperty('identifier', $payload['identifier'])->first();

            if ($existing) {
                $payload['id'] = $existing->getId();
            }

            $payload['appId'] = $appId;
            $payload['processUrl'] = $taxProvider->getProcessUrl();

            $upserts[] = $payload;
        }

        $this->taxProviderRepository->upsert($upserts$context);
    }

    private function getExistingTaxProviders(string $appId, Context $context): TaxProviderCollection
    {
        $criteria = new Criteria();

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

        static::assertNotNull($manifest->getTax());
        static::assertCount(2, $manifest->getTax()->getTaxProviders());

        $firstProvider = $manifest->getTax()->getTaxProviders()[0];
        static::assertNotNull($firstProvider);
        static::assertSame('myTaxProvider', $firstProvider->getIdentifier());
        static::assertSame('My tax provider', $firstProvider->getName());
        static::assertSame('https://tax-provider.app/process', $firstProvider->getProcessUrl());

        $secondProvider = $manifest->getTax()->getTaxProviders()[1];
        static::assertNotNull($secondProvider);
        static::assertSame('mySecondTaxProvider', $secondProvider->getIdentifier());
        static::assertSame('My second tax provider', $secondProvider->getName());
        static::assertSame('https://tax-provider-2.app/process', $secondProvider->getProcessUrl());
    }

    public function testItThrowsOnMissingIdentifier(): void
    {
        static::expectException(XmlParsingException::class);
        
$taxProvider->setName($provider->getName());
            $taxProvider->setIdentifier(
                \sprintf('app\\%s_%s', $appName ?? self::META_APP_NAME, $provider->getIdentifier()),
            );

            $result->add($taxProvider);

            if (!$appId || !$appName) {
                continue;
            }

            $taxProvider->setProcessUrl($provider->getProcessUrl());
            $taxProvider->setAppId($appId);
        }

        return new EntitySearchResult(
            TaxProviderDefinition::ENTITY_NAME,
            $result->count(),
            $result,
            null,
            new Criteria(),
            Context::createDefaultContext()
        );
    }

    public function getTaxProviders(): array
    {
        return $this->taxProviders;
    }

    /** * @return array<string> */
    public function getUrls(): array
    {
        return \array_map(fn (TaxProvider $taxProvider) => $taxProvider->getProcessUrl()$this->taxProviders);
    }

    /** * @return TaxProvider[] */
    private static function parseTaxProviders(\DOMElement $element): array
    {
        $taxProviders = [];

        foreach ($element->getElementsByTagName('tax-provider') as $taxProvider) {
            $taxProviders[] = TaxProvider::fromXml($taxProvider);
        }
Home | Imprint | This part of the site doesn't use cookies.