Skip to content

Commit

Permalink
rename old gateway to deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Dec 19, 2024
1 parent ea48f17 commit 6c9277d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Gateway/Refund/RefundProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

class RefundProcessor implements RefundProcessorInterface
{
private MolliePaymentGatewayI $molliePaymentGateway;
private $deprecatedGatewayHelper;

public function __construct(MolliePaymentGatewayI $molliePaymentGateway)
public function __construct( $deprecatedGatewayHelper)
{
$this->molliePaymentGateway = $molliePaymentGateway;
$this->deprecatedGatewayHelper = $deprecatedGatewayHelper;
}

/**
Expand All @@ -33,42 +33,42 @@ public function refundOrderPayment(WC_Order $wcOrder, $amount = null, $reason =
$order_id = $wcOrder->get_id();

// Check if there is a Mollie Payment Order object connected to this WooCommerce order
$payment_object_id = $this->molliePaymentGateway->paymentObject()->getActiveMollieOrderId(
$payment_object_id = $this->deprecatedGatewayHelper->paymentObject()->getActiveMollieOrderId(
$order_id
);

// If there is no Mollie Payment Order object, try getting a Mollie Payment Payment object
if (!$payment_object_id) {
$payment_object_id = $this->molliePaymentGateway->paymentObject()
$payment_object_id = $this->deprecatedGatewayHelper->paymentObject()
->getActiveMolliePaymentId($order_id);
}

// Mollie Payment object not found
if (!$payment_object_id) {
$error_message = __("Can\'t process refund. Could not find Mollie Payment object id for order $order_id.", 'mollie-payments-for-woocommerce');

$this->molliePaymentGateway->getLogger()->debug(
$this->deprecatedGatewayHelper->getLogger()->debug(
__METHOD__ . ' - ' . $error_message
);

throw new Exception($error_message);
}

try {
$payment_object = $this->molliePaymentGateway->getPaymentFactory()
$payment_object = $this->deprecatedGatewayHelper->getPaymentFactory()
->getPaymentObject(
$payment_object_id,
$this->molliePaymentGateway->paymentMethod()
$this->deprecatedGatewayHelper->paymentMethod()
);
} catch (ApiException $exception) {
$exceptionMessage = $exception->getMessage();
$this->molliePaymentGateway->getLogger()->debug($exceptionMessage);
$this->deprecatedGatewayHelper->getLogger()->debug($exceptionMessage);
throw new Exception($exception->getMessage());
}

if (!$payment_object || !is_object($payment_object)) {
$error_message = __("Can\'t process refund. Could not find Mollie Payment object data for order $order_id.", 'mollie-payments-for-woocommerce');
$this->molliePaymentGateway->getLogger()->debug(
$this->deprecatedGatewayHelper->getLogger()->debug(
__METHOD__ . ' - ' . $error_message
);

Expand Down

0 comments on commit 6c9277d

Please sign in to comment.