diff --git a/src/Resources/views/storefront/payone/secured-invoice/secured-invoice.html.twig b/src/Resources/views/storefront/payone/secured-invoice/secured-invoice.html.twig
index 2af49fd45..d5c22e408 100644
--- a/src/Resources/views/storefront/payone/secured-invoice/secured-invoice.html.twig
+++ b/src/Resources/views/storefront/payone/secured-invoice/secured-invoice.html.twig
@@ -11,20 +11,7 @@
{% sw_include '@PayonePayment/storefront/payone/phone-number-input.html.twig' %}
-
- {% if customerCustomFields is null or customerCustomFields['payone_customer_birthday'] is not defined or customerCustomFields['payone_customer_birthday'] is empty %}
-
-
- {{ "PayonePayment.securedInvoice.birthday.label" | trans }}{{ "general.required"|trans|sw_sanitize }}
-
-
-
- {% endif %}
+ {% sw_include '@PayonePayment/storefront/payone/birthday-input.html.twig' %}
diff --git a/src/Storefront/Controller/CheckoutController.php b/src/Storefront/Controller/CheckoutController.php
index cf90810e7..29da1ec03 100644
--- a/src/Storefront/Controller/CheckoutController.php
+++ b/src/Storefront/Controller/CheckoutController.php
@@ -4,8 +4,7 @@
namespace PayonePayment\Storefront\Controller;
-use PayonePayment\Storefront\Struct\CheckoutCartPaymentData;
-use Shopware\Core\Checkout\Cart\SalesChannel\CartService;
+use PayonePayment\Components\GenericExpressCheckout\CartExtensionService;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Storefront\Controller\StorefrontController;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -19,7 +18,7 @@
class CheckoutController
{
public function __construct(
- private readonly CartService $cartService,
+ private readonly CartExtensionService $extensionService,
private readonly RouterInterface $router,
private readonly TranslatorInterface $translator
) {
@@ -30,9 +29,7 @@ public function deleteCheckoutData(
Request $request,
SalesChannelContext $salesChannelContext
): Response {
- $cart = $this->cartService->getCart($salesChannelContext->getToken(), $salesChannelContext);
- $cart->removeExtension(CheckoutCartPaymentData::EXTENSION_NAME);
- $this->cartService->recalculate($cart, $salesChannelContext);
+ $this->extensionService->removeExtensionData($salesChannelContext);
$session = $request->getSession();
if (method_exists($session, 'getFlashBag')) {
diff --git a/src/Storefront/Controller/GenericExpressController.php b/src/Storefront/Controller/GenericExpressController.php
index 802105385..e59334d06 100644
--- a/src/Storefront/Controller/GenericExpressController.php
+++ b/src/Storefront/Controller/GenericExpressController.php
@@ -12,7 +12,6 @@
use PayonePayment\Payone\Client\Exception\PayoneRequestException;
use PayonePayment\Payone\Client\PayoneClientInterface;
use PayonePayment\Payone\RequestParameter\RequestParameterFactory;
-use PayonePayment\Storefront\Struct\CheckoutCartPaymentData;
use RuntimeException;
use Shopware\Core\Checkout\Cart\SalesChannel\CartService;
use Shopware\Core\Checkout\Customer\SalesChannel\AbstractRegisterRoute;
@@ -90,7 +89,7 @@ public function redirectAction(SalesChannelContext $context, string $paymentMeth
throw new RuntimeException('generic express checkout: No redirect URL has been given for payment method id ' . $paymentMethodId);
}
- $this->cartExtensionService->addCartExtension($cart, $context, $response['workorderid']);
+ $this->cartExtensionService->addCartExtensionForExpressCheckout($cart, $context, $paymentMethodId, $response['workorderid']);
return new RedirectResponse($response['redirecturl']);
}
@@ -113,8 +112,7 @@ public function returnAction(SalesChannelContext $context, string $paymentMethod
$cart = $this->cartService->getCart($context->getToken(), $context);
- /** @var CheckoutCartPaymentData|null $cartExtension */
- $cartExtension = $cart->getExtension(CheckoutCartPaymentData::EXTENSION_NAME);
+ $cartExtension = $this->cartExtensionService->getCartExtensionForExpressCheckout($cart, $paymentMethodId);
if ($cartExtension === null) {
throw new RuntimeException($this->trans('PayonePayment.errorMessages.genericError'));
diff --git a/src/Storefront/Controller/Payolution/PayolutionController.php b/src/Storefront/Controller/Payolution/PayolutionController.php
index c87a5b3b2..9ca169520 100644
--- a/src/Storefront/Controller/Payolution/PayolutionController.php
+++ b/src/Storefront/Controller/Payolution/PayolutionController.php
@@ -6,6 +6,7 @@
use PayonePayment\Components\CartHasher\CartHasherInterface;
use PayonePayment\Components\ConfigReader\ConfigReaderInterface;
+use PayonePayment\Components\Helper\OrderFetcher;
use PayonePayment\Installer\ConfigInstaller;
use PayonePayment\PaymentHandler\PayonePayolutionInstallmentPaymentHandler;
use PayonePayment\PaymentHandler\PayonePayolutionInvoicingPaymentHandler;
@@ -17,10 +18,13 @@
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
use PayonePayment\Payone\RequestParameter\RequestParameterFactory;
use PayonePayment\Payone\RequestParameter\Struct\PayolutionAdditionalActionStruct;
+use PayonePayment\RequestConstants;
use PayonePayment\Storefront\Struct\CheckoutCartPaymentData;
use Psr\Log\LoggerInterface;
use Shopware\Core\Checkout\Cart\Cart;
+use Shopware\Core\Checkout\Cart\Order\OrderConverter;
use Shopware\Core\Checkout\Cart\SalesChannel\CartService;
+use Shopware\Core\Checkout\Order\OrderEntity;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Storefront\Controller\StorefrontController;
@@ -28,6 +32,7 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
use Symfony\Component\Routing\Annotation\Route;
@@ -42,7 +47,9 @@ public function __construct(
private readonly CartHasherInterface $cartHasher,
private readonly PayoneClientInterface $client,
private readonly RequestParameterFactory $requestParameterFactory,
- private readonly LoggerInterface $logger
+ private readonly LoggerInterface $logger,
+ private readonly OrderFetcher $orderFetcher,
+ private readonly OrderConverter $orderConverter
) {
}
@@ -98,11 +105,19 @@ public function validate(RequestDataBag $dataBag, SalesChannelContext $context):
return new JsonResponse($response);
}
- #[Route(path: '/payone/installment/calculation', name: 'frontend.payone.payolution.installment.calculation', options: ['seo' => false], defaults: ['XmlHttpRequest' => true], methods: ['POST'])]
- public function calculation(RequestDataBag $dataBag, SalesChannelContext $context): JsonResponse
+ #[Route(path: '/payone/installment/calculation/{orderId}', name: 'frontend.payone.payolution.installment.calculation', options: ['seo' => false], defaults: ['XmlHttpRequest' => true], methods: ['POST'])]
+ public function calculation(RequestDataBag $dataBag, SalesChannelContext $context, ?string $orderId = null): JsonResponse
{
try {
- $cart = $this->cartService->getCart($context->getToken(), $context);
+ if ($orderId) {
+ $order = $this->orderFetcher->getOrderById($orderId, $context->getContext());
+ if (!$order instanceof OrderEntity) {
+ throw new NotFoundHttpException();
+ }
+ $cart = $this->orderConverter->convertToCart($order, $context->getContext());
+ } else {
+ $cart = $this->cartService->getCart($context->getToken(), $context);
+ }
$checkRequest = $this->requestParameterFactory->getRequestParameter(
new PayolutionAdditionalActionStruct(
@@ -122,14 +137,14 @@ public function calculation(RequestDataBag $dataBag, SalesChannelContext $contex
}
// will be used inside the calculation request
- $dataBag->set('workorder', $response['workorderid']);
+ $dataBag->set(RequestConstants::WORK_ORDER_ID, $response['workorderid']);
$response['carthash'] = $this->cartHasher->generate($cart, $context);
} else {
$response = [
'status' => 'OK',
- 'workorderid' => $dataBag->get('workorder'),
- 'carthash' => $dataBag->get('carthash'),
+ 'workorderid' => $dataBag->get(RequestConstants::WORK_ORDER_ID),
+ 'carthash' => $dataBag->get(RequestConstants::CART_HASH),
];
}
@@ -140,7 +155,7 @@ public function calculation(RequestDataBag $dataBag, SalesChannelContext $contex
$context,
PayonePayolutionInstallmentPaymentHandler::class,
AbstractRequestParameterBuilder::REQUEST_ACTION_PAYOLUTION_CALCULATION,
- $dataBag->get('workorder')
+ $dataBag->get(RequestConstants::WORK_ORDER_ID)
)
);
@@ -302,13 +317,13 @@ private function prepareCalculationOutput(array $response): array
private function isPreCheckNeeded(Cart $cart, RequestDataBag $dataBag, SalesChannelContext $context): bool
{
- $cartHash = $dataBag->get('carthash');
+ $cartHash = $dataBag->get(RequestConstants::CART_HASH);
if (!$this->cartHasher->validate($cart, $cartHash, $context)) {
return true;
}
- if (empty($dataBag->get('workorder'))) {
+ if (empty($dataBag->get(RequestConstants::WORK_ORDER_ID))) {
return true;
}
diff --git a/src/apple-pay-cert/merchant_id.key b/src/apple-pay-cert/merchant_id.key
deleted file mode 100644
index e69de29bb..000000000
diff --git a/src/apple-pay-cert/merchant_id.pem b/src/apple-pay-cert/merchant_id.pem
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tests/Components/PaymentFilter/PayolutionPaymentFilterTest.php b/tests/Components/PaymentFilter/PayolutionPaymentFilterTest.php
index 66c5c2e9c..8252dc18a 100644
--- a/tests/Components/PaymentFilter/PayolutionPaymentFilterTest.php
+++ b/tests/Components/PaymentFilter/PayolutionPaymentFilterTest.php
@@ -9,6 +9,7 @@
use PayonePayment\PaymentHandler\PayonePayolutionInstallmentPaymentHandler;
use PayonePayment\PaymentHandler\PayonePayolutionInvoicingPaymentHandler;
use PayonePayment\TestCaseBase\ConfigurationHelper;
+use PayonePayment\TestCaseBase\Mock\PaymentHandler\PaymentHandlerMock;
use Shopware\Core\System\Currency\CurrencyEntity;
/**
@@ -26,6 +27,93 @@ protected function setUp(): void
$this->setPayoneConfig($this->getContainer(), 'payolutionInvoicingTransferCompanyData', true);
}
+ public function testIfInvoiceGotHiddenOnDisabledB2B(): void
+ {
+ $this->setPayoneConfig($this->getContainer(), 'payolutionInvoicingTransferCompanyData', false);
+
+ $methods = $this->getPaymentMethods(PayonePayolutionInvoicingPaymentHandler::class);
+
+ $salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
+ $salesChannelContext->getCustomer()->getActiveBillingAddress()->setCompany('not-empty');
+
+ $filterContext = new PaymentFilterContext($salesChannelContext, $salesChannelContext->getCustomer()->getActiveBillingAddress());
+ $filterService = $this->getFilterService(PayonePayolutionInvoicingPaymentHandler::class);
+
+ $result = $filterService->filterPaymentMethods($methods, $filterContext);
+ static::assertNotInPaymentCollection(PayonePayolutionInvoicingPaymentHandler::class, $result, 'unzer invoice should be removed, because B2B is not allowed');
+ static::assertInPaymentCollection(PaymentHandlerMock::class, $result, 'the PaymentHandlerMock should be never removed from the available payment-methods');
+
+ // test again, but now the payment method should be available, because we allow B2B
+ $this->setPayoneConfig($this->getContainer(), 'payolutionInvoicingTransferCompanyData', true);
+ $result = $filterService->filterPaymentMethods($methods, $filterContext);
+ static::assertInPaymentCollection(PayonePayolutionInvoicingPaymentHandler::class, $result, 'after enabling the B2B for invoice, the payment method should be available');
+ static::assertInPaymentCollection(PaymentHandlerMock::class, $result, 'the PaymentHandlerMock should be never removed from the available payment-methods');
+ }
+
+ /**
+ * @dataProvider dataProviderUnzerGotHiddenOnB2B
+ */
+ public function testIfUnzerGotHiddenOnB2B(string $paymentHandler): void
+ {
+ // should not take any effect. we enable it to make sure that this configuration got not applied on the other user-payment methods
+ $this->setPayoneConfig($this->getContainer(), 'payolutionInvoicingTransferCompanyData', true);
+
+ $methods = $this->getPaymentMethods($paymentHandler);
+
+ $salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
+ $salesChannelContext->getCustomer()->getActiveBillingAddress()->setCompany('not-empty');
+
+ $filterContext = new PaymentFilterContext($salesChannelContext, $salesChannelContext->getCustomer()->getActiveBillingAddress());
+ $filterService = $this->getFilterService($paymentHandler);
+
+ $result = $filterService->filterPaymentMethods($methods, $filterContext);
+ static::assertNotInPaymentCollection($paymentHandler, $result, $paymentHandler . ' should be removed, because B2B is not allowed');
+ static::assertInPaymentCollection(PaymentHandlerMock::class, $result, 'the PaymentHandlerMock should be never removed from the available payment-methods');
+ }
+
+ public static function dataProviderUnzerGotHiddenOnB2B(): array
+ {
+ return [
+ [PayonePayolutionDebitPaymentHandler::class],
+ [PayonePayolutionInstallmentPaymentHandler::class],
+ ];
+ }
+
+ /**
+ * @dataProvider dataProviderUnzerIsAlwaysAvailableForOnB2C
+ */
+ public function testIfUnzerIsAlwaysAvailableForOnB2C(string $paymentHandler): void
+ {
+ $methods = $this->getPaymentMethods($paymentHandler);
+
+ $salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
+ $salesChannelContext->getCustomer()->getActiveBillingAddress()->assign([
+ 'company' => null, // shopware does not allow setting null with setCompany().
+ ]);
+
+ $filterContext = new PaymentFilterContext($salesChannelContext, $salesChannelContext->getCustomer()->getActiveBillingAddress());
+ $filterService = $this->getFilterService($paymentHandler);
+
+ $this->setPayoneConfig($this->getContainer(), 'payolutionInvoicingTransferCompanyData', false);
+ $result = $filterService->filterPaymentMethods($methods, $filterContext);
+ static::assertInPaymentCollection($paymentHandler, $result);
+ static::assertInPaymentCollection(PaymentHandlerMock::class, $result);
+
+ $this->setPayoneConfig($this->getContainer(), 'payolutionInvoicingTransferCompanyData', true);
+ $result = $filterService->filterPaymentMethods($methods, $filterContext);
+ static::assertInPaymentCollection($paymentHandler, $result);
+ static::assertInPaymentCollection(PaymentHandlerMock::class, $result);
+ }
+
+ public static function dataProviderUnzerIsAlwaysAvailableForOnB2C(): array
+ {
+ return [
+ [PayonePayolutionInvoicingPaymentHandler::class],
+ [PayonePayolutionDebitPaymentHandler::class],
+ [PayonePayolutionInstallmentPaymentHandler::class],
+ ];
+ }
+
protected function getFilterService(?string $paymentHandlerClass = null): PaymentFilterServiceInterface
{
$serviceId = match ($paymentHandlerClass) {
diff --git a/tests/Components/PaymentFilter/TotalPriceFilterTest.php b/tests/Components/PaymentFilter/TotalPriceFilterTest.php
new file mode 100644
index 000000000..292962acc
--- /dev/null
+++ b/tests/Components/PaymentFilter/TotalPriceFilterTest.php
@@ -0,0 +1,135 @@
+createMock(SalesChannelContext::class),
+ $this->createMock(CustomerAddressEntity::class),
+ $this->createMock(CustomerAddressEntity::class),
+ $this->createMock(CurrencyEntity::class),
+ null,
+ $cartMock = $this->createMock(Cart::class)
+ );
+
+ $cartMock->method('getPrice')->willReturn($this->createPrice(0));
+ $collection = $filter->filterPaymentMethods($this->getMethodCollection(), $context);
+ static::assertCount(3, $collection->getElements());
+ static::assertPaymentMethodCount(3, DefaultPayment::class, $collection);
+ static::assertPaymentMethodCount(0, PayonePrepaymentPaymentHandler::class, $collection);
+
+ $cartMock->method('getPrice')->willReturn($this->createPrice(-100));
+ $collection = $filter->filterPaymentMethods($this->getMethodCollection(), $context);
+ static::assertCount(3, $collection->getElements());
+ static::assertPaymentMethodCount(3, DefaultPayment::class, $collection);
+ static::assertPaymentMethodCount(0, PayonePrepaymentPaymentHandler::class, $collection);
+ }
+
+ public function testIfRemovesAllMethodsIfPriceEqualZeroForOrder(): void
+ {
+ $filter = new TotalPriceFilter();
+
+ $context = new PaymentFilterContext(
+ $this->createMock(SalesChannelContext::class),
+ $this->createMock(CustomerAddressEntity::class),
+ $this->createMock(CustomerAddressEntity::class),
+ $this->createMock(CurrencyEntity::class),
+ null,
+ $cartMock = $this->createMock(Cart::class)
+ );
+
+ $cartMock->method('getPrice')->willReturn($this->createPrice(0));
+ $collection = $filter->filterPaymentMethods($this->getMethodCollection(), $context);
+ static::assertCount(3, $collection->getElements());
+ static::assertPaymentMethodCount(3, DefaultPayment::class, $collection);
+ static::assertPaymentMethodCount(0, PayonePrepaymentPaymentHandler::class, $collection);
+
+ $cartMock->method('getPrice')->willReturn($this->createPrice(-100));
+ $collection = $filter->filterPaymentMethods($this->getMethodCollection(), $context);
+ static::assertCount(3, $collection->getElements());
+ static::assertPaymentMethodCount(3, DefaultPayment::class, $collection);
+ static::assertPaymentMethodCount(0, PayonePrepaymentPaymentHandler::class, $collection);
+ }
+
+ public function testIfKeepsAllMethodsIfPriceHigherZeroForCart(): void
+ {
+ $filter = new TotalPriceFilter();
+
+ $context = new PaymentFilterContext(
+ $this->createMock(SalesChannelContext::class),
+ $this->createMock(CustomerAddressEntity::class),
+ $this->createMock(CustomerAddressEntity::class),
+ $this->createMock(CurrencyEntity::class),
+ $orderMock = $this->createMock(OrderEntity::class),
+ );
+
+ $orderMock->method('getPrice')->willReturn($this->createPrice(100));
+
+ $collection = $filter->filterPaymentMethods($this->getMethodCollection(), $context);
+ static::assertCount(6, $collection->getElements());
+ static::assertPaymentMethodCount(3, DefaultPayment::class, $collection);
+ static::assertPaymentMethodCount(3, PayonePrepaymentPaymentHandler::class, $collection);
+ }
+
+ public function testIfRemovesAllMethodsIfPriceHigherZeroForOrder(): void
+ {
+ $filter = new TotalPriceFilter();
+
+ $context = new PaymentFilterContext(
+ $this->createMock(SalesChannelContext::class),
+ $this->createMock(CustomerAddressEntity::class),
+ $this->createMock(CustomerAddressEntity::class),
+ $this->createMock(CurrencyEntity::class),
+ $orderMock = $this->createMock(OrderEntity::class),
+ );
+
+ $orderMock->method('getPrice')->willReturn($this->createPrice(100));
+
+ $collection = $filter->filterPaymentMethods($this->getMethodCollection(), $context);
+ static::assertCount(6, $collection->getElements());
+ static::assertPaymentMethodCount(3, DefaultPayment::class, $collection);
+ static::assertPaymentMethodCount(3, PayonePrepaymentPaymentHandler::class, $collection);
+ }
+
+ private static function assertPaymentMethodCount(int $expectedCount, string $paymentHandlerClass, PaymentMethodCollection $collection): void
+ {
+ static::assertCount($expectedCount, $collection->filter(static fn (PaymentMethodEntity $e) => $e->getHandlerIdentifier() === $paymentHandlerClass)->getElements(), sprintf('there should be %s payment methods with %s handler', $expectedCount, $paymentHandlerClass));
+ }
+
+ private function getMethodCollection(): PaymentMethodCollection
+ {
+ return new PaymentMethodCollection([
+ (new PaymentMethodEntity())->assign(['id' => Uuid::randomHex(), 'handlerIdentifier' => DefaultPayment::class]),
+ (new PaymentMethodEntity())->assign(['id' => Uuid::randomHex(), 'handlerIdentifier' => DefaultPayment::class]),
+ (new PaymentMethodEntity())->assign(['id' => Uuid::randomHex(), 'handlerIdentifier' => DefaultPayment::class]),
+ (new PaymentMethodEntity())->assign(['id' => Uuid::randomHex(), 'handlerIdentifier' => PayonePrepaymentPaymentHandler::class]),
+ (new PaymentMethodEntity())->assign(['id' => Uuid::randomHex(), 'handlerIdentifier' => PayonePrepaymentPaymentHandler::class]),
+ (new PaymentMethodEntity())->assign(['id' => Uuid::randomHex(), 'handlerIdentifier' => PayonePrepaymentPaymentHandler::class]),
+ ]);
+ }
+}
diff --git a/tests/Components/PaymentStateHandler/PaymentStateHandlerTest.php b/tests/Components/PaymentStateHandler/PaymentStateHandlerTest.php
new file mode 100644
index 000000000..97dae504e
--- /dev/null
+++ b/tests/Components/PaymentStateHandler/PaymentStateHandlerTest.php
@@ -0,0 +1,69 @@
+createMock(Translator::class));
+
+ if (class_exists(PaymentException::class)) {
+ $this->expectException(PaymentException::class);
+ } elseif (class_exists(CustomerCanceledAsyncPaymentException::class)) {
+ $this->expectException(CustomerCanceledAsyncPaymentException::class);
+ } else {
+ throw new \Exception('neither PaymentException nor CustomerCanceledAsyncPaymentException does exist.');
+ }
+
+ $handler->handleStateResponse($this->createTransactionStruct(), 'cancel');
+ }
+
+ /**
+ * @dataProvider exceptionGotThrownOnErrorDataProvider
+ */
+ public function testIfExceptionGotThrownOnError(string|null $state): void
+ {
+ $handler = new PaymentStateHandler($this->createMock(Translator::class));
+
+ if (class_exists(PaymentException::class)) {
+ $this->expectException(PaymentException::class);
+ } elseif (class_exists(AsyncPaymentFinalizeException::class)) {
+ $this->expectException(AsyncPaymentFinalizeException::class);
+ } else {
+ throw new \Exception('neither PaymentException nor AsyncPaymentFinalizeException does exist.');
+ }
+
+ $handler->handleStateResponse($this->createTransactionStruct(), $state);
+ }
+
+ public static function exceptionGotThrownOnErrorDataProvider(): array
+ {
+ return [
+ [null],
+ ['error'],
+ ];
+ }
+
+ private function createTransactionStruct(): AsyncPaymentTransactionStruct
+ {
+ $mock = $this->createMock(AsyncPaymentTransactionStruct::class);
+
+ $orderTransaction = $this->createMock(OrderTransactionEntity::class);
+ $orderTransaction->method('getId')->willReturn(Uuid::randomHex());
+ $mock->method('getOrderTransaction')->willReturn($orderTransaction);
+
+ return $mock;
+ }
+}
diff --git a/tests/Components/Ratepay/Installment/InstallmentServiceTest.php b/tests/Components/Ratepay/Installment/InstallmentServiceTest.php
index a4437ba0e..2200d0b9d 100644
--- a/tests/Components/Ratepay/Installment/InstallmentServiceTest.php
+++ b/tests/Components/Ratepay/Installment/InstallmentServiceTest.php
@@ -37,7 +37,7 @@ public function testItReturnsDefaultCalculatorData(): void
$salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
$installmentService = $this->getInstallmentService();
- $this->fillCart($salesChannelContext->getToken(), 100);
+ $this->fillCart($salesChannelContext, 100);
$calculatorData = $installmentService->getInstallmentCalculatorData($salesChannelContext);
@@ -69,7 +69,7 @@ public function testItReturnsCalculatorDataByTime(): void
$salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
$installmentService = $this->getInstallmentService();
- $this->fillCart($salesChannelContext->getToken(), 100);
+ $this->fillCart($salesChannelContext, 100);
$dataBag = new RequestDataBag([
'ratepayInstallmentType' => CalculationRequestParameterBuilder::INSTALLMENT_TYPE_TIME,
@@ -106,7 +106,7 @@ public function testItReturnsCalculatorDataByRate(): void
$salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
$installmentService = $this->getInstallmentService();
- $this->fillCart($salesChannelContext->getToken(), 100);
+ $this->fillCart($salesChannelContext, 100);
$dataBag = new RequestDataBag([
'ratepayInstallmentType' => CalculationRequestParameterBuilder::INSTALLMENT_TYPE_RATE,
diff --git a/tests/Components/RedirectHandler/RedirectHandlerTest.php b/tests/Components/RedirectHandler/RedirectHandlerTest.php
index 762eb7df7..d0cacedd4 100644
--- a/tests/Components/RedirectHandler/RedirectHandlerTest.php
+++ b/tests/Components/RedirectHandler/RedirectHandlerTest.php
@@ -129,12 +129,12 @@ public function testItThrowsExceptionOnDecodingWithMissingUrl(): void
$redirectHandler->decode('the-hash');
}
- /**
- * @depends testItEncodesUrlWithDatabase
- */
public function testItCleansUpOldUrls(): void
{
+ /** @var Connection $connection */
$connection = $this->getContainer()->get(Connection::class);
+ $connection->executeStatement('TRUNCATE payone_payment_redirect'); // make sure table is empty
+
$router = $this->getContainer()->get('router.default');
$redirectHandler = new RedirectHandler(
@@ -143,6 +143,7 @@ public function testItCleansUpOldUrls(): void
$this->getContainer()->getParameter('env.app_secret')
);
+ $redirectHandler->encode('the-url-1');
$redirectHandler->encode('the-url-2');
$countQuery = 'SELECT COUNT(*) FROM payone_payment_redirect';
diff --git a/tests/Components/SecuredInstallment/InstallmentServiceTest.php b/tests/Components/SecuredInstallment/InstallmentServiceTest.php
index c82106da1..70bc3b439 100644
--- a/tests/Components/SecuredInstallment/InstallmentServiceTest.php
+++ b/tests/Components/SecuredInstallment/InstallmentServiceTest.php
@@ -25,7 +25,7 @@ public function testItReturnsInstallmentOptions(): void
$installmentService = $this->getInstallmentService($client);
$salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
- $this->fillCart($salesChannelContext->getToken(), 510.50);
+ $this->fillCart($salesChannelContext);
$installmentOptions = $installmentService->getInstallmentOptions($salesChannelContext);
@@ -61,7 +61,7 @@ public function testItReturnsInstallmentOptionsWithout0Index(): void
$installmentService = $this->getInstallmentService($client);
$salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
- $this->fillCart($salesChannelContext->getToken(), 510.50);
+ $this->fillCart($salesChannelContext);
$installmentOptions = $installmentService->getInstallmentOptions($salesChannelContext);
@@ -97,7 +97,7 @@ public function testItReturnsEmptyOptionsOnFailedRequest(): void
$installmentService = $this->getInstallmentService($client);
$salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
- $this->fillCart($salesChannelContext->getToken(), 510.50);
+ $this->fillCart($salesChannelContext);
$installmentOptions = $installmentService->getInstallmentOptions($salesChannelContext);
diff --git a/tests/Components/Validator/BirthdayValidationTest.php b/tests/Components/Validator/BirthdayValidationTest.php
new file mode 100644
index 000000000..6c0e970c9
--- /dev/null
+++ b/tests/Components/Validator/BirthdayValidationTest.php
@@ -0,0 +1,74 @@
+getContainer()->get(DataValidator::class);
+
+ $validator->validate(
+ [
+ 'birthday' => $date->format('Y-m-d'),
+ ],
+ (new DataValidationDefinition())->add('birthday', new Birthday())
+ );
+
+ static::assertTrue(true);
+ }
+
+ public static function successTestCases(): array
+ {
+ return [
+ [(DateTime::createFromFormat('Y-m-d', '1950-01-01'))],
+ [(new DateTime())->modify('-18 years')],
+ [(new DateTime())->modify('-50 years')],
+ ];
+ }
+
+ /**
+ * @dataProvider failTestCases
+ */
+ public function testIfValidationFails(mixed $date = null): void
+ {
+ /** @var DataValidator $validator */
+ $validator = $this->getContainer()->get(DataValidator::class);
+
+ $this->expectException(ConstraintViolationException::class);
+
+ $validator->validate(
+ [
+ 'birthday' => $date instanceof DateTime ? $date->format('Y-m-d') : $date,
+ ],
+ (new DataValidationDefinition())->add('birthday', new Birthday())
+ );
+ }
+
+ public static function failTestCases(): array
+ {
+ return [
+ [null],
+ ['1234567'],
+ ['abcdefg'],
+ [(new DateTime())],
+ [(new DateTime())->modify('+1 year')],
+ [(new DateTime())->modify('-17 years')],
+ ];
+ }
+}
diff --git a/tests/Constants.php b/tests/Constants.php
index 327684adb..db8a86690 100644
--- a/tests/Constants.php
+++ b/tests/Constants.php
@@ -27,4 +27,8 @@ interface Constants
public const PAYONE_TRANSACTION_ID = 'test-transaction-id';
public const COUNTRY_ID = 'ea3a25f690f848359a4d64c1c46077ea';
public const SALUTATION_ID = 'c954f5baf0894e95a7ed8b172e59b145';
+
+ public const DEFAULT_PRODUCT_PRICE = 119;
+
+ public const CUSTOMER_ID = '8c7b6ac55c4647bd997451fa3892aa8d';
}
diff --git a/tests/DataAbstractionLayer/Aggregate/PayonePaymentOrderTransactionDataEntityTest.php b/tests/DataAbstractionLayer/Aggregate/PayonePaymentOrderTransactionDataEntityTest.php
index 20f2f1aa3..447a44a5e 100644
--- a/tests/DataAbstractionLayer/Aggregate/PayonePaymentOrderTransactionDataEntityTest.php
+++ b/tests/DataAbstractionLayer/Aggregate/PayonePaymentOrderTransactionDataEntityTest.php
@@ -141,15 +141,6 @@ public function testItSetsAndReturnsAuthorizationType(): void
static::assertSame('the-authorization-type', $entity->getAuthorizationType());
}
- public function testItSetsAndReturnsWorkOrderId(): void
- {
- $entity = new PayonePaymentOrderTransactionDataEntity();
- $entity->assign([
- 'workOrderId' => 'the-work-order-id',
- ]);
- static::assertSame('the-work-order-id', $entity->getWorkOrderId());
- }
-
public function testItSetsAndReturnsClearingReference(): void
{
$entity = new PayonePaymentOrderTransactionDataEntity();
@@ -225,7 +216,6 @@ public function testItSerializesTheEntityToArray(): void
'refundedAmount' => 1,
'mandateIdentification' => 'the-mandate-identification',
'authorizationType' => 'the-authorization-type',
- 'workOrderId' => 'thw-work-order-id',
'clearingReference' => 'the-clearing-reference',
'clearingType' => 'the-clearing-type',
'financingType' => 'the-financing-type',
diff --git a/tests/EventListener/CheckoutConfirmRatepayEventListenerTest.php b/tests/EventListener/CheckoutConfirmRatepayEventListenerTest.php
index cf49888be..d9e0bd02e 100644
--- a/tests/EventListener/CheckoutConfirmRatepayEventListenerTest.php
+++ b/tests/EventListener/CheckoutConfirmRatepayEventListenerTest.php
@@ -113,7 +113,7 @@ public function testItFiltersPaymentMethodsByProfilesOnCheckoutConfirmPage(strin
$this->setPaymentMethods($page);
$salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
- $this->fillCart($salesChannelContext->getToken(), $cartValue);
+ $this->fillCart($salesChannelContext, $cartValue);
$event = new CheckoutConfirmPageLoadedEvent($page, $salesChannelContext, new Request());
$listener = $this->getContainer()->get(CheckoutConfirmRatepayEventListener::class);
diff --git a/tests/EventListener/DeviceFingerprintEventListenerTest.php b/tests/EventListener/DeviceFingerprintEventListenerTest.php
index 366e3a5e7..d24587ba1 100644
--- a/tests/EventListener/DeviceFingerprintEventListenerTest.php
+++ b/tests/EventListener/DeviceFingerprintEventListenerTest.php
@@ -50,8 +50,12 @@ public function testItAddsDeviceFingerprintDataExtensionOnCheckoutConfirmPage():
$event = new CheckoutConfirmPageLoadedEvent($page, $salesChannelContext, new Request());
$listener->addDeviceFingerprintData($event);
-
static::assertTrue($event->getPage()->hasExtension(DeviceFingerprintData::EXTENSION_NAME));
+
+ $page->removeExtension(DeviceFingerprintData::EXTENSION_NAME);
+ $event = new CheckoutConfirmPageLoadedEvent($page, $salesChannelContext, new Request());
+ $listener->addDeviceFingerprintData($event);
+ static::assertFalse($event->getPage()->hasExtension(DeviceFingerprintData::EXTENSION_NAME), 'DFP should not be added to page-struct, because it has already generated in the previous test.');
}
public function testItAddsDeviceFingerprintDataExtensionOnAccountEditOrderPage(): void
@@ -71,8 +75,12 @@ public function testItAddsDeviceFingerprintDataExtensionOnAccountEditOrderPage()
$event = new AccountEditOrderPageLoadedEvent($page, $salesChannelContext, new Request());
$listener->addDeviceFingerprintData($event);
-
static::assertTrue($event->getPage()->hasExtension(DeviceFingerprintData::EXTENSION_NAME));
+
+ $page->removeExtension(DeviceFingerprintData::EXTENSION_NAME);
+ $event = new AccountEditOrderPageLoadedEvent($page, $salesChannelContext, new Request());
+ $listener->addDeviceFingerprintData($event);
+ static::assertFalse($event->getPage()->hasExtension(DeviceFingerprintData::EXTENSION_NAME), 'DFP should not be added to page-struct, because it has already generated in the previous test.');
}
protected function setPaymentMethods(Page $page): void
diff --git a/tests/EventListener/OrderValidationEventListenerTest.php b/tests/EventListener/OrderValidationEventListenerTest.php
index bea9b2d2d..ba642e321 100644
--- a/tests/EventListener/OrderValidationEventListenerTest.php
+++ b/tests/EventListener/OrderValidationEventListenerTest.php
@@ -36,7 +36,7 @@ public function testItAddsValidationDefinitions(): void
$definitions = [
'iban' => [new NotBlank(), new Iban()],
- 'birthday' => [new NotBlank(), new Birthday(['value' => (new \DateTime())->modify('-18 years')->setTime(0, 0)])],
+ 'birthday' => [new NotBlank(), new Birthday()],
'sub' => new DataValidationDefinition(),
];
diff --git a/tests/Functional/Payment/AmazonPay/AuthorizePaymentRequestParameterTest.php b/tests/Functional/Payment/AmazonPay/AuthorizePaymentRequestParameterTest.php
index d4b689ce0..ff3ba9c40 100644
--- a/tests/Functional/Payment/AmazonPay/AuthorizePaymentRequestParameterTest.php
+++ b/tests/Functional/Payment/AmazonPay/AuthorizePaymentRequestParameterTest.php
@@ -4,10 +4,10 @@
namespace PayonePayment\Functional\Payment\AmazonPay;
-use PayonePayment\Components\CartHasher\CartHasherInterface;
use PayonePayment\PaymentHandler\PayoneAmazonPayPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
use PayonePayment\Payone\RequestParameter\RequestParameterFactory;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\PayoneTestBehavior;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
@@ -25,7 +25,7 @@ public function testIfSuccessful(string $authMethod): void
$factory = $this->getContainer()->get(RequestParameterFactory::class);
$dataBag = new RequestDataBag([
- 'payonePhone' => '012345789',
+ RequestConstants::PHONE => '012345789',
]);
$struct = $this->getPaymentTransactionStruct(
diff --git a/tests/Functional/Payment/AmazonPayExpress/AuthorizePaymentRequestParameterTest.php b/tests/Functional/Payment/AmazonPayExpress/AuthorizePaymentRequestParameterTest.php
index d043f6a15..523145556 100644
--- a/tests/Functional/Payment/AmazonPayExpress/AuthorizePaymentRequestParameterTest.php
+++ b/tests/Functional/Payment/AmazonPayExpress/AuthorizePaymentRequestParameterTest.php
@@ -8,6 +8,7 @@
use PayonePayment\PaymentHandler\PayoneAmazonPayExpressPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
use PayonePayment\Payone\RequestParameter\RequestParameterFactory;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\PayoneTestBehavior;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
@@ -33,8 +34,8 @@ public function testIfSuccessful(string $authMethod): void
$authMethod
);
- $struct->getRequestData()->set('carthash', $cartHasher->generate($struct->getPaymentTransaction()->getOrder(), $struct->getSalesChannelContext()));
- $struct->getRequestData()->set('workorder', 'ABCDEF12345678');
+ $struct->getRequestData()->set(RequestConstants::CART_HASH, $cartHasher->generate($struct->getPaymentTransaction()->getOrder(), $struct->getSalesChannelContext()));
+ $struct->getRequestData()->set(RequestConstants::WORK_ORDER_ID, 'ABCDEF12345678');
$requestParams = $factory->getRequestParameter($struct);
diff --git a/tests/Functional/Payment/AmazonPayExpress/CreateCheckoutSessionRequestParametersTest.php b/tests/Functional/Payment/AmazonPayExpress/CreateCheckoutSessionRequestParametersTest.php
index 863c27055..0d49139b7 100644
--- a/tests/Functional/Payment/AmazonPayExpress/CreateCheckoutSessionRequestParametersTest.php
+++ b/tests/Functional/Payment/AmazonPayExpress/CreateCheckoutSessionRequestParametersTest.php
@@ -6,6 +6,7 @@
use PayonePayment\Components\ConfigReader\ConfigReader;
use PayonePayment\Components\GenericExpressCheckout\Struct\CreateExpressCheckoutSessionStruct;
+use PayonePayment\Constants;
use PayonePayment\PaymentHandler\PayoneAmazonPayExpressPaymentHandler;
use PayonePayment\Payone\RequestParameter\RequestParameterFactory;
use PayonePayment\TestCaseBase\PayoneTestBehavior;
@@ -28,7 +29,12 @@ public function testIfParametersGotCreatedSuccessfulWithoutRestriction(): void
$context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
// cart got stored automatically in the CartService, which is reused in the plugin
- $this->createCartWithProduct($context, 200, 2);
+ $this->createCartWithProduct($context);
+
+ /** @var SystemConfigService $configService */
+ $configService = $this->getContainer()->get(SystemConfigService::class);
+ $configService->set(ConfigReader::getConfigKeyByPaymentHandler(PayoneAmazonPayExpressPaymentHandler::class, 'RestrictPOBoxes'), false);
+ $configService->set(ConfigReader::getConfigKeyByPaymentHandler(PayoneAmazonPayExpressPaymentHandler::class, 'RestrictPackstations'), false);
$requestParams = $factory->getRequestParameter(new CreateExpressCheckoutSessionStruct(
$context,
@@ -42,7 +48,7 @@ public function testIfParametersGotCreatedSuccessfulWithoutRestriction(): void
static::assertArrayHasKey('wallettype', $requestParams);
static::assertEquals('AMP', $requestParams['wallettype']);
static::assertArrayHasKey('amount', $requestParams);
- static::assertEquals(400 * 100, $requestParams['amount']);
+ static::assertEquals(Constants::DEFAULT_PRODUCT_PRICE * 100, $requestParams['amount']);
static::assertArrayHasKey('currency', $requestParams);
static::assertArrayHasKey('add_paydata[action]', $requestParams);
static::assertEquals('createCheckoutSessionPayload', $requestParams['add_paydata[action]']);
@@ -74,7 +80,7 @@ public function testIfParametersGotCreatedSuccessfulWithRestriction(array $restr
}
// cart got stored automatically in the CartService, which is reused in the plugin
- $this->createCartWithProduct($context, 200, 2);
+ $this->createCartWithProduct($context);
$requestParams = $factory->getRequestParameter(new CreateExpressCheckoutSessionStruct(
$context,
@@ -86,7 +92,7 @@ public function testIfParametersGotCreatedSuccessfulWithRestriction(array $restr
static::assertArrayHasKey('wallettype', $requestParams);
static::assertEquals('AMP', $requestParams['wallettype']);
static::assertArrayHasKey('amount', $requestParams);
- static::assertEquals(400 * 100, $requestParams['amount']);
+ static::assertEquals(Constants::DEFAULT_PRODUCT_PRICE * 100, $requestParams['amount']);
static::assertArrayHasKey('currency', $requestParams);
static::assertArrayHasKey('add_paydata[action]', $requestParams);
static::assertEquals('createCheckoutSessionPayload', $requestParams['add_paydata[action]']);
diff --git a/tests/Functional/Payment/AmazonPayExpress/UpdateCheckoutSessionParameterBuilderTest.php b/tests/Functional/Payment/AmazonPayExpress/UpdateCheckoutSessionParameterBuilderTest.php
index a5ff810a4..1c780616c 100644
--- a/tests/Functional/Payment/AmazonPayExpress/UpdateCheckoutSessionParameterBuilderTest.php
+++ b/tests/Functional/Payment/AmazonPayExpress/UpdateCheckoutSessionParameterBuilderTest.php
@@ -21,7 +21,7 @@ public function testIfSuccessful(): void
$context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
// cart got stored automatically in the CartService, which is reused in the plugin
- $this->createCartWithProduct($context, 200, 2);
+ $this->createCartWithProduct($context);
$struct = new AmazonPayExpressUpdateCheckoutSessionStruct($context, 'test-123');
diff --git a/tests/Functional/Payment/PaypalExpress/CreateCheckoutSessionRequestParametersTest.php b/tests/Functional/Payment/PaypalExpress/CreateCheckoutSessionRequestParametersTest.php
index 09f641efe..78d5f1964 100644
--- a/tests/Functional/Payment/PaypalExpress/CreateCheckoutSessionRequestParametersTest.php
+++ b/tests/Functional/Payment/PaypalExpress/CreateCheckoutSessionRequestParametersTest.php
@@ -5,7 +5,7 @@
namespace PayonePayment\Functional\Payment\PaypalExpress;
use PayonePayment\Components\GenericExpressCheckout\Struct\CreateExpressCheckoutSessionStruct;
-use PayonePayment\PaymentHandler\PayoneAmazonPayExpressPaymentHandler;
+use PayonePayment\Constants;
use PayonePayment\PaymentHandler\PayonePaypalExpressPaymentHandler;
use PayonePayment\Payone\RequestParameter\RequestParameterFactory;
use PayonePayment\TestCaseBase\PayoneTestBehavior;
@@ -26,7 +26,7 @@ public function testIfParametersGotCreatedSuccessful(): void
$context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
// cart got stored automatically in the CartService, which is reused in the plugin
- $this->createCartWithProduct($context, 200, 2);
+ $this->createCartWithProduct($context);
$requestParams = $factory->getRequestParameter(new CreateExpressCheckoutSessionStruct(
$context,
@@ -38,7 +38,7 @@ public function testIfParametersGotCreatedSuccessful(): void
static::assertArrayHasKey('wallettype', $requestParams);
static::assertEquals('PPE', $requestParams['wallettype']);
static::assertArrayHasKey('amount', $requestParams);
- static::assertEquals(400 * 100, $requestParams['amount']);
+ static::assertEquals(Constants::DEFAULT_PRODUCT_PRICE * 100, $requestParams['amount']);
static::assertArrayHasKey('currency', $requestParams);
static::assertArrayHasKey('add_paydata[action]', $requestParams);
static::assertEquals('setexpresscheckout', $requestParams['add_paydata[action]']);
diff --git a/tests/Functional/Payment/PaypalExpress/GetCheckoutSessionRequestParametersTest.php b/tests/Functional/Payment/PaypalExpress/GetCheckoutSessionRequestParametersTest.php
index 9ea2e4074..9ed365a43 100644
--- a/tests/Functional/Payment/PaypalExpress/GetCheckoutSessionRequestParametersTest.php
+++ b/tests/Functional/Payment/PaypalExpress/GetCheckoutSessionRequestParametersTest.php
@@ -5,7 +5,6 @@
namespace PayonePayment\Functional\Payment\PaypalExpress;
use PayonePayment\Components\GenericExpressCheckout\Struct\GetCheckoutSessionStruct;
-use PayonePayment\PaymentHandler\PayoneAmazonPayExpressPaymentHandler;
use PayonePayment\PaymentHandler\PayonePaypalExpressPaymentHandler;
use PayonePayment\Payone\RequestParameter\RequestParameterFactory;
use PayonePayment\TestCaseBase\PayoneTestBehavior;
diff --git a/tests/Integration/Configuration/SettingsTest.php b/tests/Integration/Configuration/SettingsTest.php
index f9515d97d..6ef72d908 100644
--- a/tests/Integration/Configuration/SettingsTest.php
+++ b/tests/Integration/Configuration/SettingsTest.php
@@ -9,7 +9,7 @@
class SettingsTest extends TestCase
{
- public function testIfDefaultSettingsExistsForPaymentMethods(): void
+ public function testIfDefaultSettingsDoesNotExistsForPaymentMethods(): void
{
$configFile = __DIR__ . '/../../../src/Resources/config/settings.xml';
if (!is_file($configFile) || !is_readable($configFile)) {
@@ -22,55 +22,43 @@ public function testIfDefaultSettingsExistsForPaymentMethods(): void
$prefixes = ConfigurationPrefixes::CONFIGURATION_PREFIXES;
foreach ($prefixes as $prefix) {
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sMerchantId', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sAccountId', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPortalId', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPortalKey', $prefix)));
- //self::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sAuthorizationMethod', $prefix))); // is not supported by all methods
- //self::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sProvideNarrativeText', $prefix))); // is not supported by all methods
- if (str_starts_with((string) $prefix, 'ratepay')) {
- // skip status checks
- continue;
- }
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusAppointed', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusCapture', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusPartialCapture', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusPaid', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusUnderpaid', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusCancelation', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusPartialRefund', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusDebit', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusReminder', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusVauthorization', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusVsettlement', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusInvoice', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusFailed', $prefix)));
- static::assertThat($xmlArray, new ConfigKeyMatches('name', sprintf('%sPaymentStatusPartialRefund', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sMerchantId', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sAccountId', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPortalId', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPortalKey', $prefix)));
+
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusAppointed', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusCapture', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusPartialCapture', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusPaid', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusUnderpaid', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusCancelation', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusPartialRefund', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusDebit', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusReminder', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusVauthorization', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusVsettlement', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusInvoice', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusFailed', $prefix)));
+ static::assertThat($xmlArray, new ConfigKeyShouldNotExist(sprintf('%sPaymentStatusPartialRefund', $prefix)));
}
}
}
-class ConfigKeyMatches extends Constraint
+class ConfigKeyShouldNotExist extends Constraint
{
/**
- * @param int|string $key
- * @param int|string $value
+ * @param int|string $configKey
*/
- public function __construct(private $key, private $value)
+ public function __construct(private readonly string $configKey)
{
}
- /**
- * Returns a string representation of the constraint.
- *
- * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
- */
public function toString(): string
{
return sprintf(
- 'config key exists %s with value %s',
- $this->exporter()->export($this->key),
- $this->exporter()->export($this->value)
+ 'config key does NOT exists: %s',
+ $this->exporter()->export($this->configKey)
);
}
@@ -80,29 +68,19 @@ protected function matches($configArray): bool
foreach ($configArray['card'] as $card) {
if (\is_array($card) && isset($card['input-field'])) {
foreach ($card['input-field'] as $fields) {
- if ($fields[$this->key] === $this->value) {
- return true;
+ if (($fields['name'] ?? null) === $this->configKey) {
+ return false;
}
}
}
}
}
- return false;
+ return true;
}
- /**
- * Returns the description of the failure.
- *
- * The beginning of failure messages is "Failed asserting that" in most
- * cases. This method should return the second part of that sentence.
- *
- * @param mixed $other evaluated value or object
- *
- * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
- */
protected function failureDescription(mixed $other): string
{
- return 'an array ' . $this->toString();
+ return $this->toString();
}
}
diff --git a/tests/Integration/PaymentMethod/PaymentMethodTest.php b/tests/Integration/PaymentMethod/PaymentMethodTest.php
index 864ab0593..28ddd5b74 100644
--- a/tests/Integration/PaymentMethod/PaymentMethodTest.php
+++ b/tests/Integration/PaymentMethod/PaymentMethodTest.php
@@ -11,14 +11,36 @@
class PaymentMethodTest extends TestCase
{
- public function testSameUuid(): void
+ public function testIfUuidIsSetAndUnique(): void
{
+ $idMapping = [];
foreach (ClassHelper::getPaymentMethodClasses() as $class) {
/** @var AbstractPaymentMethod $instance */
$instance = new $class();
static::assertInstanceOf(PaymentMethodInterface::class, $instance);
- // test if UUID is the same as $id
- static::assertEquals(\constant($class . '::UUID'), $instance->getId(), sprintf('%s needs to be the same values as %s', $class . '::$id', $class . '::UUID'));
+
+ $id = \constant($class . '::UUID');
+ static::assertNotNull($id, 'id for ' . $class . ' should not be null.');
+ static::assertEquals($id, $instance->getId(), sprintf('%s needs to be the same values as %s', $class . '::$id', $class . '::UUID'));
+ static::assertArrayNotHasKey($instance->getId(), $idMapping, 'id for ' . $class . ' does already exist for payment method ' . ($idMapping[$instance->getId()] ?? null));
+ $idMapping[$instance->getId()] = $class;
+ }
+ }
+
+ public function testIfTechnicalNameIsSetAndUnique(): void
+ {
+ $technicalMapping = [];
+ foreach (ClassHelper::getPaymentMethodClasses() as $class) {
+ /** @var AbstractPaymentMethod $instance */
+ $instance = new $class();
+ static::assertInstanceOf(PaymentMethodInterface::class, $instance);
+
+ $technicalName = \constant($class . '::TECHNICAL_NAME');
+ static::assertNotNull($technicalName, 'technical name for ' . $class . ' should not be null.');
+ static::assertEquals($technicalName, $instance->getTechnicalName(), 'method ' . $class . '::getTechnicalName should return the same value as ' . $class . '::TECHNICAL_NAME');
+ static::assertStringStartsWith('payone_', $technicalName, 'technical-name for ' . $class . ' should start with `payone_`');
+ static::assertArrayNotHasKey($technicalName, $technicalMapping, 'technical.name for ' . $class . ' does already exist for payment method ' . ($technicalMapping[$technicalName] ?? null));
+ $technicalMapping[$technicalName] = $class;
}
}
}
diff --git a/tests/Migration/Migration1639050658MigrateOrderTransactionDataFromCustomFieldsTest.php b/tests/Migration/Migration1639050658MigrateOrderTransactionDataFromCustomFieldsTest.php
index be60a040a..7d7bf9c63 100644
--- a/tests/Migration/Migration1639050658MigrateOrderTransactionDataFromCustomFieldsTest.php
+++ b/tests/Migration/Migration1639050658MigrateOrderTransactionDataFromCustomFieldsTest.php
@@ -130,8 +130,6 @@ public function customFieldExtensionMapping(): array
['payone_captured_amount', 0, 'getRefundedAmount', 0], // Test if the default value of payone_refunded_amount works
['payone_mandate_identification', 'the-mandate-identification', 'getMandateIdentification', 'the-mandate-identification'],
['payone_authorization_type', 'the-authorization-type', 'getAuthorizationType', 'the-authorization-type'],
- ['payone_work_order_id', 'the-work-order-id', 'getWorkOrderId', 'the-work-order-id'],
- ['payone_work_order_id', null, 'getWorkOrderId', null],
['payone_clearing_reference', 'the-clearing-reference', 'getClearingReference', 'the-clearing-reference'],
['payone_clearing_type', 'the-clearing-type', 'getClearingType', 'the-clearing-type'],
['payone_financing_type', 'the-financing-type', 'getFinancingType', 'the-financing-type'],
diff --git a/tests/PaymentHandler/AbstractKlarnaPaymentHandlerTest.php b/tests/PaymentHandler/AbstractKlarnaPaymentHandlerTest.php
index 3e1ae8692..f85a95747 100644
--- a/tests/PaymentHandler/AbstractKlarnaPaymentHandlerTest.php
+++ b/tests/PaymentHandler/AbstractKlarnaPaymentHandlerTest.php
@@ -7,15 +7,13 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\CartHasher\CartHasher;
use PayonePayment\Components\ConfigReader\ConfigReader;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface;
use PayonePayment\Components\PaymentStateHandler\PaymentStateHandler;
use PayonePayment\Payone\Client\PayoneClientInterface;
use PayonePayment\Payone\RequestParameter\RequestParameterFactory;
use Shopware\Core\Checkout\Order\OrderEntity;
-use Shopware\Core\Checkout\Payment\Cart\PaymentHandler\AsynchronousPaymentHandlerInterface;
-use Shopware\Core\Checkout\Payment\Exception\AsyncPaymentProcessException;
-use Shopware\Core\Checkout\Payment\Exception\SyncPaymentProcessException;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -39,13 +37,7 @@ public function testItThrowsExceptionOnMissingToken(): void
$paymentHandler::class
);
- if ($paymentHandler instanceof AsynchronousPaymentHandlerInterface) {
- $expectedException = AsyncPaymentProcessException::class;
- } else {
- $expectedException = SyncPaymentProcessException::class;
- }
-
- $this->expectException($expectedException);
+ $this->expectedPaymentInterruptedException($paymentHandler);
$this->performPayment($paymentHandler, $paymentTransaction, $dataBag, $salesChannelContext);
}
@@ -113,6 +105,7 @@ protected function getPaymentHandler(
$orderActionLogDataHandler ?? $this->createMock(OrderActionLogDataHandlerInterface::class),
$container->get(PaymentStateHandler::class),
$requestFactory,
+ $this->createMock(CustomerDataPersistor::class),
$this->createMock(CartHasher::class)
);
}
diff --git a/tests/PaymentHandler/AbstractPaymentHandlerTest.php b/tests/PaymentHandler/AbstractPaymentHandlerTest.php
index 4d639510d..93e0ed1fe 100644
--- a/tests/PaymentHandler/AbstractPaymentHandlerTest.php
+++ b/tests/PaymentHandler/AbstractPaymentHandlerTest.php
@@ -20,6 +20,7 @@
use Shopware\Core\Checkout\Payment\Cart\SyncPaymentTransactionStruct;
use Shopware\Core\Checkout\Payment\Exception\AsyncPaymentProcessException;
use Shopware\Core\Checkout\Payment\Exception\SyncPaymentProcessException;
+use Shopware\Core\Checkout\Payment\PaymentException;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
@@ -98,13 +99,7 @@ public function testItThrowsExceptionOnErrorStatus(): void
$paymentHandler::class
);
- if ($paymentHandler instanceof AsynchronousPaymentHandlerInterface) {
- $expectedException = AsyncPaymentProcessException::class;
- } else {
- $expectedException = SyncPaymentProcessException::class;
- }
-
- $this->expectException($expectedException);
+ $this->expectedPaymentInterruptedException($paymentHandler);
$this->performPayment($paymentHandler, $paymentTransaction, $dataBag, $salesChannelContext);
}
@@ -128,13 +123,7 @@ public function testItThrowsExceptionOnInvalidStatus(): void
$paymentHandler::class
);
- if ($paymentHandler instanceof AsynchronousPaymentHandlerInterface) {
- $expectedException = AsyncPaymentProcessException::class;
- } else {
- $expectedException = SyncPaymentProcessException::class;
- }
-
- $this->expectException($expectedException);
+ $this->expectedPaymentInterruptedException($paymentHandler);
$this->performPayment($paymentHandler, $paymentTransaction, $dataBag, $salesChannelContext);
}
@@ -170,13 +159,7 @@ public function testItHandlesPayoneExceptionsCorrectly(): void
$paymentHandler::class
);
- if ($paymentHandler instanceof AsynchronousPaymentHandlerInterface) {
- $expectedException = AsyncPaymentProcessException::class;
- } else {
- $expectedException = SyncPaymentProcessException::class;
- }
-
- $this->expectException($expectedException);
+ $this->expectedPaymentInterruptedException($paymentHandler);
$this->expectExceptionMessageMatches('/.*test-customer-message.*/');
$this->performPayment($paymentHandler, $paymentTransaction, $dataBag, $salesChannelContext);
}
@@ -204,14 +187,21 @@ public function testItHandlesRandomThrowableCorrectly(): void
$paymentHandler::class
);
+ $this->expectedPaymentInterruptedException($paymentHandler);
+ $this->performPayment($paymentHandler, $paymentTransaction, $dataBag, $salesChannelContext);
+ }
+
+ protected function expectedPaymentInterruptedException(AbstractPayonePaymentHandler $paymentHandler): void
+ {
if ($paymentHandler instanceof AsynchronousPaymentHandlerInterface) {
- $expectedException = AsyncPaymentProcessException::class;
+ $expectedException = class_exists(AsyncPaymentProcessException::class) ? AsyncPaymentProcessException::class : PaymentException::class;
+ } elseif ($paymentHandler instanceof SynchronousPaymentHandlerInterface) {
+ $expectedException = class_exists(SyncPaymentProcessException::class) ? SyncPaymentProcessException::class : PaymentException::class;
} else {
- $expectedException = SyncPaymentProcessException::class;
+ throw new \RuntimeException('invalid payment handler ' . $paymentHandler::class);
}
$this->expectException($expectedException);
- $this->performPayment($paymentHandler, $paymentTransaction, $dataBag, $salesChannelContext);
}
/**
diff --git a/tests/PaymentHandler/AbstractPostfinancePaymentHandlerTest.php b/tests/PaymentHandler/AbstractPostfinancePaymentHandlerTest.php
index 7b0126049..f2c790f09 100644
--- a/tests/PaymentHandler/AbstractPostfinancePaymentHandlerTest.php
+++ b/tests/PaymentHandler/AbstractPostfinancePaymentHandlerTest.php
@@ -6,6 +6,7 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\ConfigReader\ConfigReader;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface;
use PayonePayment\Components\PaymentStateHandler\PaymentStateHandler;
@@ -80,7 +81,8 @@ protected function getPaymentHandler(
$transactionDataHandler ?? $this->createMock(TransactionDataHandlerInterface::class),
$orderActionLogDataHandler ?? $this->createMock(OrderActionLogDataHandlerInterface::class),
$container->get(PaymentStateHandler::class),
- $requestFactory
+ $requestFactory,
+ $this->createMock(CustomerDataPersistor::class)
);
}
}
diff --git a/tests/PaymentHandler/PayoneAlipayPaymentHandlerTest.php b/tests/PaymentHandler/PayoneAlipayPaymentHandlerTest.php
index 3ea972e13..acbe86205 100644
--- a/tests/PaymentHandler/PayoneAlipayPaymentHandlerTest.php
+++ b/tests/PaymentHandler/PayoneAlipayPaymentHandlerTest.php
@@ -6,6 +6,7 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\ConfigReader\ConfigReader;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface;
use PayonePayment\Components\PaymentStateHandler\PaymentStateHandlerInterface;
@@ -190,7 +191,8 @@ private function getPaymentHandler(
$transactionDataHandler,
$orderActionLogDataHandler,
$stateHandler,
- $requestFactory
+ $requestFactory,
+ $this->createMock(CustomerDataPersistor::class)
);
}
diff --git a/tests/PaymentHandler/PayoneApplePayPaymentHandlerTest.php b/tests/PaymentHandler/PayoneApplePayPaymentHandlerTest.php
index 8eecd429c..8d0fb0287 100644
--- a/tests/PaymentHandler/PayoneApplePayPaymentHandlerTest.php
+++ b/tests/PaymentHandler/PayoneApplePayPaymentHandlerTest.php
@@ -5,6 +5,7 @@
namespace PayonePayment\PaymentHandler;
use PayonePayment\Components\Currency\CurrencyPrecision;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandler;
use PayonePayment\Payone\Client\PayoneClient;
@@ -70,7 +71,8 @@ private function getPaymentHandler(RequestDataBag $dataBag): PayoneApplePayPayme
$this->getContainer()->get('translator'),
new TransactionDataHandler($this->createMock(EntityRepository::class), new CurrencyPrecision()),
$orderActionLogDataHandler,
- $this->createMock(RequestParameterFactory::class)
+ $this->createMock(RequestParameterFactory::class),
+ $this->createMock(CustomerDataPersistor::class)
);
}
}
diff --git a/tests/PaymentHandler/PayoneCreditCardPaymentHandlerTest.php b/tests/PaymentHandler/PayoneCreditCardPaymentHandlerTest.php
index b2cca5445..24241173a 100644
--- a/tests/PaymentHandler/PayoneCreditCardPaymentHandlerTest.php
+++ b/tests/PaymentHandler/PayoneCreditCardPaymentHandlerTest.php
@@ -6,6 +6,7 @@
use PayonePayment\Components\CardRepository\CardRepositoryInterface;
use PayonePayment\Components\Currency\CurrencyPrecision;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandler;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface;
@@ -295,6 +296,7 @@ private function getPaymentHandler(
$orderActionLogDataHandler ?? $this->createMock(OrderActionLogDataHandlerInterface::class),
new PaymentStateHandler($translator),
$requestFactory,
+ $this->createMock(CustomerDataPersistor::class),
$cardRepository
);
}
diff --git a/tests/PaymentHandler/PayonePaypalPaymentHandlerTest.php b/tests/PaymentHandler/PayonePaypalPaymentHandlerTest.php
index b4d77319b..cd82e97bc 100644
--- a/tests/PaymentHandler/PayonePaypalPaymentHandlerTest.php
+++ b/tests/PaymentHandler/PayonePaypalPaymentHandlerTest.php
@@ -5,6 +5,7 @@
namespace PayonePayment\PaymentHandler;
use PayonePayment\Components\Currency\CurrencyPrecision;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandler;
use PayonePayment\Components\PaymentStateHandler\PaymentStateHandler;
@@ -82,7 +83,8 @@ private function getPaymentHandler(
new TransactionDataHandler($this->createMock(EntityRepository::class), new CurrencyPrecision()),
$orderActionLogDataHandler,
new PaymentStateHandler($translator),
- $requestFactory
+ $requestFactory,
+ $this->createMock(CustomerDataPersistor::class)
);
}
diff --git a/tests/PaymentHandler/PayonePrzelewy24PaymentHandlerTest.php b/tests/PaymentHandler/PayonePrzelewy24PaymentHandlerTest.php
index 63445b6fb..354e87d01 100644
--- a/tests/PaymentHandler/PayonePrzelewy24PaymentHandlerTest.php
+++ b/tests/PaymentHandler/PayonePrzelewy24PaymentHandlerTest.php
@@ -6,6 +6,7 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\ConfigReader\ConfigReader;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface;
use PayonePayment\Components\PaymentStateHandler\PaymentStateHandlerInterface;
@@ -192,7 +193,8 @@ private function getPaymentHandler(
$transactionDataHandler,
$orderActionLogDataHandler,
$stateHandler,
- $requestFactory
+ $requestFactory,
+ $this->createMock(CustomerDataPersistor::class)
);
}
diff --git a/tests/PaymentHandler/PayoneRatepayDebitPaymentHandlerTest.php b/tests/PaymentHandler/PayoneRatepayDebitPaymentHandlerTest.php
index 95e336a5e..d0b56536e 100644
--- a/tests/PaymentHandler/PayoneRatepayDebitPaymentHandlerTest.php
+++ b/tests/PaymentHandler/PayoneRatepayDebitPaymentHandlerTest.php
@@ -6,6 +6,7 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\ConfigReader\ConfigReader;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface;
use PayonePayment\Components\DeviceFingerprint\RatepayDeviceFingerprintService;
@@ -65,7 +66,6 @@ public function testItPerformsPaymentWithAuthorizationAndSavesCorrectTransaction
'sequenceNumber' => -1,
'userId' => '987654321',
'transactionState' => 'APPROVED',
- 'workOrderId' => null,
'clearingReference' => 'DN123',
'captureMode' => 'completed',
'clearingType' => 'fnc',
@@ -146,7 +146,6 @@ public function testItPerformsPaymentWithPreAuthorizationAndSavesCorrectTransact
'sequenceNumber' => -1,
'userId' => '987654321',
'transactionState' => 'APPROVED',
- 'workOrderId' => null,
'clearingReference' => 'DN123',
'captureMode' => 'completed',
'clearingType' => 'fnc',
@@ -203,6 +202,7 @@ private function getPaymentHandler(
$transactionDataHandler,
$orderActionLogDataHandler,
$requestFactory,
+ $this->createMock(CustomerDataPersistor::class),
$deviceFingerprintService
);
}
diff --git a/tests/PaymentHandler/PayoneRatepayInstallmentPaymentHandlerTest.php b/tests/PaymentHandler/PayoneRatepayInstallmentPaymentHandlerTest.php
index 8b633b064..40757a68b 100644
--- a/tests/PaymentHandler/PayoneRatepayInstallmentPaymentHandlerTest.php
+++ b/tests/PaymentHandler/PayoneRatepayInstallmentPaymentHandlerTest.php
@@ -6,6 +6,7 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\ConfigReader\ConfigReader;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface;
use PayonePayment\Components\DeviceFingerprint\RatepayDeviceFingerprintService;
@@ -65,7 +66,6 @@ public function testItPerformsPaymentWithAuthorizationAndSavesCorrectTransaction
'sequenceNumber' => -1,
'userId' => '987654321',
'transactionState' => 'APPROVED',
- 'workOrderId' => null,
'clearingReference' => 'DN123',
'captureMode' => 'completed',
'clearingType' => 'fnc',
@@ -146,7 +146,6 @@ public function testItPerformsPaymentWithPreAuthorizationAndSavesCorrectTransact
'sequenceNumber' => -1,
'userId' => '987654321',
'transactionState' => 'APPROVED',
- 'workOrderId' => null,
'clearingReference' => 'DN123',
'captureMode' => 'completed',
'clearingType' => 'fnc',
@@ -203,6 +202,7 @@ private function getPaymentHandler(
$transactionDataHandler,
$orderActionLogDataHandler,
$requestFactory,
+ $this->createMock(CustomerDataPersistor::class),
$deviceFingerprintService
);
}
diff --git a/tests/PaymentHandler/PayoneRatepayInvoicingPaymentHandlerTest.php b/tests/PaymentHandler/PayoneRatepayInvoicingPaymentHandlerTest.php
index 6bd3140e0..740af0ef3 100644
--- a/tests/PaymentHandler/PayoneRatepayInvoicingPaymentHandlerTest.php
+++ b/tests/PaymentHandler/PayoneRatepayInvoicingPaymentHandlerTest.php
@@ -6,6 +6,7 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\ConfigReader\ConfigReader;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface;
use PayonePayment\Components\DeviceFingerprint\RatepayDeviceFingerprintService;
@@ -65,7 +66,6 @@ public function testItPerformsPaymentWithAuthorizationAndSavesCorrectTransaction
'sequenceNumber' => -1,
'userId' => '987654321',
'transactionState' => 'APPROVED',
- 'workOrderId' => null,
'clearingReference' => 'DN123',
'captureMode' => 'completed',
'clearingType' => 'fnc',
@@ -146,7 +146,6 @@ public function testItPerformsPaymentWithPreAuthorizationAndSavesCorrectTransact
'sequenceNumber' => -1,
'userId' => '987654321',
'transactionState' => 'APPROVED',
- 'workOrderId' => null,
'clearingReference' => 'DN123',
'captureMode' => 'completed',
'clearingType' => 'fnc',
@@ -203,6 +202,7 @@ private function getPaymentHandler(
$transactionDataHandler,
$orderActionLogDataHandler,
$requestFactory,
+ $this->createMock(CustomerDataPersistor::class),
$deviceFingerprintService
);
}
diff --git a/tests/PaymentHandler/PayoneSecuredDirectDebitPaymentHandlerTest.php b/tests/PaymentHandler/PayoneSecuredDirectDebitPaymentHandlerTest.php
index fda2cc3f2..2ad3b4e4b 100644
--- a/tests/PaymentHandler/PayoneSecuredDirectDebitPaymentHandlerTest.php
+++ b/tests/PaymentHandler/PayoneSecuredDirectDebitPaymentHandlerTest.php
@@ -6,6 +6,7 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\ConfigReader\ConfigReader;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface;
use PayonePayment\Components\DeviceFingerprint\PayoneBNPLDeviceFingerprintService;
@@ -106,6 +107,7 @@ private function getPaymentHandler(
$transactionDataHandler,
$orderActionLogDataHandler,
$requestFactory,
+ $this->createMock(CustomerDataPersistor::class),
$deviceFingerprintService
);
}
diff --git a/tests/PaymentHandler/PayoneSecuredInstallmentPaymentHandlerTest.php b/tests/PaymentHandler/PayoneSecuredInstallmentPaymentHandlerTest.php
index 64f26e697..30f5b294f 100644
--- a/tests/PaymentHandler/PayoneSecuredInstallmentPaymentHandlerTest.php
+++ b/tests/PaymentHandler/PayoneSecuredInstallmentPaymentHandlerTest.php
@@ -6,6 +6,7 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\ConfigReader\ConfigReader;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface;
use PayonePayment\Components\DeviceFingerprint\PayoneBNPLDeviceFingerprintService;
@@ -106,6 +107,7 @@ private function getPaymentHandler(
$transactionDataHandler,
$orderActionLogDataHandler,
$requestFactory,
+ $this->createMock(CustomerDataPersistor::class),
$deviceFingerprintService
);
}
diff --git a/tests/PaymentHandler/PayoneSecuredInvoicePaymentHandlerTest.php b/tests/PaymentHandler/PayoneSecuredInvoicePaymentHandlerTest.php
index f58d733e0..9e1ea4ad0 100644
--- a/tests/PaymentHandler/PayoneSecuredInvoicePaymentHandlerTest.php
+++ b/tests/PaymentHandler/PayoneSecuredInvoicePaymentHandlerTest.php
@@ -6,6 +6,7 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\ConfigReader\ConfigReader;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface;
use PayonePayment\Components\DeviceFingerprint\PayoneBNPLDeviceFingerprintService;
@@ -114,6 +115,7 @@ private function getPaymentHandler(
$transactionDataHandler,
$orderActionLogDataHandler,
$requestFactory,
+ $this->createMock(CustomerDataPersistor::class),
$deviceFingerprintService
);
}
diff --git a/tests/PaymentHandler/PayoneWeChatPayPaymentHandlerTest.php b/tests/PaymentHandler/PayoneWeChatPayPaymentHandlerTest.php
index 1a3550c1d..e98ee0f5c 100644
--- a/tests/PaymentHandler/PayoneWeChatPayPaymentHandlerTest.php
+++ b/tests/PaymentHandler/PayoneWeChatPayPaymentHandlerTest.php
@@ -6,6 +6,7 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\ConfigReader\ConfigReader;
+use PayonePayment\Components\CustomerDataPersistor\CustomerDataPersistor;
use PayonePayment\Components\DataHandler\OrderActionLog\OrderActionLogDataHandlerInterface;
use PayonePayment\Components\DataHandler\Transaction\TransactionDataHandlerInterface;
use PayonePayment\Components\PaymentStateHandler\PaymentStateHandlerInterface;
@@ -190,7 +191,8 @@ private function getPaymentHandler(
$transactionDataHandler,
$orderActionLogDataHandler,
$stateHandler,
- $requestFactory
+ $requestFactory,
+ $this->createMock(CustomerDataPersistor::class)
);
}
diff --git a/tests/Payone/RequestParameter/Builder/AbstractRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/AbstractRequestParameterBuilderTest.php
new file mode 100644
index 000000000..ecb83a142
--- /dev/null
+++ b/tests/Payone/RequestParameter/Builder/AbstractRequestParameterBuilderTest.php
@@ -0,0 +1,276 @@
+getApplyPhoneBuilder();
+
+ $struct = $this->getPaymentTransactionStruct(
+ new RequestDataBag([
+ ]),
+ PayoneSecureInvoicePaymentHandler::class,
+ ''
+ );
+
+ $this->expectException(\RuntimeException::class);
+ $this->expectExceptionMessage('missing phone number');
+ $handler->getRequestParameter($struct);
+ }
+
+ public function testIfPhoneNumberGotPickedFromRequest(): void
+ {
+ $handler = $this->getApplyPhoneBuilder();
+
+ $struct = $this->getPaymentTransactionStruct(
+ new RequestDataBag([
+ RequestConstants::PHONE => '123456789',
+ ]),
+ PayoneSecureInvoicePaymentHandler::class,
+ ''
+ );
+
+ $billingAddressId = $struct->getPaymentTransaction()->getOrder()->getBillingAddressId();
+
+ /** @var EntityRepository $repo */
+ $addressRepository = $this->getContainer()->get('order_address.repository');
+ $addressRepository->update([[
+ 'id' => $billingAddressId,
+ 'phoneNumber' => null, // make sure, that order-address-phoneNumber is not set
+ ]], Context::createDefaultContext());
+
+ $result = $handler->getRequestParameter($struct);
+ static::assertArrayHasKey('telephonenumber', $result);
+ static::assertEquals('123456789', $result['telephonenumber']);
+ }
+
+ public function testIfPhoneNumberGotPickedFromOrderAddress(): void
+ {
+ $handler = $this->getApplyPhoneBuilder();
+
+ $struct = $this->getPaymentTransactionStruct(
+ new RequestDataBag([]),
+ PayoneSecureInvoicePaymentHandler::class,
+ ''
+ );
+
+ $billingAddressId = $struct->getPaymentTransaction()->getOrder()->getBillingAddressId();
+
+ /** @var EntityRepository $repo */
+ $addressRepository = $this->getContainer()->get('order_address.repository');
+ $addressRepository->update([[
+ 'id' => $billingAddressId,
+ 'phoneNumber' => '9999999',
+ ]], Context::createDefaultContext());
+
+ $result = $handler->getRequestParameter($struct);
+ static::assertArrayHasKey('telephonenumber', $result);
+ static::assertEquals('9999999', $result['telephonenumber']);
+ }
+
+ public function testIfPhoneNumberFromRequestIsMorePrioritizedThanPhoneNumberFromAddress(): void
+ {
+ $handler = $this->getApplyPhoneBuilder();
+
+ $struct = $this->getPaymentTransactionStruct(
+ new RequestDataBag([
+ RequestConstants::PHONE => '123456789',
+ ]),
+ PayoneSecureInvoicePaymentHandler::class,
+ ''
+ );
+
+ $billingAddressId = $struct->getPaymentTransaction()->getOrder()->getBillingAddressId();
+
+ /** @var EntityRepository $repo */
+ $addressRepository = $this->getContainer()->get('order_address.repository');
+ $addressRepository->update([[
+ 'id' => $billingAddressId,
+ 'phoneNumber' => '9999999',
+ ]], Context::createDefaultContext());
+
+ $result = $handler->getRequestParameter($struct);
+ static::assertArrayHasKey('telephonenumber', $result);
+ static::assertEquals('123456789', $result['telephonenumber']);
+ }
+
+ public function testIfRuntimeExceptionIsThrownOnMissingBirthday(): void
+ {
+ // this test should never be required in a real-case because the payment-handler should hold a constraint for validation the required phone-number
+ $handler = $this->getApplyBirthdayBuilder();
+
+ $struct = $this->getPaymentTransactionStruct(
+ new RequestDataBag([]),
+ PayoneSecureInvoicePaymentHandler::class,
+ ''
+ );
+
+ $this->expectException(\RuntimeException::class);
+ $this->expectExceptionMessage('missing birthday');
+ $handler->getRequestParameter($struct);
+ }
+
+ public function testIfRuntimeExceptionIsThrownOnInvalidBirthday(): void
+ {
+ // this test should never be required in a real-case because the payment-handler should hold a constraint for validation the required phone-number
+ $handler = $this->getApplyBirthdayBuilder();
+
+ $struct = $this->getPaymentTransactionStruct(
+ new RequestDataBag([
+ RequestConstants::BIRTHDAY => 'invalid-value',
+ ]),
+ PayoneSecureInvoicePaymentHandler::class,
+ ''
+ );
+
+ $this->expectException(\RuntimeException::class);
+ $this->expectExceptionMessage('missing birthday');
+ $handler->getRequestParameter($struct);
+ }
+
+ public function testIfBirthdayGotPickedFromRequest(): void
+ {
+ $handler = $this->getApplyBirthdayBuilder();
+
+ $struct = $this->getPaymentTransactionStruct(
+ new RequestDataBag([
+ RequestConstants::BIRTHDAY => '2000-04-20',
+ ]),
+ PayoneSecureInvoicePaymentHandler::class,
+ ''
+ );
+
+ $customerId = $struct->getPaymentTransaction()->getOrder()->getOrderCustomer()->getCustomerId();
+
+ /** @var EntityRepository $repo */
+ $customerRepository = $this->getContainer()->get('customer.repository');
+ $customerRepository->update([[
+ 'id' => $customerId,
+ 'birthday' => null, // make sure, that customer birthday is not set
+ ]], Context::createDefaultContext());
+
+ $result = $handler->getRequestParameter($struct);
+ static::assertArrayHasKey('birthday', $result);
+ static::assertEquals('20000420', $result['birthday']);
+ }
+
+ public function testIfBirthdayGotPickedFromCustomer(): void
+ {
+ $handler = $this->getApplyBirthdayBuilder();
+
+ $struct = $this->getPaymentTransactionStruct(
+ new RequestDataBag([]),
+ PayoneSecureInvoicePaymentHandler::class,
+ ''
+ );
+
+ $struct->getPaymentTransaction()
+ ->getOrder()
+ ->getOrderCustomer()
+ ->getCustomer()
+ ->setBirthday(\DateTime::createFromFormat('Y-m-d', '1954-01-01'));
+
+ $result = $handler->getRequestParameter($struct);
+ static::assertArrayHasKey('birthday', $result);
+ static::assertEquals('19540101', $result['birthday']);
+ }
+
+ public function testIfBirthdayFromRequestIsMorePrioritizedThanBirthdayFromCustomer(): void
+ {
+ $handler = $this->getApplyBirthdayBuilder();
+
+ $struct = $this->getPaymentTransactionStruct(
+ new RequestDataBag([
+ RequestConstants::BIRTHDAY => '2000-04-20',
+ ]),
+ PayoneSecureInvoicePaymentHandler::class,
+ ''
+ );
+
+ $customerId = $struct->getPaymentTransaction()->getOrder()->getOrderCustomer()->getCustomerId();
+
+ $struct->getPaymentTransaction()
+ ->getOrder()
+ ->getOrderCustomer()
+ ->getCustomer()
+ ->setBirthday(\DateTime::createFromFormat('Y-m-d', '1954-01-01'));
+
+ $result = $handler->getRequestParameter($struct);
+ static::assertArrayHasKey('birthday', $result);
+ static::assertEquals('20000420', $result['birthday']);
+ }
+
+ private function getApplyBirthdayBuilder(): AbstractRequestParameterBuilder
+ {
+ return new class($this->getContainer()->get(RequestBuilderServiceAccessor::class)) extends AbstractRequestParameterBuilder {
+ /**
+ * @param PaymentTransactionStruct $arguments
+ */
+ public function getRequestParameter(AbstractRequestParameterStruct $arguments): array
+ {
+ $parameters = [];
+
+ $this->applyBirthdayParameter(
+ $arguments->getPaymentTransaction()->getOrder(),
+ $parameters,
+ $arguments->getRequestData(),
+ $arguments->getSalesChannelContext()->getContext()
+ );
+
+ return $parameters;
+ }
+
+ public function supports(AbstractRequestParameterStruct $arguments): bool
+ {
+ return $arguments instanceof PaymentTransactionStruct;
+ }
+ };
+ }
+
+ private function getApplyPhoneBuilder(): AbstractRequestParameterBuilder
+ {
+ return new class($this->getContainer()->get(RequestBuilderServiceAccessor::class)) extends AbstractRequestParameterBuilder {
+ /**
+ * @param PaymentTransactionStruct $arguments
+ */
+ public function getRequestParameter(AbstractRequestParameterStruct $arguments): array
+ {
+ $parameters = [];
+
+ $this->applyPhoneParameter(
+ $arguments->getPaymentTransaction()->getOrder(),
+ $parameters,
+ $arguments->getRequestData(),
+ $arguments->getSalesChannelContext()->getContext()
+ );
+
+ return $parameters;
+ }
+
+ public function supports(AbstractRequestParameterStruct $arguments): bool
+ {
+ return $arguments instanceof PaymentTransactionStruct;
+ }
+ };
+ }
+}
diff --git a/tests/Payone/RequestParameter/Builder/Capture/CaptureRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/Capture/CaptureRequestParameterBuilderTest.php
index db69c1e45..e94cd4f21 100644
--- a/tests/Payone/RequestParameter/Builder/Capture/CaptureRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/Capture/CaptureRequestParameterBuilderTest.php
@@ -17,6 +17,7 @@
use PayonePayment\TestCaseBase\PayoneTestBehavior;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Checkout\Payment\Exception\InvalidOrderException;
+use Shopware\Core\Checkout\Payment\PaymentException;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
/**
@@ -107,7 +108,12 @@ public function testItThrowsExceptionOnMissingTransactionData(): void
$builder = $this->getContainer()->get(CaptureRequestParameterBuilder::class);
$struct->getPaymentTransaction()->getOrderTransaction()->removeExtension(PayonePaymentOrderTransactionExtension::NAME);
- $this->expectException(InvalidOrderException::class);
+ if (class_exists(PaymentException::class)) {
+ $this->expectException(PaymentException::class);
+ } else {
+ $this->expectException(InvalidOrderException::class);
+ }
+
$builder->getRequestParameter($struct);
}
@@ -131,7 +137,12 @@ public function testItThrowsExceptionOnMissingSequenceNumber(): void
]);
$struct->getPaymentTransaction()->getOrderTransaction()->addExtension(PayonePaymentOrderTransactionExtension::NAME, $extension);
- $this->expectException(InvalidOrderException::class);
+ if (class_exists(PaymentException::class)) {
+ $this->expectException(PaymentException::class);
+ } else {
+ $this->expectException(InvalidOrderException::class);
+ }
+
$builder->getRequestParameter($struct);
}
@@ -155,7 +166,12 @@ public function testItThrowsExceptionOnInvalidSequenceNumber(): void
]);
$struct->getPaymentTransaction()->getOrderTransaction()->addExtension(PayonePaymentOrderTransactionExtension::NAME, $extension);
- $this->expectException(InvalidOrderException::class);
+ if (class_exists(PaymentException::class)) {
+ $this->expectException(PaymentException::class);
+ } else {
+ $this->expectException(InvalidOrderException::class);
+ }
+
$builder->getRequestParameter($struct);
}
@@ -175,7 +191,6 @@ public function testItAddsParametersByExtensionFields(): void
/** @var PayonePaymentOrderTransactionDataEntity $extension */
$extension = $struct->getPaymentTransaction()->getOrderTransaction()->getExtension(PayonePaymentOrderTransactionExtension::NAME);
$extension->assign([
- 'workOrderId' => '123',
'captureMode' => CaptureRequestParameterBuilder::CAPTUREMODE_COMPLETED,
'clearingType' => AbstractPayonePaymentHandler::PAYONE_CLEARING_FNC,
]);
@@ -185,7 +200,6 @@ public function testItAddsParametersByExtensionFields(): void
Assert::assertArraySubset(
[
- 'workorderid' => 123,
'capturemode' => CaptureRequestParameterBuilder::CAPTUREMODE_COMPLETED,
'clearingtype' => AbstractPayonePaymentHandler::PAYONE_CLEARING_FNC,
],
diff --git a/tests/Payone/RequestParameter/Builder/GeneralTransactionRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/GeneralTransactionRequestParameterBuilderTest.php
index 4170c18e4..6bd77ad8d 100644
--- a/tests/Payone/RequestParameter/Builder/GeneralTransactionRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/GeneralTransactionRequestParameterBuilderTest.php
@@ -7,13 +7,15 @@
use PayonePayment\Components\CartHasher\CartHasherInterface;
use PayonePayment\Components\ConfigReader\ConfigReaderInterface;
use PayonePayment\Components\Currency\CurrencyPrecisionInterface;
+use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydratorInterface;
use PayonePayment\PaymentHandler\PayoneCreditCardPaymentHandler;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ClassHelper;
use PayonePayment\TestCaseBase\PayoneTestBehavior;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionCollection;
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity;
-use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
use Shopware\Core\System\Currency\CurrencyEntity;
use Symfony\Component\HttpFoundation\ParameterBag;
@@ -68,6 +70,7 @@ public function testItAddsCorrectAmountAndCurrency(): void
$struct->getPaymentTransaction()->getOrder()->setCurrency($currency);
$struct->getPaymentTransaction()->getOrder()->setAmountTotal(100.1);
+ /** @var MockObject&CurrencyPrecisionInterface $currencyPrecision */
$currencyPrecision = $this->createMock(CurrencyPrecisionInterface::class);
$currencyPrecision
->expects(static::once())
@@ -79,10 +82,16 @@ public function testItAddsCorrectAmountAndCurrency(): void
->willReturn(10010);
$builder = new GeneralTransactionRequestParameterBuilder(
+ new RequestBuilderServiceAccessor(
+ $this->getContainer()->get('customer.repository'),
+ $this->getContainer()->get('order_address.repository'),
+ $this->getContainer()->get('customer_address.repository'),
+ $this->getContainer()->get('currency.repository'),
+ $currencyPrecision,
+ $this->getContainer()->get(LineItemHydratorInterface::class)
+ ),
$this->createMock(CartHasherInterface::class),
- $this->createMock(ConfigReaderInterface::class),
- $this->createMock(EntityRepository::class),
- $currencyPrecision
+ $this->createMock(ConfigReaderInterface::class)
);
$parameters = $builder->getRequestParameter($struct);
@@ -95,8 +104,8 @@ public function testItAddsCorrectWorkorderId(): void
{
$struct = $this->getPaymentTransactionStruct(
new RequestDataBag([
- 'carthash' => 'the-hash',
- 'workorder' => 'the-workorder',
+ RequestConstants::CART_HASH => 'the-hash',
+ RequestConstants::WORK_ORDER_ID => 'the-workorder',
]),
PayoneCreditCardPaymentHandler::class,
AbstractRequestParameterBuilder::REQUEST_ACTION_AUTHORIZE
@@ -106,10 +115,9 @@ public function testItAddsCorrectWorkorderId(): void
$cartHasher->expects(static::once())->method('validate')->willReturn(true);
$builder = new GeneralTransactionRequestParameterBuilder(
+ $this->getContainer()->get(RequestBuilderServiceAccessor::class),
$cartHasher,
- $this->createMock(ConfigReaderInterface::class),
- $this->createMock(EntityRepository::class),
- $this->createMock(CurrencyPrecisionInterface::class)
+ $this->createMock(ConfigReaderInterface::class)
);
$parameters = $builder->getRequestParameter($struct);
@@ -121,18 +129,13 @@ public function testItAddsNoWorkorderIdOnMissingHash(): void
{
$struct = $this->getPaymentTransactionStruct(
new RequestDataBag([
- 'workorder' => 'the-workorder',
+ RequestConstants::WORK_ORDER_ID => 'the-workorder',
]),
PayoneCreditCardPaymentHandler::class,
AbstractRequestParameterBuilder::REQUEST_ACTION_AUTHORIZE
);
- $builder = new GeneralTransactionRequestParameterBuilder(
- $this->createMock(CartHasherInterface::class),
- $this->createMock(ConfigReaderInterface::class),
- $this->createMock(EntityRepository::class),
- $this->createMock(CurrencyPrecisionInterface::class)
- );
+ $builder = $this->getContainer()->get(GeneralTransactionRequestParameterBuilder::class);
$parameters = $builder->getRequestParameter($struct);
@@ -143,8 +146,8 @@ public function testItAddsNoWorkorderIdOnInvalidHash(): void
{
$struct = $this->getPaymentTransactionStruct(
new RequestDataBag([
- 'carthash' => 'the-hash',
- 'workorder' => 'the-workorder',
+ RequestConstants::CART_HASH => 'the-hash',
+ RequestConstants::WORK_ORDER_ID => 'the-workorder',
]),
PayoneCreditCardPaymentHandler::class,
AbstractRequestParameterBuilder::REQUEST_ACTION_AUTHORIZE
@@ -154,10 +157,9 @@ public function testItAddsNoWorkorderIdOnInvalidHash(): void
$cartHasher->expects(static::once())->method('validate')->willReturn(false);
$builder = new GeneralTransactionRequestParameterBuilder(
+ $this->getContainer()->get(RequestBuilderServiceAccessor::class),
$cartHasher,
- $this->createMock(ConfigReaderInterface::class),
- $this->createMock(EntityRepository::class),
- $this->createMock(CurrencyPrecisionInterface::class)
+ $this->createMock(ConfigReaderInterface::class)
);
$parameters = $builder->getRequestParameter($struct);
@@ -175,12 +177,7 @@ public function testItAddsOrderNumberAsReference(): void
$struct->getPaymentTransaction()->getOrder()->setOrderNumber('the-order-number');
- $builder = new GeneralTransactionRequestParameterBuilder(
- $this->createMock(CartHasherInterface::class),
- $this->createMock(ConfigReaderInterface::class),
- $this->createMock(EntityRepository::class),
- $this->createMock(CurrencyPrecisionInterface::class)
- );
+ $builder = $this->getContainer()->get(GeneralTransactionRequestParameterBuilder::class);
$parameters = $builder->getRequestParameter($struct);
@@ -211,12 +208,7 @@ public function testItAddsOrderNumberWithSuffixAsReference(): void
)
);
- $builder = new GeneralTransactionRequestParameterBuilder(
- $this->createMock(CartHasherInterface::class),
- $this->createMock(ConfigReaderInterface::class),
- $this->createMock(EntityRepository::class),
- $this->createMock(CurrencyPrecisionInterface::class)
- );
+ $builder = $this->getContainer()->get(GeneralTransactionRequestParameterBuilder::class);
$parameters = $builder->getRequestParameter($struct);
diff --git a/tests/Payone/RequestParameter/Builder/Klarna/CreateSessionRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/Klarna/CreateSessionRequestParameterBuilderTest.php
index 177beb86e..2fbb95fb0 100644
--- a/tests/Payone/RequestParameter/Builder/Klarna/CreateSessionRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/Klarna/CreateSessionRequestParameterBuilderTest.php
@@ -17,7 +17,7 @@ public function testItAddsCorrectCreateSessionParameters(): void
{
$salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
- $this->createCartWithProduct($salesChannelContext, 123.45, 4);
+ $this->createCartWithProduct($salesChannelContext);
$struct = new KlarnaCreateSessionStruct($salesChannelContext, PayoneKlarnaInvoicePaymentHandler::class);
diff --git a/tests/Payone/RequestParameter/Builder/PayolutionDebit/AuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/PayolutionDebit/AuthorizeRequestParameterBuilderTest.php
index f56192e38..96d3a3063 100644
--- a/tests/Payone/RequestParameter/Builder/PayolutionDebit/AuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/PayolutionDebit/AuthorizeRequestParameterBuilderTest.php
@@ -8,6 +8,7 @@
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayonePayolutionDebitPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
@@ -26,7 +27,7 @@ public function testItAddsCorrectAuthorizeParameters(): void
$dataBag = new RequestDataBag([
'payolutionIban' => 'DE81500105177147426471',
'payolutionBic' => 'ABCD1111',
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
diff --git a/tests/Payone/RequestParameter/Builder/PayolutionDebit/PreAuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/PayolutionDebit/PreAuthorizeRequestParameterBuilderTest.php
index 862db917f..2b7ebac71 100644
--- a/tests/Payone/RequestParameter/Builder/PayolutionDebit/PreAuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/PayolutionDebit/PreAuthorizeRequestParameterBuilderTest.php
@@ -8,6 +8,7 @@
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayonePayolutionDebitPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
@@ -26,7 +27,7 @@ public function testItAddsCorrectPreAuthorizeParameters(): void
$dataBag = new RequestDataBag([
'payolutionIban' => 'DE81500105177147426471',
'payolutionBic' => 'ABCD1111',
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
diff --git a/tests/Payone/RequestParameter/Builder/PayolutionInstallment/AuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/PayolutionInstallment/AuthorizeRequestParameterBuilderTest.php
index 1681c77c6..771cba779 100644
--- a/tests/Payone/RequestParameter/Builder/PayolutionInstallment/AuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/PayolutionInstallment/AuthorizeRequestParameterBuilderTest.php
@@ -8,6 +8,7 @@
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayonePayolutionInstallmentPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
@@ -28,7 +29,7 @@ public function testItAddsCorrectAuthorizeParameters(): void
'payolutionBic' => 'ABCD1111',
'payolutionAccountOwner' => 'Tester Test',
'payolutionInstallmentDuration' => 12,
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
diff --git a/tests/Payone/RequestParameter/Builder/PayolutionInstallment/PreAuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/PayolutionInstallment/PreAuthorizeRequestParameterBuilderTest.php
index fe5d67dbe..9ab3ef899 100644
--- a/tests/Payone/RequestParameter/Builder/PayolutionInstallment/PreAuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/PayolutionInstallment/PreAuthorizeRequestParameterBuilderTest.php
@@ -8,6 +8,7 @@
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayonePayolutionInstallmentPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
@@ -28,7 +29,7 @@ public function testItAddsCorrectPreAuthorizeParameters(): void
'payolutionBic' => 'ABCD1111',
'payolutionAccountOwner' => 'Tester Test',
'payolutionInstallmentDuration' => 12,
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
diff --git a/tests/Payone/RequestParameter/Builder/PayolutionInstallment/PreCheckRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/PayolutionInstallment/PreCheckRequestParameterBuilderTest.php
index e21f8e877..aa1775f16 100644
--- a/tests/Payone/RequestParameter/Builder/PayolutionInstallment/PreCheckRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/PayolutionInstallment/PreCheckRequestParameterBuilderTest.php
@@ -5,11 +5,13 @@
namespace PayonePayment\Payone\RequestParameter\Builder\PayolutionInstallment;
use DMS\PHPUnitExtensions\ArraySubset\Assert;
+use PayonePayment\Constants;
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayonePayolutionInstallmentPaymentHandler;
use PayonePayment\PaymentHandler\PayoneRatepayDebitPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
use PayonePayment\Payone\RequestParameter\Struct\PayolutionAdditionalActionStruct;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PayoneTestBehavior;
use PHPUnit\Framework\TestCase;
@@ -81,7 +83,7 @@ public function testItAddsCorrectPreCheckParameters(): void
'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PYS,
'add_paydata[action]' => 'pre_check',
'add_paydata[payment_type]' => 'Payolution-Installment',
- 'amount' => 10000,
+ 'amount' => Constants::DEFAULT_PRODUCT_PRICE * 100,
'currency' => 'EUR',
'workorderid' => '',
'birthday' => '20000101',
@@ -95,10 +97,10 @@ protected function getPayolutionAdditionalActionStruct(
string $requestAction = AbstractRequestParameterBuilder::REQUEST_ACTION_PAYOLUTION_PRE_CHECK
): PayolutionAdditionalActionStruct {
$salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
- $cart = $this->fillCart($salesChannelContext->getToken(), 100);
+ $cart = $this->fillCart($salesChannelContext);
$dataBag = new RequestDataBag([
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
return new PayolutionAdditionalActionStruct(
diff --git a/tests/Payone/RequestParameter/Builder/PayolutionInvoicing/AuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/PayolutionInvoicing/AuthorizeRequestParameterBuilderTest.php
index baf191c6f..079df4ff5 100644
--- a/tests/Payone/RequestParameter/Builder/PayolutionInvoicing/AuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/PayolutionInvoicing/AuthorizeRequestParameterBuilderTest.php
@@ -9,6 +9,7 @@
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayonePayolutionInvoicingPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
@@ -26,7 +27,7 @@ class AuthorizeRequestParameterBuilderTest extends TestCase
public function testItAddsCorrectAuthorizeParameters(): void
{
$dataBag = new RequestDataBag([
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
@@ -58,7 +59,7 @@ public function testItAddsCorrectAuthorizeParametersForCompanyByBillingAddress()
);
$dataBag = new RequestDataBag([
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
@@ -102,7 +103,7 @@ public function testItAddsCorrectAuthorizeParametersForCompanyByOrderCustomer():
);
$dataBag = new RequestDataBag([
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
@@ -146,7 +147,7 @@ public function testItNotAddsCompanyParametersOnDeactivatedConfiguration(): void
);
$dataBag = new RequestDataBag([
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
diff --git a/tests/Payone/RequestParameter/Builder/PayolutionInvoicing/PreAuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/PayolutionInvoicing/PreAuthorizeRequestParameterBuilderTest.php
index 9c7b1bba8..2b9628e8d 100644
--- a/tests/Payone/RequestParameter/Builder/PayolutionInvoicing/PreAuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/PayolutionInvoicing/PreAuthorizeRequestParameterBuilderTest.php
@@ -9,6 +9,7 @@
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayonePayolutionInvoicingPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
@@ -26,7 +27,7 @@ class PreAuthorizeRequestParameterBuilderTest extends TestCase
public function testItAddsCorrectPreAuthorizeParameters(): void
{
$dataBag = new RequestDataBag([
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
@@ -58,7 +59,7 @@ public function testItAddsCorrectPreAuthorizeParametersForCompanyByBillingAddres
);
$dataBag = new RequestDataBag([
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
@@ -102,7 +103,7 @@ public function testItAddsCorrectPreAuthorizeParametersForCompanyByOrderCustomer
);
$dataBag = new RequestDataBag([
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
@@ -146,7 +147,7 @@ public function testItNotAddsCompanyParametersOnDeactivatedConfiguration(): void
);
$dataBag = new RequestDataBag([
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
diff --git a/tests/Payone/RequestParameter/Builder/PayolutionInvoicing/PreCheckRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/PayolutionInvoicing/PreCheckRequestParameterBuilderTest.php
index 268caf3f4..1c9b4fbc4 100644
--- a/tests/Payone/RequestParameter/Builder/PayolutionInvoicing/PreCheckRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/PayolutionInvoicing/PreCheckRequestParameterBuilderTest.php
@@ -5,12 +5,14 @@
namespace PayonePayment\Payone\RequestParameter\Builder\PayolutionInvoicing;
use DMS\PHPUnitExtensions\ArraySubset\Assert;
+use PayonePayment\Constants;
use PayonePayment\Installer\ConfigInstaller;
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayonePayolutionInvoicingPaymentHandler;
use PayonePayment\PaymentHandler\PayoneRatepayDebitPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
use PayonePayment\Payone\RequestParameter\Struct\PayolutionAdditionalActionStruct;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PayoneTestBehavior;
use PHPUnit\Framework\TestCase;
@@ -82,7 +84,7 @@ public function testItAddsCorrectPreCheckParameters(): void
'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PYV,
'add_paydata[action]' => 'pre_check',
'add_paydata[payment_type]' => 'Payolution-Invoicing',
- 'amount' => 10000,
+ 'amount' => Constants::DEFAULT_PRODUCT_PRICE * 100,
'currency' => 'EUR',
'workorderid' => '',
'birthday' => '20000101',
@@ -112,7 +114,7 @@ public function testItAddsCorrectCompanyParametersByBillingAddress(): void
'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PYV,
'add_paydata[action]' => 'pre_check',
'add_paydata[payment_type]' => 'Payolution-Invoicing',
- 'amount' => 10000,
+ 'amount' => Constants::DEFAULT_PRODUCT_PRICE * 100,
'currency' => 'EUR',
'workorderid' => '',
'birthday' => '20000101',
@@ -144,7 +146,7 @@ public function testItAddsCorrectCompanyParametersByCustomer(): void
'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PYV,
'add_paydata[action]' => 'pre_check',
'add_paydata[payment_type]' => 'Payolution-Invoicing',
- 'amount' => 10000,
+ 'amount' => Constants::DEFAULT_PRODUCT_PRICE * 100,
'currency' => 'EUR',
'workorderid' => '',
'birthday' => '20000101',
@@ -179,10 +181,10 @@ protected function getPayolutionAdditionalActionStruct(
string $requestAction = AbstractRequestParameterBuilder::REQUEST_ACTION_PAYOLUTION_PRE_CHECK
): PayolutionAdditionalActionStruct {
$salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
- $cart = $this->fillCart($salesChannelContext->getToken(), 100);
+ $cart = $this->fillCart($salesChannelContext);
$dataBag = new RequestDataBag([
- 'payolutionBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
return new PayolutionAdditionalActionStruct(
diff --git a/tests/Payone/RequestParameter/Builder/RatepayDebit/AuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/RatepayDebit/AuthorizeRequestParameterBuilderTest.php
index 908b10b2c..0083a76ff 100644
--- a/tests/Payone/RequestParameter/Builder/RatepayDebit/AuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/RatepayDebit/AuthorizeRequestParameterBuilderTest.php
@@ -7,10 +7,10 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\DeviceFingerprint\RatepayDeviceFingerprintService;
use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydrator;
-use PayonePayment\Installer\CustomFieldInstaller;
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneRatepayDebitPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
@@ -36,8 +36,8 @@ public function testItAddsCorrectAuthorizeParameters(): void
$dataBag = new RequestDataBag([
'ratepayIban' => 'DE81500105177147426471',
- 'payonePhone' => '0123456789',
- 'ratepayBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
@@ -77,7 +77,7 @@ public function testItThrowsExceptionOnMissingPhoneNumber(): void
$dataBag = new RequestDataBag([
'ratepayIban' => 'DE81500105177147426471',
- 'ratepayBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
@@ -94,56 +94,6 @@ public function testItThrowsExceptionOnMissingPhoneNumber(): void
$builder->getRequestParameter($struct);
}
- public function testItAddsCorrectAuthorizeParametersWithSavedPhoneNumber(): void
- {
- $this->setValidRatepayProfiles($this->getContainer(), $this->getValidPaymentHandler());
-
- $request = $this->getRequestWithSession([
- RatepayDeviceFingerprintService::SESSION_VAR_NAME => 'the-device-ident-token',
- ]);
- $this->getContainer()->get(RequestStack::class)->push($request);
-
- $dataBag = new RequestDataBag([
- 'ratepayIban' => 'DE81500105177147426471',
- 'ratepayBirthday' => '2000-01-01',
- ]);
-
- $struct = $this->getPaymentTransactionStruct(
- $dataBag,
- $this->getValidPaymentHandler(),
- $this->getValidRequestAction()
- );
-
- $builder = $this->getContainer()->get($this->getParameterBuilder());
-
- // Save phone number on customer custom fields
- $this->getContainer()->get('customer.repository')->update([
- [
- 'id' => $struct->getPaymentTransaction()->getOrder()->getOrderCustomer()->getCustomerId(),
- 'customFields' => [
- CustomFieldInstaller::CUSTOMER_PHONE_NUMBER => '0123456789',
- ],
- ],
- ], $struct->getSalesChannelContext()->getContext());
-
- $parameters = $builder->getRequestParameter($struct);
-
- Assert::assertArraySubset(
- [
- 'request' => $this->getValidRequestAction(),
- 'clearingtype' => AbstractRequestParameterBuilder::CLEARING_TYPE_FINANCING,
- 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_RPD,
- 'iban' => 'DE81500105177147426471',
- 'add_paydata[customer_allow_credit_inquiry]' => 'yes',
- 'add_paydata[shop_id]' => '88880103',
- 'telephonenumber' => '0123456789',
- 'birthday' => '20000101',
- 'it[1]' => LineItemHydrator::TYPE_GOODS,
- ],
- $parameters
- );
- }
-
protected function getParameterBuilder(): string
{
return AuthorizeRequestParameterBuilder::class;
diff --git a/tests/Payone/RequestParameter/Builder/RatepayDebit/PreAuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/RatepayDebit/PreAuthorizeRequestParameterBuilderTest.php
index 115cd0c7e..bba8b2315 100644
--- a/tests/Payone/RequestParameter/Builder/RatepayDebit/PreAuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/RatepayDebit/PreAuthorizeRequestParameterBuilderTest.php
@@ -10,6 +10,7 @@
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneRatepayDebitPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
@@ -35,8 +36,8 @@ public function testItAddsCorrectPreAuthorizeParameters(): void
$dataBag = new RequestDataBag([
'ratepayIban' => 'DE81500105177147426471',
- 'payonePhone' => '0123456789',
- 'ratepayBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
diff --git a/tests/Payone/RequestParameter/Builder/RatepayInstallment/AuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/RatepayInstallment/AuthorizeRequestParameterBuilderTest.php
index bc069bbe5..01761e7e5 100644
--- a/tests/Payone/RequestParameter/Builder/RatepayInstallment/AuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/RatepayInstallment/AuthorizeRequestParameterBuilderTest.php
@@ -7,10 +7,10 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\DeviceFingerprint\RatepayDeviceFingerprintService;
use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydrator;
-use PayonePayment\Installer\CustomFieldInstaller;
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneRatepayInstallmentPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
@@ -42,8 +42,8 @@ public function testItAddsCorrectAuthorizeParametersWithIban(): void
$dataBag = new RequestDataBag([
'ratepayIban' => 'DE81500105177147426471',
- 'payonePhone' => '0123456789',
- 'ratepayBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
'ratepayInstallmentAmount' => '100',
'ratepayInstallmentNumber' => '24',
'ratepayLastInstallmentAmount' => '101',
@@ -99,8 +99,8 @@ public function testItAddsCorrectAuthorizeParametersWithoutIban(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
- 'ratepayBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
'ratepayInstallmentAmount' => '100',
'ratepayInstallmentNumber' => '24',
'ratepayLastInstallmentAmount' => '101',
@@ -138,7 +138,7 @@ public function testItThrowsExceptionOnMissingPhoneNumber(): void
$dataBag = new RequestDataBag([
'ratepayIban' => 'DE81500105177147426471',
- 'ratepayBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
'ratepayInstallmentAmount' => '100',
'ratepayInstallmentNumber' => '24',
'ratepayLastInstallmentAmount' => '101',
@@ -160,73 +160,6 @@ public function testItThrowsExceptionOnMissingPhoneNumber(): void
$builder->getRequestParameter($struct);
}
- public function testItAddsCorrectAuthorizeParametersWithSavedPhoneNumber(): void
- {
- $this->setValidRatepayProfiles(
- $this->getContainer(),
- $this->getValidPaymentHandler(),
- [
- 'tx-limit-installment-min' => '10',
- ]
- );
-
- $request = $this->getRequestWithSession([
- RatepayDeviceFingerprintService::SESSION_VAR_NAME => 'the-device-ident-token',
- ]);
- $this->getContainer()->get(RequestStack::class)->push($request);
-
- $dataBag = new RequestDataBag([
- 'ratepayIban' => 'DE81500105177147426471',
- 'ratepayBirthday' => '2000-01-01',
- 'ratepayInstallmentAmount' => '100',
- 'ratepayInstallmentNumber' => '24',
- 'ratepayLastInstallmentAmount' => '101',
- 'ratepayInterestRate' => '10',
- 'ratepayTotalAmount' => '1000',
- ]);
-
- $struct = $this->getPaymentTransactionStruct(
- $dataBag,
- $this->getValidPaymentHandler(),
- $this->getValidRequestAction()
- );
-
- $builder = $this->getContainer()->get($this->getParameterBuilder());
-
- // Save phone number on customer custom fields
- $this->getContainer()->get('customer.repository')->update([
- [
- 'id' => $struct->getPaymentTransaction()->getOrder()->getOrderCustomer()->getCustomerId(),
- 'customFields' => [
- CustomFieldInstaller::CUSTOMER_PHONE_NUMBER => '0123456789',
- ],
- ],
- ], $struct->getSalesChannelContext()->getContext());
-
- $parameters = $builder->getRequestParameter($struct);
-
- Assert::assertArraySubset(
- [
- 'request' => $this->getValidRequestAction(),
- 'clearingtype' => AbstractRequestParameterBuilder::CLEARING_TYPE_FINANCING,
- 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_RPS,
- 'iban' => 'DE81500105177147426471',
- 'add_paydata[customer_allow_credit_inquiry]' => 'yes',
- 'add_paydata[shop_id]' => '88880103',
- 'add_paydata[installment_amount]' => 10000,
- 'add_paydata[installment_number]' => 24,
- 'add_paydata[last_installment_amount]' => 10100,
- 'add_paydata[interest_rate]' => 1000,
- 'add_paydata[amount]' => 100000,
- 'add_paydata[debit_paytype]' => 'DIRECT-DEBIT',
- 'telephonenumber' => '0123456789',
- 'birthday' => '20000101',
- 'it[1]' => LineItemHydrator::TYPE_GOODS,
- ],
- $parameters
- );
- }
-
protected function getParameterBuilder(): string
{
return AuthorizeRequestParameterBuilder::class;
diff --git a/tests/Payone/RequestParameter/Builder/RatepayInstallment/CalculationRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/RatepayInstallment/CalculationRequestParameterBuilderTest.php
index 6fb0f6d87..edbdc3777 100644
--- a/tests/Payone/RequestParameter/Builder/RatepayInstallment/CalculationRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/RatepayInstallment/CalculationRequestParameterBuilderTest.php
@@ -6,6 +6,7 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\Ratepay\Profile\ProfileService;
+use PayonePayment\Constants;
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneRatepayDebitPaymentHandler;
use PayonePayment\PaymentHandler\PayoneRatepayInstallmentPaymentHandler;
@@ -95,7 +96,7 @@ public function testItAddsTheInstallmentCalculationRequestParametersByRate(): vo
'add_paydata[customer_allow_credit_inquiry]' => 'yes',
'add_paydata[calculation_type]' => 'calculation-by-rate',
'add_paydata[rate]' => 1000,
- 'amount' => 10000,
+ 'amount' => Constants::DEFAULT_PRODUCT_PRICE * 100,
'currency' => 'EUR',
],
$parameters
@@ -119,7 +120,7 @@ public function testItAddsTheInstallmentCalculationRequestParametersByTime(): vo
'add_paydata[customer_allow_credit_inquiry]' => 'yes',
'add_paydata[calculation_type]' => 'calculation-by-time',
'add_paydata[month]' => 10,
- 'amount' => 10000,
+ 'amount' => Constants::DEFAULT_PRODUCT_PRICE * 100,
'currency' => 'EUR',
],
$parameters
@@ -133,7 +134,7 @@ protected function getRatepayCalculationStruct(
string $requestAction = AbstractRequestParameterBuilder::REQUEST_ACTION_RATEPAY_CALCULATION
): RatepayCalculationStruct {
$salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
- $cart = $this->fillCart($salesChannelContext->getToken(), 100);
+ $cart = $this->fillCart($salesChannelContext);
$profile = $this->getContainer()->get(ProfileService::class)->getProfileBySalesChannelContext(
$salesChannelContext,
$paymentHandler
diff --git a/tests/Payone/RequestParameter/Builder/RatepayInstallment/PreAuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/RatepayInstallment/PreAuthorizeRequestParameterBuilderTest.php
index 88f8d5227..7320102eb 100644
--- a/tests/Payone/RequestParameter/Builder/RatepayInstallment/PreAuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/RatepayInstallment/PreAuthorizeRequestParameterBuilderTest.php
@@ -10,6 +10,7 @@
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneRatepayInstallmentPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
@@ -41,8 +42,8 @@ public function testItAddsCorrectPreAuthorizeParameters(): void
$dataBag = new RequestDataBag([
'ratepayIban' => 'DE81500105177147426471',
- 'payonePhone' => '0123456789',
- 'ratepayBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
'ratepayInstallmentAmount' => '100',
'ratepayInstallmentNumber' => '24',
'ratepayLastInstallmentAmount' => '101',
diff --git a/tests/Payone/RequestParameter/Builder/RatepayInvoicing/AuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/RatepayInvoicing/AuthorizeRequestParameterBuilderTest.php
index b45058645..b5c72d3cc 100644
--- a/tests/Payone/RequestParameter/Builder/RatepayInvoicing/AuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/RatepayInvoicing/AuthorizeRequestParameterBuilderTest.php
@@ -7,10 +7,10 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\DeviceFingerprint\RatepayDeviceFingerprintService;
use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydrator;
-use PayonePayment\Installer\CustomFieldInstaller;
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneRatepayInvoicingPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
@@ -35,8 +35,8 @@ public function testItAddsCorrectAuthorizeParameters(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
- 'ratepayBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
@@ -74,7 +74,7 @@ public function testItThrowsExceptionOnMissingPhoneNumber(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'ratepayBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
@@ -91,54 +91,6 @@ public function testItThrowsExceptionOnMissingPhoneNumber(): void
$builder->getRequestParameter($struct);
}
- public function testItAddsCorrectAuthorizeParametersWithSavedPhoneNumber(): void
- {
- $this->setValidRatepayProfiles($this->getContainer(), $this->getValidPaymentHandler());
-
- $request = $this->getRequestWithSession([
- RatepayDeviceFingerprintService::SESSION_VAR_NAME => 'the-device-ident-token',
- ]);
- $this->getContainer()->get(RequestStack::class)->push($request);
-
- $dataBag = new RequestDataBag([
- 'ratepayBirthday' => '2000-01-01',
- ]);
-
- $struct = $this->getPaymentTransactionStruct(
- $dataBag,
- $this->getValidPaymentHandler(),
- $this->getValidRequestAction()
- );
-
- $builder = $this->getContainer()->get($this->getParameterBuilder());
-
- // Save phone number on customer custom fields
- $this->getContainer()->get('customer.repository')->update([
- [
- 'id' => $struct->getPaymentTransaction()->getOrder()->getOrderCustomer()->getCustomerId(),
- 'customFields' => [
- CustomFieldInstaller::CUSTOMER_PHONE_NUMBER => '0123456789',
- ],
- ],
- ], $struct->getSalesChannelContext()->getContext());
-
- $parameters = $builder->getRequestParameter($struct);
-
- Assert::assertArraySubset(
- [
- 'request' => $this->getValidRequestAction(),
- 'clearingtype' => AbstractRequestParameterBuilder::CLEARING_TYPE_FINANCING,
- 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_RPV,
- 'add_paydata[customer_allow_credit_inquiry]' => 'yes',
- 'add_paydata[shop_id]' => '88880103',
- 'telephonenumber' => '0123456789',
- 'birthday' => '20000101',
- 'it[1]' => LineItemHydrator::TYPE_GOODS,
- ],
- $parameters
- );
- }
-
protected function getParameterBuilder(): string
{
return AuthorizeRequestParameterBuilder::class;
diff --git a/tests/Payone/RequestParameter/Builder/RatepayInvoicing/PreAuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/RatepayInvoicing/PreAuthorizeRequestParameterBuilderTest.php
index 64b99fe8d..41da0134a 100644
--- a/tests/Payone/RequestParameter/Builder/RatepayInvoicing/PreAuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/RatepayInvoicing/PreAuthorizeRequestParameterBuilderTest.php
@@ -10,6 +10,7 @@
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneRatepayInvoicingPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\ConfigurationHelper;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
@@ -34,8 +35,8 @@ public function testItAddsCorrectPreAuthorizeParameters(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
- 'ratepayBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
diff --git a/tests/Payone/RequestParameter/Builder/Refund/RefundRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/Refund/RefundRequestParameterBuilderTest.php
index 645b36467..52791c067 100644
--- a/tests/Payone/RequestParameter/Builder/Refund/RefundRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/Refund/RefundRequestParameterBuilderTest.php
@@ -14,6 +14,7 @@
use PayonePayment\TestCaseBase\PayoneTestBehavior;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Checkout\Payment\Exception\InvalidOrderException;
+use Shopware\Core\Checkout\Payment\PaymentException;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
/**
@@ -104,7 +105,12 @@ public function testItThrowsExceptionOnMissingTransactionData(): void
$builder = $this->getContainer()->get(RefundRequestParameterBuilder::class);
$struct->getPaymentTransaction()->getOrderTransaction()->removeExtension(PayonePaymentOrderTransactionExtension::NAME);
- $this->expectException(InvalidOrderException::class);
+ if (class_exists(PaymentException::class)) {
+ $this->expectException(PaymentException::class);
+ } else {
+ $this->expectException(InvalidOrderException::class);
+ }
+
$builder->getRequestParameter($struct);
}
@@ -128,7 +134,12 @@ public function testItThrowsExceptionOnMissingTransactionId(): void
]);
$struct->getPaymentTransaction()->getOrderTransaction()->addExtension(PayonePaymentOrderTransactionExtension::NAME, $extension);
- $this->expectException(InvalidOrderException::class);
+ if (class_exists(PaymentException::class)) {
+ $this->expectException(PaymentException::class);
+ } else {
+ $this->expectException(InvalidOrderException::class);
+ }
+
$builder->getRequestParameter($struct);
}
@@ -152,7 +163,12 @@ public function testItThrowsExceptionOnMissingSequenceNumber(): void
]);
$struct->getPaymentTransaction()->getOrderTransaction()->addExtension(PayonePaymentOrderTransactionExtension::NAME, $extension);
- $this->expectException(InvalidOrderException::class);
+ if (class_exists(PaymentException::class)) {
+ $this->expectException(PaymentException::class);
+ } else {
+ $this->expectException(InvalidOrderException::class);
+ }
+
$builder->getRequestParameter($struct);
}
diff --git a/tests/Payone/RequestParameter/Builder/SecuredDirectDebit/AuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/SecuredDirectDebit/AuthorizeRequestParameterBuilderTest.php
index 68fb33bf1..b85bafbe2 100644
--- a/tests/Payone/RequestParameter/Builder/SecuredDirectDebit/AuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/SecuredDirectDebit/AuthorizeRequestParameterBuilderTest.php
@@ -7,10 +7,10 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\DeviceFingerprint\PayoneBNPLDeviceFingerprintService;
use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydrator;
-use PayonePayment\Installer\CustomFieldInstaller;
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneSecuredDirectDebitPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
@@ -31,8 +31,8 @@ public function testItAddsCorrectAuthorizeParameters(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
- 'securedDirectDebitBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
'securedDirectDebitIban' => 'DE85500105173716329595',
]);
@@ -72,7 +72,7 @@ public function testItThrowsExceptionOnMissingPhoneNumber(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'securedDirectDebitBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
'securedDirectDebitIban' => 'DE85500105173716329595',
]);
@@ -98,7 +98,7 @@ public function testItThrowsExceptionOnMissingBirthday(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
+ RequestConstants::PHONE => '0123456789',
'securedDirectDebitIban' => 'DE85500105173716329595',
]);
@@ -116,100 +116,6 @@ public function testItThrowsExceptionOnMissingBirthday(): void
$builder->getRequestParameter($struct);
}
- public function testItAddsCorrectAuthorizeParametersWithSavedPhoneNumber(): void
- {
- $request = $this->getRequestWithSession([
- PayoneBNPLDeviceFingerprintService::SESSION_VAR_NAME => 'the-device-ident-token',
- ]);
- $this->getContainer()->get(RequestStack::class)->push($request);
-
- $dataBag = new RequestDataBag([
- 'securedDirectDebitBirthday' => '2000-01-01',
- 'securedDirectDebitIban' => 'DE85500105173716329595',
- ]);
-
- $struct = $this->getPaymentTransactionStruct(
- $dataBag,
- $this->getValidPaymentHandler(),
- $this->getValidRequestAction()
- );
-
- $builder = $this->getContainer()->get($this->getParameterBuilder());
-
- // Save phone number on customer custom fields
- $this->getContainer()->get('customer.repository')->update([
- [
- 'id' => $struct->getPaymentTransaction()->getOrder()->getOrderCustomer()->getCustomerId(),
- 'customFields' => [
- CustomFieldInstaller::CUSTOMER_PHONE_NUMBER => '0123456789',
- ],
- ],
- ], $struct->getSalesChannelContext()->getContext());
-
- $parameters = $builder->getRequestParameter($struct);
-
- Assert::assertArraySubset(
- [
- 'request' => $this->getValidRequestAction(),
- 'clearingtype' => AbstractRequestParameterBuilder::CLEARING_TYPE_FINANCING,
- 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PDD,
- 'telephonenumber' => '0123456789',
- 'birthday' => '20000101',
- 'bankaccountholder' => 'Max Mustermann',
- 'iban' => 'DE85500105173716329595',
- 'it[1]' => LineItemHydrator::TYPE_GOODS,
- ],
- $parameters
- );
- }
-
- public function testItAddsCorrectAuthorizeParametersWithSavedBirthday(): void
- {
- $request = $this->getRequestWithSession([
- PayoneBNPLDeviceFingerprintService::SESSION_VAR_NAME => 'the-device-ident-token',
- ]);
- $this->getContainer()->get(RequestStack::class)->push($request);
-
- $dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
- 'securedDirectDebitIban' => 'DE85500105173716329595',
- ]);
-
- $struct = $this->getPaymentTransactionStruct(
- $dataBag,
- $this->getValidPaymentHandler(),
- $this->getValidRequestAction()
- );
-
- $builder = $this->getContainer()->get($this->getParameterBuilder());
-
- // Save phone number on customer custom fields
- $this->getContainer()->get('customer.repository')->update([
- [
- 'id' => $struct->getPaymentTransaction()->getOrder()->getOrderCustomer()->getCustomerId(),
- 'customFields' => [
- CustomFieldInstaller::CUSTOMER_BIRTHDAY => '2000-01-01',
- ],
- ],
- ], $struct->getSalesChannelContext()->getContext());
-
- $parameters = $builder->getRequestParameter($struct);
-
- Assert::assertArraySubset(
- [
- 'request' => $this->getValidRequestAction(),
- 'clearingtype' => AbstractRequestParameterBuilder::CLEARING_TYPE_FINANCING,
- 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PDD,
- 'telephonenumber' => '0123456789',
- 'birthday' => '20000101',
- 'bankaccountholder' => 'Max Mustermann',
- 'iban' => 'DE85500105173716329595',
- 'it[1]' => LineItemHydrator::TYPE_GOODS,
- ],
- $parameters
- );
- }
-
protected function getParameterBuilder(): string
{
return AuthorizeRequestParameterBuilder::class;
diff --git a/tests/Payone/RequestParameter/Builder/SecuredDirectDebit/PreAuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/SecuredDirectDebit/PreAuthorizeRequestParameterBuilderTest.php
index 864e204bc..5516724b0 100644
--- a/tests/Payone/RequestParameter/Builder/SecuredDirectDebit/PreAuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/SecuredDirectDebit/PreAuthorizeRequestParameterBuilderTest.php
@@ -10,6 +10,7 @@
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneSecuredDirectDebitPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
@@ -30,8 +31,8 @@ public function testItAddsCorrectPreAuthorizeParameters(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
- 'securedDirectDebitBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
'securedDirectDebitIban' => 'DE85500105173716329595',
]);
diff --git a/tests/Payone/RequestParameter/Builder/SecuredInstallment/AuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/SecuredInstallment/AuthorizeRequestParameterBuilderTest.php
index 77bd77070..644a34a43 100644
--- a/tests/Payone/RequestParameter/Builder/SecuredInstallment/AuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/SecuredInstallment/AuthorizeRequestParameterBuilderTest.php
@@ -7,10 +7,10 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\DeviceFingerprint\PayoneBNPLDeviceFingerprintService;
use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydrator;
-use PayonePayment\Installer\CustomFieldInstaller;
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneSecuredInstallmentPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
@@ -31,8 +31,8 @@ public function testItAddsCorrectAuthorizeParameters(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
- 'securedInstallmentBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
'securedInstallmentIban' => 'DE85500105173716329595',
'securedInstallmentOptionId' => 'the-option-id',
]);
@@ -74,7 +74,7 @@ public function testItThrowsExceptionOnMissingPhoneNumber(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'securedInstallmentBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
'securedInstallmentIban' => 'DE85500105173716329595',
'securedInstallmentOptionId' => 'the-option-id',
]);
@@ -101,7 +101,7 @@ public function testItThrowsExceptionOnMissingBirthday(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
+ RequestConstants::PHONE => '0123456789',
'securedInstallmentIban' => 'DE85500105173716329595',
'securedInstallmentOptionId' => 'the-option-id',
]);
@@ -120,104 +120,6 @@ public function testItThrowsExceptionOnMissingBirthday(): void
$builder->getRequestParameter($struct);
}
- public function testItAddsCorrectAuthorizeParametersWithSavedPhoneNumber(): void
- {
- $request = $this->getRequestWithSession([
- PayoneBNPLDeviceFingerprintService::SESSION_VAR_NAME => 'the-device-ident-token',
- ]);
- $this->getContainer()->get(RequestStack::class)->push($request);
-
- $dataBag = new RequestDataBag([
- 'securedInstallmentBirthday' => '2000-01-01',
- 'securedInstallmentIban' => 'DE85500105173716329595',
- 'securedInstallmentOptionId' => 'the-option-id',
- ]);
-
- $struct = $this->getPaymentTransactionStruct(
- $dataBag,
- $this->getValidPaymentHandler(),
- $this->getValidRequestAction()
- );
-
- $builder = $this->getContainer()->get($this->getParameterBuilder());
-
- // Save phone number on customer custom fields
- $this->getContainer()->get('customer.repository')->update([
- [
- 'id' => $struct->getPaymentTransaction()->getOrder()->getOrderCustomer()->getCustomerId(),
- 'customFields' => [
- CustomFieldInstaller::CUSTOMER_PHONE_NUMBER => '0123456789',
- ],
- ],
- ], $struct->getSalesChannelContext()->getContext());
-
- $parameters = $builder->getRequestParameter($struct);
-
- Assert::assertArraySubset(
- [
- 'request' => $this->getValidRequestAction(),
- 'clearingtype' => AbstractRequestParameterBuilder::CLEARING_TYPE_FINANCING,
- 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PIN,
- 'telephonenumber' => '0123456789',
- 'birthday' => '20000101',
- 'bankaccountholder' => 'Max Mustermann',
- 'iban' => 'DE85500105173716329595',
- 'add_paydata[installment_option_id]' => 'the-option-id',
- 'it[1]' => LineItemHydrator::TYPE_GOODS,
- ],
- $parameters
- );
- }
-
- public function testItAddsCorrectAuthorizeParametersWithSavedBirthday(): void
- {
- $request = $this->getRequestWithSession([
- PayoneBNPLDeviceFingerprintService::SESSION_VAR_NAME => 'the-device-ident-token',
- ]);
- $this->getContainer()->get(RequestStack::class)->push($request);
-
- $dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
- 'securedInstallmentIban' => 'DE85500105173716329595',
- 'securedInstallmentOptionId' => 'the-option-id',
- ]);
-
- $struct = $this->getPaymentTransactionStruct(
- $dataBag,
- $this->getValidPaymentHandler(),
- $this->getValidRequestAction()
- );
-
- $builder = $this->getContainer()->get($this->getParameterBuilder());
-
- // Save phone number on customer custom fields
- $this->getContainer()->get('customer.repository')->update([
- [
- 'id' => $struct->getPaymentTransaction()->getOrder()->getOrderCustomer()->getCustomerId(),
- 'customFields' => [
- CustomFieldInstaller::CUSTOMER_BIRTHDAY => '2000-01-01',
- ],
- ],
- ], $struct->getSalesChannelContext()->getContext());
-
- $parameters = $builder->getRequestParameter($struct);
-
- Assert::assertArraySubset(
- [
- 'request' => $this->getValidRequestAction(),
- 'clearingtype' => AbstractRequestParameterBuilder::CLEARING_TYPE_FINANCING,
- 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PIN,
- 'telephonenumber' => '0123456789',
- 'birthday' => '20000101',
- 'bankaccountholder' => 'Max Mustermann',
- 'iban' => 'DE85500105173716329595',
- 'add_paydata[installment_option_id]' => 'the-option-id',
- 'it[1]' => LineItemHydrator::TYPE_GOODS,
- ],
- $parameters
- );
- }
-
protected function getParameterBuilder(): string
{
return AuthorizeRequestParameterBuilder::class;
diff --git a/tests/Payone/RequestParameter/Builder/SecuredInstallment/InstallmentOptionsRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/SecuredInstallment/InstallmentOptionsRequestParameterBuilderTest.php
index a534d607b..2ecb78f89 100644
--- a/tests/Payone/RequestParameter/Builder/SecuredInstallment/InstallmentOptionsRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/SecuredInstallment/InstallmentOptionsRequestParameterBuilderTest.php
@@ -5,6 +5,7 @@
namespace PayonePayment\Payone\RequestParameter\Builder\SecuredInstallment;
use DMS\PHPUnitExtensions\ArraySubset\Assert;
+use PayonePayment\Constants;
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneSecuredInstallmentPaymentHandler;
use PayonePayment\PaymentHandler\PayoneSecuredInvoicePaymentHandler;
@@ -76,7 +77,7 @@ public function testItAddsTheInstallmentOptionsRequestParameters(): void
'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PIN,
'add_paydata[action]' => 'installment_options',
'add_paydata[businessRelation]' => 'b2c',
- 'amount' => 30000,
+ 'amount' => Constants::DEFAULT_PRODUCT_PRICE * 100,
'currency' => 'EUR',
],
$parameters
@@ -88,7 +89,7 @@ protected function getSecuredInstallmentOptionsStruct(
string $requestAction = AbstractRequestParameterBuilder::REQUEST_ACTION_SECURED_INSTALLMENT_OPTIONS
): SecuredInstallmentOptionsStruct {
$salesChannelContext = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
- $cart = $this->fillCart($salesChannelContext->getToken(), 300);
+ $cart = $this->fillCart($salesChannelContext);
$dataBag = new RequestDataBag([]);
diff --git a/tests/Payone/RequestParameter/Builder/SecuredInstallment/PreAuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/SecuredInstallment/PreAuthorizeRequestParameterBuilderTest.php
index 6dc8d053a..b38af8c06 100644
--- a/tests/Payone/RequestParameter/Builder/SecuredInstallment/PreAuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/SecuredInstallment/PreAuthorizeRequestParameterBuilderTest.php
@@ -10,6 +10,7 @@
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneSecuredInstallmentPaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
@@ -30,8 +31,8 @@ public function testItAddsCorrectPreAuthorizeParameters(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
- 'securedInstallmentBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
'securedInstallmentIban' => 'DE85500105173716329595',
'securedInstallmentOptionId' => 'the-option-id',
]);
diff --git a/tests/Payone/RequestParameter/Builder/SecuredInvoice/AuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/SecuredInvoice/AuthorizeRequestParameterBuilderTest.php
index 063205047..2673eae04 100644
--- a/tests/Payone/RequestParameter/Builder/SecuredInvoice/AuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/SecuredInvoice/AuthorizeRequestParameterBuilderTest.php
@@ -7,10 +7,10 @@
use DMS\PHPUnitExtensions\ArraySubset\Assert;
use PayonePayment\Components\DeviceFingerprint\PayoneBNPLDeviceFingerprintService;
use PayonePayment\Components\Hydrator\LineItemHydrator\LineItemHydrator;
-use PayonePayment\Installer\CustomFieldInstaller;
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneSecuredInvoicePaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
@@ -31,8 +31,8 @@ public function testItAddsCorrectAuthorizeParameters(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
- 'payoneInvoiceBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
@@ -69,7 +69,7 @@ public function testItThrowsExceptionOnMissingPhoneNumber(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payoneInvoiceBirthday' => '2000-01-01',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
@@ -94,7 +94,7 @@ public function testItThrowsExceptionOnMissingBirthday(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
+ RequestConstants::PHONE => '0123456789',
]);
$struct = $this->getPaymentTransactionStruct(
@@ -111,94 +111,6 @@ public function testItThrowsExceptionOnMissingBirthday(): void
$builder->getRequestParameter($struct);
}
- public function testItAddsCorrectAuthorizeParametersWithSavedPhoneNumber(): void
- {
- $request = $this->getRequestWithSession([
- PayoneBNPLDeviceFingerprintService::SESSION_VAR_NAME => 'the-device-ident-token',
- ]);
- $this->getContainer()->get(RequestStack::class)->push($request);
-
- $dataBag = new RequestDataBag([
- 'payoneInvoiceBirthday' => '2000-01-01',
- ]);
-
- $struct = $this->getPaymentTransactionStruct(
- $dataBag,
- $this->getValidPaymentHandler(),
- $this->getValidRequestAction()
- );
-
- $builder = $this->getContainer()->get($this->getParameterBuilder());
-
- // Save phone number on customer custom fields
- $this->getContainer()->get('customer.repository')->update([
- [
- 'id' => $struct->getPaymentTransaction()->getOrder()->getOrderCustomer()->getCustomerId(),
- 'customFields' => [
- CustomFieldInstaller::CUSTOMER_PHONE_NUMBER => '0123456789',
- ],
- ],
- ], $struct->getSalesChannelContext()->getContext());
-
- $parameters = $builder->getRequestParameter($struct);
-
- Assert::assertArraySubset(
- [
- 'request' => $this->getValidRequestAction(),
- 'clearingtype' => AbstractRequestParameterBuilder::CLEARING_TYPE_FINANCING,
- 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PIV,
- 'telephonenumber' => '0123456789',
- 'birthday' => '20000101',
- 'it[1]' => LineItemHydrator::TYPE_GOODS,
- ],
- $parameters
- );
- }
-
- public function testItAddsCorrectAuthorizeParametersWithSavedBirthday(): void
- {
- $request = $this->getRequestWithSession([
- PayoneBNPLDeviceFingerprintService::SESSION_VAR_NAME => 'the-device-ident-token',
- ]);
- $this->getContainer()->get(RequestStack::class)->push($request);
-
- $dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
- ]);
-
- $struct = $this->getPaymentTransactionStruct(
- $dataBag,
- $this->getValidPaymentHandler(),
- $this->getValidRequestAction()
- );
-
- $builder = $this->getContainer()->get($this->getParameterBuilder());
-
- // Save phone number on customer custom fields
- $this->getContainer()->get('customer.repository')->update([
- [
- 'id' => $struct->getPaymentTransaction()->getOrder()->getOrderCustomer()->getCustomerId(),
- 'customFields' => [
- CustomFieldInstaller::CUSTOMER_BIRTHDAY => '2000-01-01',
- ],
- ],
- ], $struct->getSalesChannelContext()->getContext());
-
- $parameters = $builder->getRequestParameter($struct);
-
- Assert::assertArraySubset(
- [
- 'request' => $this->getValidRequestAction(),
- 'clearingtype' => AbstractRequestParameterBuilder::CLEARING_TYPE_FINANCING,
- 'financingtype' => AbstractPayonePaymentHandler::PAYONE_FINANCING_PIV,
- 'telephonenumber' => '0123456789',
- 'birthday' => '20000101',
- 'it[1]' => LineItemHydrator::TYPE_GOODS,
- ],
- $parameters
- );
- }
-
public function testItAddsCorrectAuthorizeParametersForB2b(): void
{
$request = $this->getRequestWithSession([
@@ -207,8 +119,8 @@ public function testItAddsCorrectAuthorizeParametersForB2b(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
- 'payoneInvoiceBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
diff --git a/tests/Payone/RequestParameter/Builder/SecuredInvoice/PreAuthorizeRequestParameterBuilderTest.php b/tests/Payone/RequestParameter/Builder/SecuredInvoice/PreAuthorizeRequestParameterBuilderTest.php
index 7a3e4d3bc..6b335ebe5 100644
--- a/tests/Payone/RequestParameter/Builder/SecuredInvoice/PreAuthorizeRequestParameterBuilderTest.php
+++ b/tests/Payone/RequestParameter/Builder/SecuredInvoice/PreAuthorizeRequestParameterBuilderTest.php
@@ -10,6 +10,7 @@
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\PaymentHandler\PayoneSecuredInvoicePaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use PayonePayment\RequestConstants;
use PayonePayment\TestCaseBase\PaymentTransactionParameterBuilderTestTrait;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
@@ -30,8 +31,8 @@ public function testItAddsCorrectPreAuthorizeParameters(): void
$this->getContainer()->get(RequestStack::class)->push($request);
$dataBag = new RequestDataBag([
- 'payonePhone' => '0123456789',
- 'payoneInvoiceBirthday' => '2000-01-01',
+ RequestConstants::PHONE => '0123456789',
+ RequestConstants::BIRTHDAY => '2000-01-01',
]);
$struct = $this->getPaymentTransactionStruct(
diff --git a/tests/Payone/Webhook/Processor/WebhookProcessorTest.php b/tests/Payone/Webhook/Processor/WebhookProcessorTest.php
index 6deb8f5a0..7eb1a39d0 100644
--- a/tests/Payone/Webhook/Processor/WebhookProcessorTest.php
+++ b/tests/Payone/Webhook/Processor/WebhookProcessorTest.php
@@ -15,16 +15,17 @@
use PayonePayment\Struct\PaymentTransaction;
use PayonePayment\TestCaseBase\Factory\TransactionStatusWebhookHandlerFactory;
use PayonePayment\TestCaseBase\Mock\ConfigReaderMock;
+use PayonePayment\TestCaseBase\PayoneTestBehavior;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionDefinition;
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity;
use Shopware\Core\Checkout\Order\OrderEntity;
use Shopware\Core\Checkout\Payment\PaymentMethodEntity;
-use Shopware\Core\Checkout\Test\Cart\Common\Generator;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\Pricing\CashRoundingConfig;
use Shopware\Core\System\Currency\CurrencyEntity;
+use Shopware\Core\System\StateMachine\Aggregation\StateMachineState\StateMachineStateCollection;
use Shopware\Core\System\StateMachine\Aggregation\StateMachineState\StateMachineStateEntity;
use Shopware\Core\System\StateMachine\Aggregation\StateMachineTransition\StateMachineTransitionActions;
use Shopware\Core\System\StateMachine\StateMachineRegistry;
@@ -37,11 +38,11 @@
*/
class WebhookProcessorTest extends TestCase
{
+ use PayoneTestBehavior;
+
public function testItAppointsCreditCard(): void
{
- $context = Context::createDefaultContext();
- $salesChannelContext = Generator::createSalesChannelContext($context);
- $salesChannelContext->getSalesChannel()->setId(TestDefaults::SALES_CHANNEL);
+ $salesChannelContext = $this->createSalesChannelContext();
$request = new Request();
$request->request->set('key', md5(''));
@@ -60,8 +61,7 @@ public function testItAppointsCreditCard(): void
public function testItPartialCapturesCreditCard(): void
{
- $context = Context::createDefaultContext();
- $salesChannelContext = Generator::createSalesChannelContext($context);
+ $salesChannelContext = $this->createSalesChannelContext();
$salesChannelContext->getSalesChannel()->setId(TestDefaults::SALES_CHANNEL);
$request = new Request();
@@ -82,8 +82,7 @@ public function testItPartialCapturesCreditCard(): void
public function testItFullCapturesCreditCard(): void
{
- $context = Context::createDefaultContext();
- $salesChannelContext = Generator::createSalesChannelContext($context);
+ $salesChannelContext = $this->createSalesChannelContext();
$salesChannelContext->getSalesChannel()->setId(TestDefaults::SALES_CHANNEL);
$request = new Request();
@@ -105,8 +104,7 @@ public function testItFullCapturesCreditCard(): void
public function testItProcessesPaidCreditCard(): void
{
- $context = Context::createDefaultContext();
- $salesChannelContext = Generator::createSalesChannelContext($context);
+ $salesChannelContext = $this->createSalesChannelContext();
$salesChannelContext->getSalesChannel()->setId(TestDefaults::SALES_CHANNEL);
$request = new Request();
@@ -124,22 +122,19 @@ public function testItProcessesPaidCreditCard(): void
static::assertSame(WebhookHandlerInterface::RESPONSE_TSOK, $response->getContent());
}
- protected function getWebhookProcessor(string $transition, array $transactionData): WebhookProcessorInterface
+ protected function getWebhookProcessor(string $transitionName, array $transactionData): WebhookProcessorInterface
{
- $context = Context::createDefaultContext();
- $salesChannelContext = Generator::createSalesChannelContext($context);
+ $salesChannelContext = $this->createSalesChannelContext();
$salesChannelContext->getSalesChannel()->setId(TestDefaults::SALES_CHANNEL);
$stateMachineRegistry = $this->createMock(StateMachineRegistry::class);
- $stateMachineRegistry->expects(static::once())->method('transition')->with(
- new Transition(
- OrderTransactionDefinition::ENTITY_NAME,
- Constants::ORDER_TRANSACTION_ID,
- $transition,
- 'stateId'
- ),
- $context
- );
+ $stateMachineRegistry->expects(static::once())->method('transition')->willReturnCallback(static function (Transition $transition, Context $context) use ($transitionName) {
+ static::assertEquals(OrderTransactionDefinition::ENTITY_NAME, $transition->getEntityName());
+ static::assertEquals($transitionName, $transition->getTransitionName());
+ static::assertEquals('stateId', $transition->getStateFieldName());
+
+ return new StateMachineStateCollection();
+ });
$currency = new CurrencyEntity();
$currency->setId(Constants::CURRENCY_ID);
diff --git a/tests/TestCaseBase/Mock/PaymentHandler/PaymentHandlerMock.php b/tests/TestCaseBase/Mock/PaymentHandler/PaymentHandlerMock.php
index d8d75bba9..c821a389c 100644
--- a/tests/TestCaseBase/Mock/PaymentHandler/PaymentHandlerMock.php
+++ b/tests/TestCaseBase/Mock/PaymentHandler/PaymentHandlerMock.php
@@ -6,6 +6,8 @@
use PayonePayment\PaymentHandler\AbstractPayonePaymentHandler;
use PayonePayment\Payone\RequestParameter\Builder\AbstractRequestParameterBuilder;
+use Shopware\Core\Checkout\Payment\Exception\SyncPaymentProcessException;
+use Shopware\Core\Checkout\Payment\PaymentException;
class PaymentHandlerMock extends AbstractPayonePaymentHandler
{
@@ -23,4 +25,17 @@ protected function getDefaultAuthorizationMethod(): string
{
return AbstractRequestParameterBuilder::REQUEST_ACTION_AUTHORIZE;
}
+
+ protected function createPaymentException(string $orderTransactionId, string $errorMessage, ?\Throwable $e): \Throwable
+ {
+ if (class_exists(PaymentException::class)) {
+ return PaymentException::asyncProcessInterrupted($orderTransactionId, $errorMessage, $e);
+ } elseif (class_exists(SyncPaymentProcessException::class)) {
+ // required for shopware version <= 6.5.3
+ throw new SyncPaymentProcessException($orderTransactionId, $errorMessage, $e); // @phpstan-ignore-line
+ }
+
+ // should never occur, just to be safe.
+ throw new \RuntimeException('payment process was interrupted ' . $orderTransactionId);
+ }
}
diff --git a/tests/TestCaseBase/PayoneTestBehavior.php b/tests/TestCaseBase/PayoneTestBehavior.php
index f551e0435..e055bca54 100644
--- a/tests/TestCaseBase/PayoneTestBehavior.php
+++ b/tests/TestCaseBase/PayoneTestBehavior.php
@@ -31,9 +31,7 @@
use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity;
use Shopware\Core\Checkout\Order\OrderEntity;
use Shopware\Core\Checkout\Payment\PaymentMethodEntity;
-use Shopware\Core\Content\Product\Aggregate\ProductVisibility\ProductVisibilityDefinition;
use Shopware\Core\Defaults;
-use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Test\TestCaseBase\IntegrationTestBehaviour;
use Shopware\Core\Framework\Test\TestCaseBase\SessionTestBehaviour;
use Shopware\Core\Framework\Uuid\Uuid;
@@ -55,11 +53,14 @@ trait PayoneTestBehavior
/**
* @deprecated use `createCartWithProduct`
*/
- protected function fillCart(string $contextToken, float $totalPrice): Cart
+ protected function fillCart(SalesChannelContext $context, ?float $totalPrice = Constants::DEFAULT_PRODUCT_PRICE): Cart
{
- $cart = static::getContainer()->get(CartService::class)->createNew($contextToken);
+ $cart = static::getContainer()->get(CartService::class)->createNew($context->getToken());
+
+ $productId = $this->getRandomProduct($context, 1, false, $totalPrice ? [
+ 'price' => [['currencyId' => Defaults::CURRENCY, 'gross' => $totalPrice, 'net' => $totalPrice / 1.19, 'linked' => false]],
+ ] : [])->getId();
- $productId = $this->createProduct($totalPrice);
$cart->add(new LineItem('lineItem1', LineItem::PRODUCT_LINE_ITEM_TYPE, $productId));
$cart->setPrice($this->createPrice($totalPrice));
@@ -70,14 +71,16 @@ protected function fillCart(string $contextToken, float $totalPrice): Cart
/**
* creates a cart with calculated sums
*/
- protected function createCartWithProduct(SalesChannelContext $context, float $itemPrice, int $qty): Cart
+ protected function createCartWithProduct(SalesChannelContext $context, float $itemPrice = Constants::DEFAULT_PRODUCT_PRICE, int $qty = 1): Cart
{
$cartService = static::getContainer()->get(CartService::class);
$cartItemCalculator = static::getContainer()->get(Calculator::class);
$cart = $cartService->createNew($context->getToken());
- $productId = $this->createProduct($itemPrice);
+ $productId = $this->getRandomProduct($context, $qty, false, [
+ 'price' => [['currencyId' => Defaults::CURRENCY, 'gross' => $itemPrice, 'net' => $itemPrice / 1.19, 'linked' => false]],
+ ])->getId();
$lineItem = (new LineItem('lineItem1', LineItem::PRODUCT_LINE_ITEM_TYPE, $productId, $qty))
->setPriceDefinition(new QuantityPriceDefinition($itemPrice, new TaxRuleCollection([]), $qty))
@@ -92,37 +95,6 @@ protected function createCartWithProduct(SalesChannelContext $context, float $it
return $cart;
}
- protected function createProduct(float $price): string
- {
- $productId = Uuid::randomHex();
-
- $product = [
- 'id' => $productId,
- 'name' => 'Test product',
- 'productNumber' => '123456789',
- 'stock' => 1,
- 'price' => [
- ['currencyId' => Defaults::CURRENCY, 'gross' => $price, 'net' => $price, 'linked' => false],
- ],
- 'manufacturer' => ['id' => $productId, 'name' => 'shopware AG'],
- 'tax' => ['id' => $productId, 'name' => 'testTaxRate', 'taxRate' => 0],
- 'categories' => [
- ['id' => $productId, 'name' => 'Test category'],
- ],
- 'visibilities' => [
- [
- 'id' => $productId,
- 'salesChannelId' => TestDefaults::SALES_CHANNEL,
- 'visibility' => ProductVisibilityDefinition::VISIBILITY_ALL,
- ],
- ],
- ];
-
- static::getContainer()->get('product.repository')->create([$product], Context::createDefaultContext());
-
- return $productId;
- }
-
protected function createPrice(float $price): CartPrice
{
return new CartPrice(
@@ -284,6 +256,7 @@ protected function getPageLoader(): CheckoutConfirmPageLoader
protected function getRequestWithSession(array $sessionVariables): Request
{
$session = $this->getSession();
+ $session->clear(); // make sure that session is empty
foreach ($sessionVariables as $key => $value) {
$session->set($key, $value);
diff --git a/tests/TestCaseBase/StorefrontPageTestBehaviour.php b/tests/TestCaseBase/StorefrontPageTestBehaviour.php
index 046b005a8..fed7a0c5b 100644
--- a/tests/TestCaseBase/StorefrontPageTestBehaviour.php
+++ b/tests/TestCaseBase/StorefrontPageTestBehaviour.php
@@ -4,6 +4,7 @@
namespace PayonePayment\TestCaseBase;
+use PayonePayment\Constants;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Checkout\Cart\CartRuleLoader;
use Shopware\Core\Checkout\Cart\LineItem\LineItem;
@@ -14,7 +15,9 @@
use Shopware\Core\Defaults;
use Shopware\Core\Framework\Api\Util\AccessKeyHelper;
use Shopware\Core\Framework\Context;
+use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
+use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Routing\RoutingException;
use Shopware\Core\Framework\Struct\Struct;
use Shopware\Core\Framework\Test\TestCaseBase\TaxAddToSalesChannelTestBehaviour;
@@ -24,6 +27,7 @@
use Shopware\Core\System\SalesChannel\Context\SalesChannelContextService;
use Shopware\Core\System\SalesChannel\Entity\SalesChannelRepository;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
+use Shopware\Core\System\SalesChannel\SalesChannelEntity;
use Shopware\Core\Test\TestDefaults;
use Shopware\Storefront\Page\PageLoadedEvent;
use Shopware\Storefront\Pagelet\PageletLoadedEvent;
@@ -99,23 +103,30 @@ protected function placeRandomOrder(SalesChannelContext $context): string
*/
protected function getRandomProduct(SalesChannelContext $context, ?int $stock = 1, ?bool $isCloseout = false, array $config = []): ProductEntity
{
- $id = Uuid::randomHex();
- $productNumber = Uuid::randomHex();
+ $productNumber = 'phpunit-' . md5(json_encode([$stock, $isCloseout, $config]));
+
$productRepository = $this->getContainer()->get('product.repository');
+ $criteria = new Criteria();
+ $criteria->addFilter(new EqualsFilter('productNumber', $productNumber));
+ $criteria->setLimit(1);
+ $product = $productRepository->search($criteria, $context->getContext())->first();
+
+ if ($product instanceof ProductEntity) {
+ return $product;
+ }
+
+ $id = Uuid::randomHex();
+ $itemPrice = Constants::DEFAULT_PRODUCT_PRICE;
$data = [
'id' => $id,
'productNumber' => $productNumber,
'stock' => $stock,
'name' => StorefrontPageTestConstants::PRODUCT_NAME,
- 'price' => [['currencyId' => Defaults::CURRENCY, 'gross' => 15, 'net' => 10, 'linked' => false]],
- 'manufacturer' => ['name' => 'test'],
- 'tax' => ['id' => Uuid::randomHex(), 'name' => 'test', 'taxRate' => 15],
+ 'price' => [['currencyId' => Defaults::CURRENCY, 'gross' => $itemPrice, 'net' => $itemPrice / 1.19, 'linked' => false]],
+ 'tax' => ['id' => '2abf31f1c4d94effb0e42c9bdcab0dd0', 'name' => 'test', 'taxRate' => 19],
'active' => true,
'isCloseout' => $isCloseout,
- 'categories' => [
- ['id' => Uuid::randomHex(), 'name' => 'asd'],
- ],
'visibilities' => [
['salesChannelId' => $context->getSalesChannel()->getId(), 'visibility' => ProductVisibilityDefinition::VISIBILITY_ALL],
],
@@ -143,6 +154,7 @@ protected function createSalesChannelContextWithNavigation(): SalesChannelContex
$countryId = $this->getValidCountryId();
$snippetSetId = $this->getSnippetSetIdForLocale('en-GB');
$data = [
+ 'id' => 'd70c06716f8848b685f8faa7ff1bbeae',
'typeId' => Defaults::SALES_CHANNEL_TYPE_STOREFRONT,
'name' => 'store front',
'accessKey' => AccessKeyHelper::generateAccessKey('sales-channel'),
@@ -178,6 +190,7 @@ protected function createSalesChannelContextWithLoggedInCustomerAndWithNavigatio
$countryId = $this->getValidCountryId();
$snippetSetId = $this->getSnippetSetIdForLocale('en-GB');
$data = [
+ 'id' => '5339bf0dc99f4579a69119a021453085',
'typeId' => Defaults::SALES_CHANNEL_TYPE_STOREFRONT,
'name' => 'store front',
'accessKey' => AccessKeyHelper::generateAccessKey('sales-channel'),
@@ -207,16 +220,14 @@ protected function createSalesChannelContextWithLoggedInCustomerAndWithNavigatio
]);
}
- /**
- * @param array|null $salesChannelData
- */
- protected function createSalesChannelContext(?array $salesChannelData = null): SalesChannelContext
+ protected function createSalesChannelContext(): SalesChannelContext
{
$paymentMethodId = $this->getValidPaymentMethodId();
$shippingMethodId = $this->getAvailableShippingMethod()->getId();
$countryId = $this->getValidCountryId();
$snippetSetId = $this->getSnippetSetIdForLocale('en-GB');
$data = [
+ 'id' => '626f01c28ba640bfb49c42ff41762e57',
'typeId' => Defaults::SALES_CHANNEL_TYPE_STOREFRONT,
'name' => 'store front',
'accessKey' => AccessKeyHelper::generateAccessKey('sales-channel'),
@@ -242,10 +253,6 @@ protected function createSalesChannelContext(?array $salesChannelData = null): S
],
];
- if ($salesChannelData) {
- $data = array_merge($data, $salesChannelData);
- }
-
return $this->createContext($data, []);
}
@@ -260,12 +267,37 @@ abstract protected static function getContainer(): ContainerInterface;
private function createCustomer(): CustomerEntity
{
- $customerId = Uuid::randomHex();
- $addressId = Uuid::randomHex();
+ $context = Context::createDefaultContext();
+ $addressId = '43419bb9d20d436ab096a902c5452544';
+
+ /** @var EntityRepository $customerRepo */
+ $customerRepo = $this->getContainer()->get('customer.repository');
+
+ $criteria = new Criteria([Constants::CUSTOMER_ID]);
+ $criteria->addAssociation('defaultBillingAddress');
+ $customer = $customerRepo->search($criteria, $context)->first();
+
+ if ($customer instanceof CustomerEntity) {
+ // make sure that phoneNumber is not set (which may have been happened through other tests.
+ if ($customer->getDefaultBillingAddress()->getPhoneNumber()) {
+ /** @var EntityRepository $addressRepo */
+ $addressRepo = $this->getContainer()->get('customer_address.repository');
+ $addressRepo->upsert([['id' => $customer->getDefaultBillingAddressId(), 'phoneNumber' => null]], $context);
+ $customer->getDefaultBillingAddress()->assign(['phoneNumber' => null]);
+ }
+
+ // make sure that birthday is not set (which may have been happened through other tests.
+ if ($customer->getBirthday()) {
+ $customerRepo->upsert([['id' => $customer->getId(), 'birthday' => null]], $context);
+ $customer->assign(['birthday' => null]);
+ }
+
+ return $customer;
+ }
$data = [
[
- 'id' => $customerId,
+ 'id' => Constants::CUSTOMER_ID,
'salesChannelId' => TestDefaults::SALES_CHANNEL,
'defaultShippingAddress' => [
'id' => $addressId,
@@ -289,13 +321,10 @@ private function createCustomer(): CustomerEntity
],
];
- $repo = $this->getContainer()->get('customer.repository');
-
- $repo->create($data, Context::createDefaultContext());
+ $customerRepo->create($data, $context);
- $result = $repo->search(new Criteria([$customerId]), Context::createDefaultContext());
/** @var CustomerEntity $customer */
- $customer = $result->first();
+ $customer = $customerRepo->search(new Criteria([Constants::CUSTOMER_ID]), Context::createDefaultContext())->first();
return $customer;
}
@@ -307,13 +336,22 @@ private function createCustomer(): CustomerEntity
private function createContext(array $salesChannel, array $options): SalesChannelContext
{
$factory = $this->getContainer()->get(SalesChannelContextFactory::class);
+ /** @var EntityRepository $salesChannelRepository */
$salesChannelRepository = $this->getContainer()->get('sales_channel.repository');
- $salesChannelId = Uuid::randomHex();
- $salesChannel['id'] = $salesChannelId;
- $salesChannel['customerGroupId'] = TestDefaults::FALLBACK_CUSTOMER_GROUP;
+ $salesChannelEntity = null;
+ if (isset($salesChannel['id'])) {
+ $salesChannelEntity = $salesChannelRepository->search(new Criteria([$salesChannel['id']]), Context::createDefaultContext())->first();
+ }
+
+ $salesChannelId = $salesChannel['id'] ?? Uuid::randomHex();
- $salesChannelRepository->create([$salesChannel], Context::createDefaultContext());
+ if (!$salesChannelEntity instanceof SalesChannelEntity) {
+ $salesChannel['id'] = $salesChannelId;
+ $salesChannel['customerGroupId'] = TestDefaults::FALLBACK_CUSTOMER_GROUP;
+
+ $salesChannelRepository->create([$salesChannel], Context::createDefaultContext());
+ }
$context = $factory->create(Uuid::randomHex(), $salesChannelId, $options);
diff --git a/tests/cypress/.eslintrc.js b/tests/cypress/.eslintrc.js
deleted file mode 100644
index e3c30b61a..000000000
--- a/tests/cypress/.eslintrc.js
+++ /dev/null
@@ -1,15 +0,0 @@
-module.exports = {
- 'extends': 'standard',
- 'root': true,
- 'globals': {
- 'Cypress': true,
- 'cy': true
- },
- 'rules': {
- 'indent': [
- 'error',
- 4,
- {'SwitchCase': 1}
- ],
- }
-};
diff --git a/tests/cypress/commands/buy_demo_article.js b/tests/cypress/commands/buy_demo_article.js
deleted file mode 100644
index 9e56c0beb..000000000
--- a/tests/cypress/commands/buy_demo_article.js
+++ /dev/null
@@ -1,19 +0,0 @@
-Cypress.Commands.add('buyDemoArticle', () => {
- cy.server();
- cy.route({
- method: 'POST',
- url: '*checkout/line-item/add*'
- }).as('addProduct');
- cy.route({
- method: 'GET',
- url: '*widgets/checkout/info*'
- }).as('ajaxCart');
-
- cy.visit('/');
- cy.contains('Add to shopping cart').first().click();
- cy.wait('@addProduct');
- cy.wait('@ajaxCart');
- cy.get('.cart-item-quantity-container > .custom-select').select('3').should('have.value', '3');
- cy.wait('@ajaxCart');
- cy.contains('Proceed to checkout').click();
-})
diff --git a/tests/cypress/commands/checkout_buy.js b/tests/cypress/commands/checkout_buy.js
deleted file mode 100644
index 4eb95178f..000000000
--- a/tests/cypress/commands/checkout_buy.js
+++ /dev/null
@@ -1,6 +0,0 @@
-Cypress.Commands.add('checkoutBuy', () => {
- cy.get('#sAGB').check()
- cy.get('.main--actions button').click()
- cy.wait(5000)
- cy.url().should('include', 'checkout/finish')
-})
diff --git a/tests/cypress/commands/finish_checkout.js b/tests/cypress/commands/finish_checkout.js
deleted file mode 100644
index 76ad3c0f8..000000000
--- a/tests/cypress/commands/finish_checkout.js
+++ /dev/null
@@ -1,5 +0,0 @@
-Cypress.Commands.add('finishCheckout', () => {
- cy.get('#tos').check({force: true});
- cy.get('#confirmFormSubmit').click({force: true});
- cy.url().should('include', 'checkout/finish')
-})
diff --git a/tests/cypress/commands/login.js b/tests/cypress/commands/login.js
deleted file mode 100644
index ed1863eb6..000000000
--- a/tests/cypress/commands/login.js
+++ /dev/null
@@ -1,7 +0,0 @@
-Cypress.Commands.add('login', () => {
- cy.url().should('include', 'checkout/register');
- cy.get('.register-login-collapse-toogle').click();
- cy.get('#loginMail').type('demo@payone.demo');
- cy.get('#loginPassword').type('demo@payone.demo');
- cy.get('.login-submit button').should('contain.text', 'Login').click();
-})
diff --git a/tests/cypress/commands/register.js b/tests/cypress/commands/register.js
deleted file mode 100644
index 9c2c3fb80..000000000
--- a/tests/cypress/commands/register.js
+++ /dev/null
@@ -1,17 +0,0 @@
-Cypress.Commands.add('register', () => {
- cy.url().should('include', 'checkout/register')
- cy.get('#personalSalutation').select('Mr.').should('contain.text', 'Mr.');
-
- cy.get('#personalFirstName').type('Payone');
- cy.get('#personalLastName').type('Testkäufer');
-
- cy.get('#personalMail').type('demo@payone.demo');
- cy.get('#personalGuest').check({force: true});
-
- cy.get('#billingAddressAddressStreet').type('Demostreet 12');
- cy.get('#billingAddressAddressZipcode').type('12345');
- cy.get('#billingAddressAddressCity').type('Democity');
-
- cy.get('#billingAddressAddressCountry').select('Germany').should('contain.text', 'Germany');
- cy.get('.register-submit > button').click();
-})
diff --git a/tests/cypress/commands/select_payment_method.js b/tests/cypress/commands/select_payment_method.js
deleted file mode 100644
index d12fa3659..000000000
--- a/tests/cypress/commands/select_payment_method.js
+++ /dev/null
@@ -1,7 +0,0 @@
-Cypress.Commands.add('selectPaymentMethod', (name) => {
- cy.url().should('include', '/checkout/confirm')
- cy.get('*[data-target="#confirmPaymentModal"]').should('contain.text','Change payment').click();
- cy.wait(5000);
- cy.contains(name).click({force: true})
- cy.get('#confirmPaymentForm *[type="submit"]').should('contain.text', 'Save').click()
-})
diff --git a/tests/cypress/integration/payment/credit_card.js b/tests/cypress/integration/payment/credit_card.js
deleted file mode 100644
index b5d288f4c..000000000
--- a/tests/cypress/integration/payment/credit_card.js
+++ /dev/null
@@ -1,16 +0,0 @@
-describe('CreditCard Test', function () {
- it('Buy with CreditCard', function () {
- const findInIframe = (selector) => ($iframe) => $iframe.contents().find(selector)
-
- cy.buyDemoArticle()
- cy.register()
- cy.selectPaymentMethod('Credit Card')
-
- cy.get('#cardpan > iframe').pipe(findInIframe('input')).type('4111111111111111', {force: true});
- cy.get('#cardcvc2 > iframe').pipe(findInIframe('input')).type('123', {force: true});
- cy.get('#cardexpiremonth > iframe').pipe(findInIframe('select')).select('10', {force: true});
- cy.get('#cardexpireyear > iframe').pipe(findInIframe('select')).select('2022', {force: true});
-
- cy.finishCheckout()
- })
-})
diff --git a/tests/cypress/integration/payment/debit.js b/tests/cypress/integration/payment/debit.js
deleted file mode 100644
index bdbb8e528..000000000
--- a/tests/cypress/integration/payment/debit.js
+++ /dev/null
@@ -1,29 +0,0 @@
-describe('SEPA Lastschrift Test', function () {
- it('Buy with SEPA Lastschrift', function () {
- cy.server();
- cy.route({
- method: 'POST',
- url: '*payone/debit/manage-mandate*'
- }).as('manageMandate');
-
- cy.buyDemoArticle()
- cy.register()
- cy.selectPaymentMethod('Payone SEPA')
-
- cy.get('#accountOwner').type('Payone Testkäufer');
- cy.get('#iban').type('DE00123456782599100010');
- cy.get('#bic').type('TESTTEST');
-
- cy.get('#tos').check({force: true});
- cy.get('#confirmFormSubmit').click({force: true});
-
- cy.wait('@manageMandate').then((xhr) => {
- cy.wait(5000);
- if(undefined !== xhr.responseBody.modal_content) {
- cy.get('#accept-mandate').check({force: true});
- cy.get('#mandateSubmit').click();
- }
- cy.url().should('include', 'checkout/finish')
- });
- })
-})
diff --git a/tests/cypress/integration/payment/payolution_debit.js b/tests/cypress/integration/payment/payolution_debit.js
deleted file mode 100644
index 0c5b46068..000000000
--- a/tests/cypress/integration/payment/payolution_debit.js
+++ /dev/null
@@ -1,16 +0,0 @@
-describe('Pay Later Debit Test', function () {
- it('Buy with Pay Later Debit', function () {
- cy.buyDemoArticle();
- cy.register();
- cy.selectPaymentMethod('Pay Later Debit');
-
- cy.get('#payolutionAccountHolder').type('Payone Testkäufer');
- cy.get('#payolutionIban').type('DE00123456782599100010');
- cy.get('#payolutionBic').type('TESTTEST');
- cy.get('#payolutionBirthday').type('1990-01-01');
- cy.get('#payolutionConsent').check({force: true});
- cy.get('#payolutionMandate').check({force: true});
-
- cy.finishCheckout()
- })
-})
diff --git a/tests/cypress/integration/payment/payolution_installment.js b/tests/cypress/integration/payment/payolution_installment.js
deleted file mode 100644
index b33c8b66e..000000000
--- a/tests/cypress/integration/payment/payolution_installment.js
+++ /dev/null
@@ -1,23 +0,0 @@
-describe('Payolution installment Test', function () {
- it('Buy with Pay Later Installment', function () {
- cy.server();
- cy.route({
- method: 'POST',
- url: '*payone/installment/calculation*'
- }).as('installmentCalculation');
-
- cy.buyDemoArticle();
- cy.register();
- cy.selectPaymentMethod('Pay Later Installment');
-
- cy.get('#payolutionBirthday').type('1990-01-01');
- cy.get('#payolutionConsent').check({force: true});
- cy.get('#checkInstallmentButton').click();
- cy.wait('@installmentCalculation');
- cy.get('#payolutionAccountOwner').type('Payone Testkäufer');
- cy.get('#payolutionIban').type('DE00123456782599100012');
- cy.get('#payolutionBic').type('TESTTEST');
-
- cy.finishCheckout()
- })
-})
diff --git a/tests/cypress/integration/payment/payolution_invoice.js b/tests/cypress/integration/payment/payolution_invoice.js
deleted file mode 100644
index b32e12326..000000000
--- a/tests/cypress/integration/payment/payolution_invoice.js
+++ /dev/null
@@ -1,17 +0,0 @@
-describe('Pay Later Invoice Test', function () {
- it('Buy with Pay Later Invoice', function () {
- cy.server();
- cy.route({
- method: 'POST',
- url: '*payone/debit/manage-mandate*'
- }).as('calculateInvoice');
- cy.buyDemoArticle();
- cy.register();
- cy.selectPaymentMethod('Pay Later Invoice');
-
- cy.get('#payolutionBirthday').type('1990-01-01');
- cy.get('#payolutionConsent').check({force: true});
-
- cy.finishCheckout()
- })
-})
diff --git a/tests/cypress/integration/payment/paypal.js b/tests/cypress/integration/payment/paypal.js
deleted file mode 100644
index 7ae8f3f89..000000000
--- a/tests/cypress/integration/payment/paypal.js
+++ /dev/null
@@ -1,12 +0,0 @@
-describe('PayPal Test', function () {
- it('Buy with PayPal', function () {
- cy.buyDemoArticle();
- cy.register();
- cy.selectPaymentMethod('Payone PayPal');
-
- cy.get('#tos').check({force: true});
- cy.get('#confirmFormSubmit').click({force: true});
-
- cy.url().should('include', 'paypal.com');
- })
-})
diff --git a/tests/cypress/integration/payment/paypal_express.js b/tests/cypress/integration/payment/paypal_express.js
deleted file mode 100644
index f6a61aa51..000000000
--- a/tests/cypress/integration/payment/paypal_express.js
+++ /dev/null
@@ -1,7 +0,0 @@
-describe('PayPal Express Test', function () {
- it('Buy with PayPal Express', function () {
- cy.buyDemoArticle();
- cy.get('a[title="PayPal Express"]').click({force: true});
- cy.url().should('include', 'paypal.com');
- })
-})
diff --git a/tests/cypress/integration/payment/sofort.js b/tests/cypress/integration/payment/sofort.js
deleted file mode 100644
index dceb797b4..000000000
--- a/tests/cypress/integration/payment/sofort.js
+++ /dev/null
@@ -1,13 +0,0 @@
-describe('Sofort Test', function () {
- it('Buy with Sofort', function () {
- cy.buyDemoArticle();
- cy.register();
- cy.selectPaymentMethod('PAYONE Sofort');
-
- cy.get('#tos').check({force: true});
- cy.get('#confirmFormSubmit').click({force: true});
-
- // Needs some cookies
- // cy.url().should('include', 'www.sofort.com/payment');
- })
-})
diff --git a/tests/cypress/main.js b/tests/cypress/main.js
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tests/cypress/plugins/index.js b/tests/cypress/plugins/index.js
deleted file mode 100644
index 6d7d44d5f..000000000
--- a/tests/cypress/plugins/index.js
+++ /dev/null
@@ -1,21 +0,0 @@
-///
-// ***********************************************************
-// This example plugins/index.js can be used to load plugins
-//
-// You can change the location of this file or turn off loading
-// the plugins file with the 'pluginsFile' configuration option.
-//
-// You can read more here:
-// https://on.cypress.io/plugins-guide
-// ***********************************************************
-
-// This function is called when a project is opened or re-opened (e.g. due to
-// the project's config changing)
-
-/**
- * @type {Cypress.PluginConfig}
- */
-module.exports = (on, config) => {
- // `on` is used to hook into various events Cypress emits
- // `config` is the resolved Cypress config
-}
diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js
deleted file mode 100644
index d50e7ae52..000000000
--- a/tests/cypress/support/commands.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import '../commands/buy_demo_article'
-import '../commands/checkout_buy'
-import '../commands/finish_checkout'
-import '../commands/login'
-import '../commands/register'
-import '../commands/select_payment_method'
diff --git a/tests/cypress/support/index.js b/tests/cypress/support/index.js
deleted file mode 100644
index bc98e2bb5..000000000
--- a/tests/cypress/support/index.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import 'cypress-pipe'
-import './commands'
-
-// use `Cypress` instead of `cy` so this persists across all tests
-Cypress.on('window:before:load', win => {
- win.fetch = null
-})
-cy.on('uncaught:exception', (err, runnable) => {
- return false
-})
-module.exports = (on, config) => {
- on('before:browser:launch', (browser = {}, args) => {
- if (browser.name === 'chrome') {
- args.push('--disable-site-isolation-trials')
- return args
- }
- })
-}