From 262d3abd269adefc1d31c97bf9e08194aaba5866 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Mon, 17 Feb 2025 16:55:53 +0100
Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20PayUponInvoiceG?=
=?UTF-8?q?ateway?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
modules/ppcp-wc-gateway/services.php | 2 +-
.../PayUponInvoice/PayUponInvoiceGateway.php | 15 +++------------
2 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/modules/ppcp-wc-gateway/services.php b/modules/ppcp-wc-gateway/services.php
index bad9f9579..ac8b54f85 100644
--- a/modules/ppcp-wc-gateway/services.php
+++ b/modules/ppcp-wc-gateway/services.php
@@ -1489,7 +1489,7 @@ return array(
$container->get( 'woocommerce.logger.woocommerce' ),
$container->get( 'wcgateway.pay-upon-invoice-helper' ),
$container->get( 'wcgateway.checkout-helper' ),
- $container->get( 'onboarding.state' ),
+ $container->get( 'settings.flag.is-connected' ),
$container->get( 'wcgateway.processor.refunds' ),
$container->get( 'wcgateway.url' )
);
diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoiceGateway.php b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoiceGateway.php
index ecd6c1df1..1622123bc 100644
--- a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoiceGateway.php
+++ b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoiceGateway.php
@@ -17,7 +17,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PayUponInvoiceOrderEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
use WooCommerce\PayPalCommerce\WcGateway\Helper\Environment;
-use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\TransactionUrlProvider;
use WooCommerce\PayPalCommerce\WcGateway\Helper\CheckoutHelper;
use WooCommerce\PayPalCommerce\WcGateway\Helper\PayUponInvoiceHelper;
@@ -89,13 +88,6 @@ class PayUponInvoiceGateway extends WC_Payment_Gateway {
*/
protected $checkout_helper;
- /**
- * The onboarding state.
- *
- * @var State
- */
- protected $state;
-
/**
* The refund processor.
*
@@ -121,7 +113,7 @@ class PayUponInvoiceGateway extends WC_Payment_Gateway {
* @param LoggerInterface $logger The logger.
* @param PayUponInvoiceHelper $pui_helper The PUI helper.
* @param CheckoutHelper $checkout_helper The checkout helper.
- * @param State $state The onboarding state.
+ * @param bool $is_connected Whether the onboarding was completed.
* @param RefundProcessor $refund_processor The refund processor.
* @param string $module_url The module URL.
*/
@@ -134,7 +126,7 @@ class PayUponInvoiceGateway extends WC_Payment_Gateway {
LoggerInterface $logger,
PayUponInvoiceHelper $pui_helper,
CheckoutHelper $checkout_helper,
- State $state,
+ bool $is_connected,
RefundProcessor $refund_processor,
string $module_url
) {
@@ -169,8 +161,7 @@ class PayUponInvoiceGateway extends WC_Payment_Gateway {
$this->module_url = $module_url;
$this->icon = apply_filters( 'woocommerce_paypal_payments_pay_upon_invoice_gateway_icon', esc_url( $this->module_url ) . 'assets/images/ratepay.svg' );
- $this->state = $state;
- if ( $state->current_state() === State::STATE_ONBOARDED ) {
+ if ( $is_connected ) {
$this->supports = array( 'refunds' );
}
$this->refund_processor = $refund_processor;