diff --git a/src/Gateway/inc/services.php b/src/Gateway/inc/services.php index 2d350922..c34cec01 100644 --- a/src/Gateway/inc/services.php +++ b/src/Gateway/inc/services.php @@ -405,9 +405,9 @@ function ($order, $sent_to_admin, $plain_text) use ($instructionsManager, $payme if (!isset($oldGatewayInstances[$gatewayId])) { return new NoopPaymentFieldsRenderer(); } - //TODO im passing the deprecated gateway - $gateway = $oldGatewayInstances[$gatewayId]; - return new PaymentFieldsRenderer($paymentMethod, $gateway); + $deprecatedGatewayHelper = $oldGatewayInstances[$gatewayId]; + $gatewayDescription = $container->get('payment_gateway.' . $gatewayId . '.description'); + return new PaymentFieldsRenderer($paymentMethod, $deprecatedGatewayHelper, $gatewayDescription); }; $dynamicServices["payment_gateway.$gatewayId.title"] = static function (ContainerInterface $container) use ($gatewayId) { diff --git a/src/PaymentMethods/AbstractPaymentMethod.php b/src/PaymentMethods/AbstractPaymentMethod.php index 89ab91b3..f9b1efa4 100644 --- a/src/PaymentMethods/AbstractPaymentMethod.php +++ b/src/PaymentMethods/AbstractPaymentMethod.php @@ -178,13 +178,13 @@ public function getAllFormFields() /** * Sets the gateway's payment fields strategy based on payment method - * @param $gateway + * @param $deprecatedHelperGateway * @return string */ - public function paymentFieldsStrategy($gateway) + public function paymentFieldsStrategy($deprecatedHelperGateway, $gatewayDescription) { $this->paymentFieldsService->setStrategy($this); - return $this->paymentFieldsService->executeStrategy($gateway); + return $this->paymentFieldsService->executeStrategy($deprecatedHelperGateway, $gatewayDescription); } /** diff --git a/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php index e8783c32..45bd8047 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/BancomatpayFieldsStrategy.php @@ -8,7 +8,7 @@ class BancomatpayFieldsStrategy implements PaymentFieldsStrategyI { const FIELD_PHONE = "billing_phone_bancomatpay"; - public function execute($gateway, $dataHelper) + public function execute($deprecatedHelperGateway, $gatewayDescription, $dataHelper) { $showPhoneField = false; $isPhoneRequired = get_option('mollie_wc_is_phone_required_flag'); diff --git a/src/PaymentMethods/PaymentFieldsStrategies/BillieFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/BillieFieldsStrategy.php index f7e6f06c..7f88f28f 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/BillieFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/BillieFieldsStrategy.php @@ -8,7 +8,7 @@ class BillieFieldsStrategy implements PaymentFieldsStrategyI { const FIELD_COMPANY = "billing_company"; - public function execute($gateway, $dataHelper): string + public function execute($deprecatedHelperGateway, $gatewayDescription, $dataHelper): string { $showCompanyField = false; diff --git a/src/PaymentMethods/PaymentFieldsStrategies/CreditcardFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/CreditcardFieldsStrategy.php index 5cececc7..4f79abb0 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/CreditcardFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/CreditcardFieldsStrategy.php @@ -8,12 +8,12 @@ class CreditcardFieldsStrategy implements PaymentFieldsStrategyI { - public function execute($gateway, $dataHelper): string + public function execute($deprecatedHelperGateway, $gatewayDescription, $dataHelper): string { - if (!$this->isMollieComponentsEnabled($gateway->paymentMethod())) { + if (!$this->isMollieComponentsEnabled($deprecatedHelperGateway->paymentMethod())) { return ''; } - $gateway->has_fields = true; + $deprecatedHelperGateway->has_fields = true; $allowedHtml = $this->svgAllowedHtml(); $output = '
'; diff --git a/src/PaymentMethods/PaymentFieldsStrategies/DefaultFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/DefaultFieldsStrategy.php index b52b9cb8..cf93bdc0 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/DefaultFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/DefaultFieldsStrategy.php @@ -6,9 +6,9 @@ class DefaultFieldsStrategy implements PaymentFieldsStrategyI { - public function execute($gateway, $dataHelper): string + public function execute($deprecatedHelperGateway, $gatewayDescription, $dataHelper): string { - return ''; + return $gatewayDescription; } public function getFieldMarkup($gateway, $dataHelper) diff --git a/src/PaymentMethods/PaymentFieldsStrategies/GiftcardFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/GiftcardFieldsStrategy.php index 6c7b357e..bb262480 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/GiftcardFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/GiftcardFieldsStrategy.php @@ -8,17 +8,17 @@ class GiftcardFieldsStrategy implements PaymentFieldsStrategyI { use IssuersDropdownBehavior; - public function execute($gateway, $dataHelper): string + public function execute($deprecatedHelperGateway, $gatewayDescription, $dataHelper): string { - if (!$this->dropDownEnabled($gateway)) { - return ''; + if (!$this->dropDownEnabled($deprecatedHelperGateway)) { + return $gatewayDescription; } - $issuers = $this->getIssuers($gateway, $dataHelper); + $issuers = $this->getIssuers($deprecatedHelperGateway, $dataHelper); if (empty($issuers)) { - return ''; + return $gatewayDescription; } - $selectedIssuer = $gateway->paymentMethod()->getSelectedIssuer(); + $selectedIssuer = $deprecatedHelperGateway->paymentMethod()->getSelectedIssuer(); $html = ''; @@ -35,7 +35,7 @@ public function execute($gateway, $dataHelper): string return wpautop(wptexturize($html)); } - return $this->renderIssuers($gateway, $issuers, $selectedIssuer); + return $this->renderIssuers($deprecatedHelperGateway, $issuers, $selectedIssuer); } public function getFieldMarkup($gateway, $dataHelper) diff --git a/src/PaymentMethods/PaymentFieldsStrategies/In3FieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/In3FieldsStrategy.php index a67c0d47..bbe3083e 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/In3FieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/In3FieldsStrategy.php @@ -11,7 +11,7 @@ class In3FieldsStrategy implements PaymentFieldsStrategyI const FIELD_BIRTHDATE = "billing_birthdate_in3"; const FIELD_PHONE = "billing_phone_in3"; - public function execute($gateway, $dataHelper): string + public function execute($deprecatedHelperGateway, $gatewayDescription, $dataHelper): string { $showBirthdateField = false; $showPhoneField = false; diff --git a/src/PaymentMethods/PaymentFieldsStrategies/KbcFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/KbcFieldsStrategy.php index fb28a8f3..7cf7ca1a 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/KbcFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/KbcFieldsStrategy.php @@ -8,17 +8,17 @@ class KbcFieldsStrategy implements PaymentFieldsStrategyI { use IssuersDropdownBehavior; - public function execute($gateway, $dataHelper): string + public function execute($deprecatedHelperGateway, $gatewayDescription, $dataHelper): string { - if (!$this->dropDownEnabled($gateway)) { + if (!$this->dropDownEnabled($deprecatedHelperGateway)) { return ''; } - $issuers = $this->getIssuers($gateway, $dataHelper); + $issuers = $this->getIssuers($deprecatedHelperGateway, $dataHelper); - $selectedIssuer = $gateway->paymentMethod()->getSelectedIssuer(); + $selectedIssuer = $deprecatedHelperGateway->paymentMethod()->getSelectedIssuer(); - return $this->renderIssuers($gateway, $issuers, $selectedIssuer); + return $this->renderIssuers($deprecatedHelperGateway, $issuers, $selectedIssuer); } public function getFieldMarkup($gateway, $dataHelper) diff --git a/src/PaymentMethods/PaymentFieldsStrategies/PaymentFieldsManager.php b/src/PaymentMethods/PaymentFieldsStrategies/PaymentFieldsManager.php index a9ad773d..a27788da 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/PaymentFieldsManager.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/PaymentFieldsManager.php @@ -38,9 +38,9 @@ public function setStrategy($paymentMethod) } } - public function executeStrategy($gateway) + public function executeStrategy($deprecatedHelperGateway, $gatewayDescription) { - return $this->strategy->execute($gateway, $this->dataHelper); + return $this->strategy->execute($deprecatedHelperGateway, $gatewayDescription, $this->dataHelper); } public function getStrategyMarkup($gateway) diff --git a/src/PaymentMethods/PaymentFieldsStrategies/PaymentFieldsRenderer.php b/src/PaymentMethods/PaymentFieldsStrategies/PaymentFieldsRenderer.php index f62c7ec0..156acc9b 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/PaymentFieldsRenderer.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/PaymentFieldsRenderer.php @@ -3,18 +3,22 @@ namespace Mollie\WooCommerce\PaymentMethods\PaymentFieldsStrategies; use Inpsyde\PaymentGateway\PaymentFieldsRendererInterface; +use Inpsyde\PaymentGateway\PaymentGateway; use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler; use Mollie\WooCommerce\PaymentMethods\PaymentMethodI; class PaymentFieldsRenderer implements PaymentFieldsRendererInterface { private PaymentMethodI $paymentMethod; - private MolliePaymentGatewayHandler $gateway; + private MolliePaymentGatewayHandler $deprecatedGatewayHelper; - public function __construct($paymentMethod, $gateway) + private string $gatewayDescription; + + public function __construct($paymentMethod, $deprecatedGatewayHelper, $gateway) { $this->paymentMethod = $paymentMethod; - $this->gateway = $gateway; + $this->deprecatedGatewayHelper = $deprecatedGatewayHelper; + $this->gatewayDescription = $gateway; } /** @@ -22,6 +26,6 @@ public function __construct($paymentMethod, $gateway) */ public function renderFields(): string { - return $this->paymentMethod->paymentFieldsStrategy($this->gateway); + return $this->paymentMethod->paymentFieldsStrategy($this->deprecatedGatewayHelper, $this->gatewayDescription); } } diff --git a/src/PaymentMethods/PaymentFieldsStrategies/PaymentFieldsStrategyI.php b/src/PaymentMethods/PaymentFieldsStrategies/PaymentFieldsStrategyI.php index 6cc311fb..81e60c26 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/PaymentFieldsStrategyI.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/PaymentFieldsStrategyI.php @@ -6,5 +6,5 @@ interface PaymentFieldsStrategyI { - public function execute($gateway, $dataHelper): string; + public function execute($deprecatedHelperDeprecatedHelperGateway, $gatewayDescription, $dataHelper): string; } diff --git a/src/PaymentMethods/PaymentFieldsStrategies/RivertyFieldsStrategy.php b/src/PaymentMethods/PaymentFieldsStrategies/RivertyFieldsStrategy.php index 90aaa27a..de00e398 100644 --- a/src/PaymentMethods/PaymentFieldsStrategies/RivertyFieldsStrategy.php +++ b/src/PaymentMethods/PaymentFieldsStrategies/RivertyFieldsStrategy.php @@ -11,7 +11,7 @@ class RivertyFieldsStrategy implements PaymentFieldsStrategyI const FIELD_BIRTHDATE = "billing_birthdate_riverty"; const FIELD_PHONE = "billing_phone_riverty"; - public function execute($gateway, $dataHelper): string + public function execute($deprecatedHelperGateway, $gatewayDescription, $dataHelper): string { $showBirthdateField = false; $showPhoneField = false;