buildSource example

->willReturn($this->ids->get('shop-id'));

        $appPayloadServiceHelper = new AppPayloadServiceHelper(
            static::createMock(DefinitionInstanceRegistry::class),
            static::createMock(JsonEntityEncoder::class),
            $shopIdProvider
        );

        $app = new AppEntity();
        $app->setVersion('1.0.0');

        $source = $appPayloadServiceHelper->buildSource($app, 'https://shopware.com');

        static::assertInstanceOf(Source::class$source);

        static::assertSame('https://shopware.com', $source->getUrl());
        static::assertSame($this->ids->get('shop-id')$source->getShopId());
        static::assertSame('1.0.0', $source->getAppVersion());
    }

    public function testEncode(): void
    {
        $context = new Context(new SystemSource());
        
return $responseClass::create($transactionIdjson_decode($content, true, 512, \JSON_THROW_ON_ERROR));
        } catch (GuzzleException) {
            return null;
        }
    }

    /** * @return array<string, mixed> */
    private function getRequestOptions(SourcedPayloadInterface $payload, AppEntity $app, Context $context): array
    {
        $payload->setSource($this->buildSource($app));
        $encoded = $this->encode($payload);
        $jsonPayload = json_encode($encoded, \JSON_THROW_ON_ERROR);

        if (!$jsonPayload) {
            if ($payload instanceof PaymentPayloadInterface) {
                throw PaymentException::asyncProcessInterrupted($payload->getOrderTransaction()->getId(), \sprintf('Empty payload, got: %s', var_export($jsonPayload, true)));
            }

            throw PaymentException::validatePreparedPaymentInterrupted(\sprintf('Empty payload, got: %s', var_export($jsonPayload, true)));
        }

        
return $responseClass::create($transactionId, \json_decode($content, true, 512, \JSON_THROW_ON_ERROR));
        } catch (GuzzleException) {
            return null;
        }
    }

    /** * @return array<string, mixed> */
    private function getRequestOptions(SourcedPayloadInterface $payload, AppEntity $app, Context $context): array
    {
        $payload->setSource($this->helper->buildSource($app$this->shopUrl));
        $encoded = $this->helper->encode($payload);
        $jsonPayload = json_encode($encoded, \JSON_THROW_ON_ERROR);

        if (!$jsonPayload) {
            if ($payload instanceof PaymentPayloadInterface) {
                throw PaymentException::asyncProcessInterrupted($payload->getOrderTransaction()->getId(), \sprintf('Empty payload, got: %s', var_export($jsonPayload, true)));
            }

            throw PaymentException::validatePreparedPaymentInterrupted(\sprintf('Empty payload, got: %s', var_export($jsonPayload, true)));
        }

        
return TaxProviderResponse::create(\json_decode($content, true, 512, \JSON_THROW_ON_ERROR));
        } catch (GuzzleException) {
            return null;
        }
    }

    /** * @return array<string, mixed> */
    private function getRequestOptions(TaxProviderPayload $payload, AppEntity $app, Context $context): array
    {
        $payload->setSource($this->helper->buildSource($app$this->shopUrl));
        $encoded = $this->helper->encode($payload);
        $jsonPayload = \json_encode($encoded, \JSON_THROW_ON_ERROR);

        if (!$jsonPayload) {
            throw new BadRequestHttpException(\sprintf('Empty payload, got: %s', \var_export($jsonPayload, true)));
        }

        $secret = $app->getAppSecret();

        if (!$secret) {
            throw AppException::registrationFailed($app->getName(), 'App secret is missing');
        }
Home | Imprint | This part of the site doesn't use cookies.