Skip to content

Commit

Permalink
Fix error on renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Dec 16, 2024
1 parent df17270 commit 867b71a
Show file tree
Hide file tree
Showing 24 changed files with 103 additions and 83 deletions.
4 changes: 2 additions & 2 deletions src/Assets/MollieCheckoutBlocksSupport.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Mollie\WooCommerce\Assets;

use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayI;
use Mollie\WooCommerce\PaymentMethods\PaymentMethodI;
use Mollie\WooCommerce\Shared\Data;
Expand Down Expand Up @@ -114,7 +114,7 @@ public static function gatewayDataForWCBlocks(Data $dataService, array $gatewayI
];
$gatewayData = [];
$isSepaEnabled = isset($gatewayInstances['mollie_wc_gateway_directdebit']) && $gatewayInstances['mollie_wc_gateway_directdebit']->enabled === 'yes';
/** @var MolliePaymentGateway $gateway */
/** @var MolliePaymentGatewayHandler $gateway */
foreach ($gatewayInstances as $gatewayKey => $gateway) {
$method = $gateway->paymentMethod();
$gatewayId = is_string($method->getProperty('id')) ? $method->getProperty('id') : "";
Expand Down
72 changes: 72 additions & 0 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,78 @@ public function molliePayPalButtonHandling(
}
}

/**
* @param $container
* @return array
*/
protected function instantiatePaymentMethods($container): array
{
$paymentMethods = [];
$listAllAvailablePaymentMethods = $container->get('gateway.getPaymentMethodsAfterFeatureFlag');
$iconFactory = $container->get(IconFactory::class);
assert($iconFactory instanceof IconFactory);
$settingsHelper = $container->get('settings.settings_helper');
assert($settingsHelper instanceof Settings);
$surchargeService = $container->get(Surcharge::class);
assert($surchargeService instanceof Surcharge);
$paymentFieldsService = $container->get(PaymentFieldsService::class);
assert($paymentFieldsService instanceof PaymentFieldsService);
foreach ($listAllAvailablePaymentMethods as $paymentMethodAvailable) {
$paymentMethodId = $paymentMethodAvailable['id'];
$paymentMethods[$paymentMethodId] = $this->buildPaymentMethod(
$paymentMethodId,
$iconFactory,
$settingsHelper,
$paymentFieldsService,
$surchargeService,
$paymentMethodAvailable
);
}

//I need DirectDebit to create SEPA gateway
if (!in_array(Constants::DIRECTDEBIT, array_keys($paymentMethods), true)) {
$paymentMethodId = Constants::DIRECTDEBIT;
$paymentMethods[$paymentMethodId] = $this->buildPaymentMethod(
$paymentMethodId,
$iconFactory,
$settingsHelper,
$paymentFieldsService,
$surchargeService,
[]
);
}
return $paymentMethods;
}
/**
* @param string $id
* @param IconFactory $iconFactory
* @param Settings $settingsHelper
* @param PaymentFieldsService $paymentFieldsService
* @param Surcharge $surchargeService
* @param array $paymentMethods
* @return PaymentMethodI | array
*/
public function buildPaymentMethod(
string $id,
IconFactory $iconFactory,
Settings $settingsHelper,
PaymentFieldsService $paymentFieldsService,
Surcharge $surchargeService,
array $apiMethod
) {

$transformedId = ucfirst($id);
$paymentMethodClassName = 'Mollie\\WooCommerce\\PaymentMethods\\' . $transformedId;
$paymentMethod = new $paymentMethodClassName(
$iconFactory,
$settingsHelper,
$paymentFieldsService,
$surchargeService,
$apiMethod
);

return $paymentMethod;
}

public function BillieFieldsMandatory($fields, $errors)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use WC_Payment_Gateway;
use WP_Error;

