mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Fix psalm
This commit is contained in:
parent
49bc0f255c
commit
f2284d49f5
2 changed files with 16 additions and 11 deletions
|
@ -116,8 +116,8 @@ class PayUponInvoice {
|
|||
* @param Environment $environment The environment.
|
||||
* @param string $asset_version The asset version.
|
||||
* @param State $state The onboarding state.
|
||||
* @param bool $is_ppcp_settings_page The is ppcp settings page.
|
||||
* @param string $current_ppcp_settings_page_id Current PayPal settings page id.
|
||||
* @param bool $is_ppcp_settings_page The is ppcp settings page.
|
||||
* @param string $current_ppcp_settings_page_id Current PayPal settings page id.
|
||||
* @param PayUponInvoiceProductStatus $pui_product_status PUI seller product status.
|
||||
*/
|
||||
public function __construct(
|
||||
|
@ -143,7 +143,7 @@ class PayUponInvoice {
|
|||
$this->state = $state;
|
||||
$this->is_ppcp_settings_page = $is_ppcp_settings_page;
|
||||
$this->current_ppcp_settings_page_id = $current_ppcp_settings_page_id;
|
||||
$this->pui_product_status = $pui_product_status;
|
||||
$this->pui_product_status = $pui_product_status;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -322,16 +322,16 @@ class PayUponInvoice {
|
|||
'woocommerce_settings_checkout',
|
||||
function () {
|
||||
if (
|
||||
$this->current_ppcp_settings_page_id === PayUponInvoiceGateway::ID
|
||||
PayUponInvoiceGateway::ID === $this->current_ppcp_settings_page_id
|
||||
&& ! $this->pui_product_status->pui_is_active()
|
||||
) {
|
||||
$gateway_settings = get_option( 'woocommerce_ppcp-pay-upon-invoice-gateway_settings' );
|
||||
$gateway_enabled = $gateway_settings['enabled'] ?? '';
|
||||
if($gateway_enabled === 'yes') {
|
||||
$gateway_enabled = $gateway_settings['enabled'] ?? '';
|
||||
if ( 'yes' === $gateway_enabled ) {
|
||||
$gateway_settings['enabled'] = 'no';
|
||||
update_option('woocommerce_ppcp-pay-upon-invoice-gateway_settings', $gateway_settings);
|
||||
update_option( 'woocommerce_ppcp-pay-upon-invoice-gateway_settings', $gateway_settings );
|
||||
$redirect_url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-pay-upon-invoice-gateway' );
|
||||
wp_safe_redirect( $redirect_url);
|
||||
wp_safe_redirect( $redirect_url );
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -347,6 +347,10 @@ class PayUponInvoice {
|
|||
* @return bool
|
||||
*/
|
||||
private function is_checkout_ready_for_pui(): bool {
|
||||
if ( ! $this->pui_product_status->pui_is_active() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$billing_country = filter_input( INPUT_POST, 'country', FILTER_SANITIZE_STRING ) ?? null;
|
||||
if ( $billing_country && 'DE' !== $billing_country ) {
|
||||
return false;
|
||||
|
|
|
@ -13,6 +13,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PartnersEndpoint;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Entity\SellerStatusProduct;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
||||
|
||||
/**
|
||||
* Class DccProductStatus
|
||||
|
@ -22,7 +23,7 @@ class PayUponInvoiceProductStatus {
|
|||
/**
|
||||
* Caches the status for the current load.
|
||||
*
|
||||
* @var string|null
|
||||
* @var bool|null
|
||||
*/
|
||||
private $current_status_cache;
|
||||
/**
|
||||
|
@ -57,7 +58,7 @@ class PayUponInvoiceProductStatus {
|
|||
* Whether the active/subscribed products support PUI.
|
||||
*
|
||||
* @return bool
|
||||
* @throws \WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException Should a setting not be found.
|
||||
* @throws NotFoundException Should a setting not be found.
|
||||
*/
|
||||
public function pui_is_active() : bool {
|
||||
if ( is_bool( $this->current_status_cache ) ) {
|
||||
|
@ -76,7 +77,7 @@ class PayUponInvoiceProductStatus {
|
|||
}
|
||||
|
||||
foreach ( $seller_status->products() as $product ) {
|
||||
if($product->name() !== 'PAYMENT_METHODS') {
|
||||
if ( $product->name() !== 'PAYMENT_METHODS' ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue