♻️ Refactor PayUponInvoice

This commit is contained in:
Philipp Stracker 2025-02-17 16:51:11 +01:00
parent 8b76e5fcb7
commit d852a7bea9
No known key found for this signature in database
2 changed files with 8 additions and 8 deletions

View file

@ -1523,7 +1523,7 @@ return array(
$container->get( 'wcgateway.pay-upon-invoice-order-endpoint' ),
$container->get( 'woocommerce.logger.woocommerce' ),
$container->get( 'wcgateway.settings' ),
$container->get( 'onboarding.state' ),
$container->get( 'settings.flag.is-connected' ),
$container->get( 'wcgateway.current-ppcp-settings-page-id' ),
$container->get( 'wcgateway.pay-upon-invoice-product-status' ),
$container->get( 'wcgateway.pay-upon-invoice-helper' ),

View file

@ -62,11 +62,11 @@ class PayUponInvoice {
protected $pui_helper;
/**
* The onboarding state.
* Whether onboarding was completed and the merchant is connected to PayPal.
*
* @var State
* @var bool
*/
protected $state;
protected bool $is_connected;
/**
* Current PayPal settings page id.
@ -102,7 +102,7 @@ class PayUponInvoice {
* @param PayUponInvoiceOrderEndpoint $pui_order_endpoint The PUI order endpoint.
* @param LoggerInterface $logger The logger.
* @param Settings $settings The settings.
* @param State $state The onboarding state.
* @param bool $is_connected Whether onboarding was completed.
* @param string $current_ppcp_settings_page_id Current PayPal settings page id.
* @param PayUponInvoiceProductStatus $pui_product_status The PUI product status.
* @param PayUponInvoiceHelper $pui_helper The PUI helper.
@ -113,7 +113,7 @@ class PayUponInvoice {
PayUponInvoiceOrderEndpoint $pui_order_endpoint,
LoggerInterface $logger,
Settings $settings,
State $state,
bool $is_connected,
string $current_ppcp_settings_page_id,
PayUponInvoiceProductStatus $pui_product_status,
PayUponInvoiceHelper $pui_helper,
@ -123,7 +123,7 @@ class PayUponInvoice {
$this->pui_order_endpoint = $pui_order_endpoint;
$this->logger = $logger;
$this->settings = $settings;
$this->state = $state;
$this->is_connected = $is_connected;
$this->current_ppcp_settings_page_id = $current_ppcp_settings_page_id;
$this->pui_product_status = $pui_product_status;
$this->pui_helper = $pui_helper;
@ -437,7 +437,7 @@ class PayUponInvoice {
function ( $methods ) {
if (
! is_array( $methods )
|| State::STATE_ONBOARDED !== $this->state->current_state()
|| ! $this->is_connected
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|| ! ( is_checkout() || isset( $_GET['pay_for_order'] ) && $_GET['pay_for_order'] === 'true' )
) {