class MolliePaymentGateway extends WC_Payment_Gateway implements MolliePaymentGatewayI
class MolliePaymentGatewayHandler extends WC_Payment_Gateway implements MolliePaymentGatewayI
{
/**
* @var bool
Expand Down
6 changes: 3 additions & 3 deletions src/Gateway/OldGatewayBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Mollie\WooCommerce\SDK\HttpResponse;
use Mollie\WooCommerce\Settings\Settings;
use Mollie\WooCommerce\Shared\Data;
use Mollie\WooCommerce\Subscription\MollieSepaRecurringGatewayHandlerHandler;
use Mollie\WooCommerce\Subscription\MollieSepaRecurringGatewayHandler;
use Mollie\WooCommerce\Subscription\MollieSubscriptionGatewayHandler;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface as Logger;
Expand Down Expand Up @@ -59,7 +59,7 @@ public function instantiatePaymentMethodGateways(ContainerInterface $container):
$key = 'mollie_wc_gateway_' . $paymentMethodId;
if ($isSepa) {
$directDebit = $paymentMethods[Constants::DIRECTDEBIT];
$gateways[$key] = new MollieSepaRecurringGatewayHandlerHandler(
$gateways[$key] = new MollieSepaRecurringGatewayHandler(
$directDebit,
$paymentMethod,
$paymentService,
Expand Down Expand Up @@ -92,7 +92,7 @@ public function instantiatePaymentMethodGateways(ContainerInterface $container):
$apiHelper
);
} else {
$gateways[$key] = new MolliePaymentGateway(
$gateways[$key] = new MolliePaymentGatewayHandler(
$paymentMethod,
$paymentService,
$orderInstructionsService,
Expand Down
2 changes: 1 addition & 1 deletion src/Gateway/Voucher/MaybeDisableGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Mollie\WooCommerce\Gateway\Voucher;

use Inpsyde\PaymentGateway\PaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Payment\PaymentService;
use Mollie\WooCommerce\PaymentMethods\Voucher;

Expand Down
1 change: 0 additions & 1 deletion src/Gateway/inc/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
return SharedDataDictionary::GATEWAY_CLASSNAMES;
},
'gateway.instances' => static function (ContainerInterface $container): array {
//TODO remove this
$oldGatewayBuilder = new OldGatewayBuilder();
return $oldGatewayBuilder->instantiatePaymentMethodGateways($container);
},
Expand Down
2 changes: 1 addition & 1 deletion src/Payment/MollieObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Order;
use Mollie\Api\Resources\Payment;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\PaymentMethods\Voucher;
use Mollie\WooCommerce\SDK\Api;
use Mollie\WooCommerce\Settings\Settings;
Expand Down
2 changes: 1 addition & 1 deletion src/Payment/MollieOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\Order;
use Mollie\Api\Resources\Refund;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\PaymentMethods\Voucher;
use Mollie\WooCommerce\SDK\Api;
use Mollie\WooCommerce\Shared\SharedDataDictionary;
Expand Down
2 changes: 1 addition & 1 deletion src/Payment/MollieOrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Mollie\Api\Resources\Order;
use Mollie\Api\Resources\Payment;
use Mollie\WooCommerce\Gateway\AbstractGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\SDK\HttpResponse;
use Mollie\WooCommerce\Shared\Data;
use Mollie\WooCommerce\Shared\SharedDataDictionary;
Expand Down
2 changes: 1 addition & 1 deletion src/Payment/MolliePayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Mollie\Api\Resources\Order;
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\Refund;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayI;
use Mollie\WooCommerce\PaymentMethods\Voucher;
use Mollie\WooCommerce\SDK\Api;
Expand Down
2 changes: 1 addition & 1 deletion src/Payment/MollieSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Inpsyde\PaymentGateway\PaymentGateway;
use Mollie\Api\Types\SequenceType;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\SDK\Api;
use Mollie\WooCommerce\Subscription\MollieSubscriptionGatewayHandler;

Expand Down
4 changes: 2 additions & 2 deletions src/Payment/PaymentModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Inpsyde\PaymentGateway\PaymentGateway;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Refund;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayI;
use Mollie\WooCommerce\SDK\Api;
use Mollie\WooCommerce\SDK\HttpResponse;
Expand Down Expand Up @@ -326,7 +326,7 @@ public function onOrderDetails(WC_Order $order, ContainerInterface $container)
* Do not show instruction again below details on order received page
* Instructions already displayed on top of order received page by $gateway->thankyou_page()
*
* @see MolliePaymentGateway::thankyou_page
* @see MolliePaymentGatewayHandler::thankyou_page
*/
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/PaymentMethods/AbstractPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Mollie\WooCommerce\PaymentMethods;

use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Gateway\Surcharge;
use Mollie\WooCommerce\Payment\PaymentFieldsService;
use Mollie\WooCommerce\Settings\Settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Mollie\WooCommerce\PaymentMethods\PaymentFieldsStrategies;

use Inpsyde\PaymentGateway\PaymentFieldsRendererInterface;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\PaymentMethods\PaymentMethodI;

class PaymentFieldsRenderer implements PaymentFieldsRendererInterface
{
private PaymentMethodI $paymentMethod;
private MolliePaymentGateway $gateway;
private MolliePaymentGatewayHandler $gateway;

public function __construct($paymentMethod, $gateway)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Settings/General/MollieGeneralSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Mollie\WooCommerce\Settings\General;

use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Gateway\Surcharge;
use Mollie\WooCommerce\Shared\SharedDataDictionary;

Expand Down
51 changes: 0 additions & 51 deletions src/Subscription/MaybeFixSubscription.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use DateTime;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Types\SequenceType;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Notice\NoticeInterface;
use Mollie\WooCommerce\Payment\MollieObject;
use Mollie\WooCommerce\Payment\MollieOrderService;
Expand All @@ -24,7 +24,7 @@
use Psr\Log\LoggerInterface as Logger;
use Psr\Log\LogLevel;

class MollieSepaRecurringGatewayHandlerHandler extends MollieSubscriptionGatewayHandler
class MollieSepaRecurringGatewayHandler extends MollieSubscriptionGatewayHandler
{
const WAITING_CONFIRMATION_PERIOD_DAYS = '21';

Expand Down Expand Up @@ -66,7 +66,7 @@ public function __construct(
$pluginId,
$apiHelper
);
$directDebit = new MolliePaymentGateway(
$directDebit = new MolliePaymentGatewayHandler(
$directDebitPaymentMethod,
$paymentService,
$orderInstructionsService,
Expand Down
4 changes: 2 additions & 2 deletions src/Subscription/MollieSubscriptionGatewayHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Exception;
use Inpsyde\PaymentGateway\PaymentGateway;
use Mollie\Api\Exceptions\ApiException;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Payment\MollieObject;
use Mollie\WooCommerce\Payment\MollieSubscription;
use Mollie\WooCommerce\Payment\OrderInstructionsService;
Expand All @@ -27,7 +27,7 @@
use Mollie\WooCommerce\PaymentMethods\Constants;
use WC_Order;

class MollieSubscriptionGatewayHandler extends MolliePaymentGateway
class MollieSubscriptionGatewayHandler extends MolliePaymentGatewayHandler
{
protected const PAYMENT_TEST_MODE = 'test';
protected const METHODS_NEEDING_UPDATE = ['mollie_wc_gateway_bancontact',
Expand Down
2 changes: 1 addition & 1 deletion src/Subscription/SubscriptionModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use DateTime;
use Inpsyde\Modularity\Module\ExecutableModule;
use Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Settings\Settings;
use Mollie\WooCommerce\Shared\Data;
use Mollie\WooCommerce\Shared\SharedDataDictionary;
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Functional/Gateway/MollieGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Mollie\Api\Resources\Mandate;
use Mollie\Api\Resources\MandateCollection;
use Mollie\Api\Resources\Payment;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Payment\MollieObject;
use Mollie\WooCommerce\SDK\HttpResponse;
use Mollie\WooCommerce\Subscription\MollieSubscriptionGatewayHandler;
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Functional/HelperMocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


use Mollie\Api\MollieApiClient;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Notice\AdminNotice;
use Mollie\WooCommerce\Payment\MollieOrder;
use Mollie\WooCommerce\Payment\MollieOrderService;
Expand Down Expand Up @@ -257,7 +257,7 @@ public function mollieGatewayBuilder($paymentMethodName, $isSepa, $isSubscriptio
$pluginId = $this->pluginId();

return $this->buildTesteeMock(
MolliePaymentGateway::class,
MolliePaymentGatewayHandler::class,
[
$paymentMethod,
$paymentService,
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Functional/Payment/PaymentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Mollie\Api\Endpoints\OrderEndpoint;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\MollieApiClient;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Payment\PaymentCheckoutRedirectService;
use Mollie\WooCommerce\Payment\PaymentService;
use Mollie\WooCommerce\PaymentMethods\IconFactory;
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Functional/SDK/SdkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Mollie\Api\Resources\Mandate;
use Mollie\Api\Resources\MandateCollection;
use Mollie\Api\Resources\Payment;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
use Mollie\WooCommerce\Gateway\MolliePaymentGatewayHandler;
use Mollie\WooCommerce\Payment\MollieObject;
use Mollie\WooCommerce\SDK\HttpResponse;
use Mollie\WooCommerce\SDK\WordPressHttpAdapter;
Expand Down
Loading

0 comments on commit 867b71a

Please sign in to comment.