Skip to content

Commit

Permalink
Pass container to fix onMollieReturn
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Dec 15, 2024
1 parent b4ce8a7 commit c9d7638
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Gateway/inc/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
$data = $container->get('settings.data_helper');
assert($data instanceof Data);
$pluginId = $container->get('shared.plugin_id');
return new MollieOrderService($HttpResponseService, $logger, $paymentFactory, $data, $pluginId);
return new MollieOrderService($HttpResponseService, $logger, $paymentFactory, $data, $pluginId, $container);
},
OrderMandatoryGatewayDisabler::class => static function (ContainerInterface $container): OrderMandatoryGatewayDisabler {
$settings = $container->get('settings.settings_helper');
Expand Down
8 changes: 6 additions & 2 deletions src/Payment/MollieOrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Mollie\WooCommerce\SDK\HttpResponse;
use Mollie\WooCommerce\Shared\Data;
use Mollie\WooCommerce\Shared\SharedDataDictionary;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface as Logger;
use Psr\Log\LogLevel;
use WC_Order;
Expand All @@ -37,6 +38,7 @@ class MollieOrderService
*/
protected $data;
protected $pluginId;
private ContainerInterface $container;

/**
* PaymentService constructor.
Expand All @@ -46,14 +48,16 @@ public function __construct(
Logger $logger,
PaymentFactory $paymentFactory,
Data $data,
string $pluginId
string $pluginId,
ContainerInterface $container
) {

$this->httpResponse = $httpResponse;
$this->logger = $logger;
$this->paymentFactory = $paymentFactory;
$this->data = $data;
$this->pluginId = $pluginId;
$this->container = $container;
}

public function setGateway($gateway)
Expand Down Expand Up @@ -213,7 +217,7 @@ public function orderNeedsPayment(WC_Order $order)
{
$order_id = $order->get_id();
$gateway = wc_get_payment_gateway_by_order($order);
$paymentMethod = $gateway->locate('getPaymentMethod')($gateway->id);
$paymentMethod = $this->container->get('payment_gateway.getPaymentMethod')($gateway->id);

// Check whether the order is processed and paid via another gateway
if ($this->isOrderPaidByOtherGateway($order)) {
Expand Down
1 change: 1 addition & 0 deletions src/Payment/PaymentModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Inpsyde\Modularity\Module\ExecutableModule;
use Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
use Inpsyde\Modularity\Module\ServiceModule;
use Inpsyde\PaymentGateway\PaymentGateway;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Refund;
use Mollie\WooCommerce\Gateway\MolliePaymentGateway;
Expand Down

0 comments on commit c9d7638

Please sign in to comment.