Skip to content

Commit

Permalink
Fix cs, composer update
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Jan 7, 2025
1 parent b27ce4a commit ea81951
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 46 deletions.
38 changes: 13 additions & 25 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ static function ($gateways) use ($container) {
30
);


// Disable SEPA as payment option in WooCommerce checkout
add_filter(
'woocommerce_available_payment_gateways',
Expand Down Expand Up @@ -188,7 +187,6 @@ static function ($paymentContext) {
return $fields;
}, 10, 3);


return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Gateway/MolliePaymentGatewayHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MolliePaymentGatewayHandler
/**
* @var PaymentMethodI
*/
public $paymentMethod;
protected PaymentMethodI $paymentMethod;
/**
* @var string
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Gateway/inc/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
$deprecatedGatewayHelper = $oldGatewayInstances[$gatewayId];
add_action(
'woocommerce_thankyou_' . $paymentGateway->id,
function ($order_id) use ($instructionsManager, $paymentGateway, $deprecatedGatewayHelper) {
static function ($order_id) use ($instructionsManager, $paymentGateway, $deprecatedGatewayHelper) {
$order = wc_get_order($order_id);

// Order not found
Expand Down Expand Up @@ -318,7 +318,7 @@ function ($order_id) use ($instructionsManager, $paymentGateway, $deprecatedGate
$deprecatedGatewayHelper = $oldGatewayInstances[$gatewayId];
add_action(
'woocommerce_email_after_order_table',
function ($order, $sent_to_admin, $plain_text) use ($instructionsManager, $paymentGateway, $deprecatedGatewayHelper) {
static function ($order, $sent_to_admin, $plain_text) use ($instructionsManager, $paymentGateway, $deprecatedGatewayHelper) {
$instructionsManager->displayInstructions(
$paymentGateway,
$deprecatedGatewayHelper,
Expand All @@ -333,7 +333,7 @@ function ($order, $sent_to_admin, $plain_text) use ($instructionsManager, $payme

add_action(
'woocommerce_email_order_meta',
function ($order, $sent_to_admin, $plain_text) use ($instructionsManager, $paymentGateway, $deprecatedGatewayHelper) {
static function ($order, $sent_to_admin, $plain_text) use ($instructionsManager, $paymentGateway, $deprecatedGatewayHelper) {
$instructionsManager->displayInstructions(
$paymentGateway,
$deprecatedGatewayHelper,
Expand All @@ -354,7 +354,7 @@ function ($order, $sent_to_admin, $plain_text) use ($instructionsManager, $payme
if ($paymentGateway->supports('subscriptions')) {
add_filter(
$pluginId . '_is_subscription_payment',
function ($isSubscription, $orderId) use ($pluginId, $dataHelper) {
static function ($isSubscription, $orderId) use ($pluginId, $dataHelper) {
if ($dataHelper->isWcSubscription($orderId)) {
add_filter(
$pluginId . '_is_automatic_payment_disabled',
Expand Down
2 changes: 1 addition & 1 deletion src/Payment/MollieSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected function getRecurringPaymentDescription($order, $option, $initialPayme
$middleware = new PaymentDescriptionMiddleware($this->dataHelper);
$requestData = [];
$context = 'payment';
$result = $middleware->__invoke($requestData, $order, $context, function($requestData) {
$result = $middleware->__invoke($requestData, $order, $context, static function ($requestData) {
return $requestData;
});
return $result['description'];
Expand Down
5 changes: 3 additions & 2 deletions src/Payment/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ public function __construct(

public function setGatewayHelper(string $paymentGatewayId)
{
$this->deprecatedGatewayHelper = $this->deprecatedGatewayInstances[$paymentGatewayId]??false;
$this->deprecatedGatewayHelper = $this->deprecatedGatewayInstances[$paymentGatewayId] ?? false;
}

public function setGateway(PaymentGateway $gateway)
{
$this->gateway = $gateway;
Expand All @@ -99,7 +100,7 @@ public function processPayment($order, $paymentGateway): array
$orderId = $order->get_id();
$this->setGateway($paymentGateway);
$this->setGatewayHelper($paymentGateway->id);
if($this->deprecatedGatewayHelper === false){
if ($this->deprecatedGatewayHelper === false) {
return ['result' => 'failure'];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __invoke(array $requestData, WC_Order $order, $context, $next):
if (class_exists($middlewareClass)) {
$middleware = $this->container->get($middlewareClass);
if ($middleware instanceof RequestMiddlewareInterface) {
$requestData = $middleware->__invoke($requestData, $order);
$requestData = $middleware->__invoke($requestData, $order, $context, $next);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Payment/Request/Middleware/MiddlewareHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ private function createMiddlewareChain(array $middlewares): callable
{
return array_reduce(
array_reverse($middlewares),
function ($next, $middleware) {
return function ($requestData, $order, $context) use ($middleware, $next) {
static function ($next, $middleware) {
return static function ($requestData, $order, $context) use ($middleware, $next) {
return $middleware($requestData, $order, $context, $next);
};
},
function ($requestData) {
static function ($requestData) {
return $requestData;
}
);
Expand Down
4 changes: 2 additions & 2 deletions src/Payment/Request/Middleware/RequestMiddlewareInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ interface RequestMiddlewareInterface
/**
* Invoke the middleware.
*
* @param array<string, mixed> $requestData The request data to be modified.
* @param array $requestData The request data to be modified.
* @param WC_Order $order The WooCommerce order object.
* @param string $context Additional context for the middleware.
* @param callable $next The next middleware to be called.
* @return array<string, mixed> The modified request data.
* @return array The modified request data.
*/
public function __invoke(array $requestData, WC_Order $order, string $context, callable $next): array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,26 @@ public function displayInstructions(
$admin_instructions = false,
$plain_text = false
) {

if (
($admin_instructions && !self::$alreadyDisplayedAdminInstructions)
|| (!$admin_instructions && !self::$alreadyDisplayedCustomerInstructions)
) {
$order_payment_method = $order->get_payment_method();

// Invalid gateway
if ($deprecatedGatewayHelper->id !== $order_payment_method) {
if ($paymentGateway->id !== $order_payment_method) {
return;
}

$payment = $deprecatedGatewayHelper->paymentObject()->getActiveMolliePayment(
$order->get_id()
);

$methodId = str_replace('mollie_wc_gateway_', '', $paymentGateway->id);
// Mollie payment not found or invalid gateway
if (
!$payment
|| $payment->method !== $deprecatedGatewayHelper->paymentMethod->getProperty('id')
|| $payment->method !== $methodId
) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class BillieFieldsStrategy extends AbstractPaymentFieldsRenderer implements Paym
{
const FIELD_COMPANY = "billing_company";

public function renderFields(): string {
public function renderFields(): string
{

$showCompanyField = false;

if (is_checkout_pay_page()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public function renderFields(): string
if (!$this->isMollieComponentsEnabled($this->deprecatedHelperGateway->paymentMethod())) {
return '';
}
$this->deprecatedHelperGateway->has_fields = true;
$allowedHtml = $this->svgAllowedHtml();

$output = '<div class="mollie-components"></div>';
Expand Down

0 comments on commit ea81951

Please sign in to comment.