mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 12:25:15 +08:00
Do not display pui tab if wc store is not is germany
This commit is contained in:
parent
63c3c095bb
commit
0f93759c9c
6 changed files with 54 additions and 20 deletions
|
@ -7,7 +7,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice;
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Endpoint;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use RuntimeException;
|
||||
|
@ -17,6 +17,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\FraudNet;
|
||||
use WP_Error;
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
|||
namespace WooCommerce\PayPalCommerce\WcGateway;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PayUponInvoiceOrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
||||
|
@ -32,7 +33,6 @@ use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
|||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\FraudNet;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\FraudNetSessionId;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\FraudNetSourceWebsiteId;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\PayUponInvoiceOrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\PaymentSourceFactory;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\PayUponInvoice;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice\PayUponInvoiceGateway;
|
||||
|
@ -69,6 +69,7 @@ return array(
|
|||
$order_endpoint = $container->get( 'api.endpoint.order' );
|
||||
$environment = $container->get( 'onboarding.environment' );
|
||||
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
||||
$api_shop_country = $container->get( 'api.shop.country' );
|
||||
return new PayPalGateway(
|
||||
$settings_renderer,
|
||||
$funding_source_renderer,
|
||||
|
@ -85,7 +86,8 @@ return array(
|
|||
$payment_token_repository,
|
||||
$logger,
|
||||
$payments_endpoint,
|
||||
$order_endpoint
|
||||
$order_endpoint,
|
||||
$api_shop_country
|
||||
);
|
||||
},
|
||||
'wcgateway.credit-card-gateway' => static function ( ContainerInterface $container ): CreditCardGateway {
|
||||
|
@ -177,7 +179,10 @@ return array(
|
|||
return new AuthorizeOrderActionNotice();
|
||||
},
|
||||
'wcgateway.settings.sections-renderer' => static function ( ContainerInterface $container ): SectionsRenderer {
|
||||
return new SectionsRenderer( $container->get( 'wcgateway.current-ppcp-settings-page-id' ) );
|
||||
return new SectionsRenderer(
|
||||
$container->get( 'wcgateway.current-ppcp-settings-page-id' ),
|
||||
$container->get( 'api.shop.country' )
|
||||
);
|
||||
},
|
||||
'wcgateway.settings.status' => static function ( ContainerInterface $container ): SettingsStatus {
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Gateway;
|
|||
use Psr\Log\LoggerInterface;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentsEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\CaptureStatus;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\State;
|
||||
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
||||
|
@ -159,6 +158,13 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* The api shop country.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $api_shop_country;
|
||||
|
||||
/**
|
||||
* PayPalGateway constructor.
|
||||
*
|
||||
|
@ -178,6 +184,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
* @param LoggerInterface $logger The logger.
|
||||
* @param PaymentsEndpoint $payments_endpoint The payments endpoint.
|
||||
* @param OrderEndpoint $order_endpoint The order endpoint.
|
||||
* @param string $api_shop_country The api shop country.
|
||||
*/
|
||||
public function __construct(
|
||||
SettingsRenderer $settings_renderer,
|
||||
|
@ -195,7 +202,8 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
PaymentTokenRepository $payment_token_repository,
|
||||
LoggerInterface $logger,
|
||||
PaymentsEndpoint $payments_endpoint,
|
||||
OrderEndpoint $order_endpoint
|
||||
OrderEndpoint $order_endpoint,
|
||||
string $api_shop_country
|
||||
) {
|
||||
|
||||
$this->id = self::ID;
|
||||
|
@ -276,6 +284,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
$this->payments_endpoint = $payments_endpoint;
|
||||
$this->order_endpoint = $order_endpoint;
|
||||
$this->state = $state;
|
||||
$this->api_shop_country = $api_shop_country;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -399,6 +408,10 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
* @return bool
|
||||
*/
|
||||
private function is_pui_tab():bool {
|
||||
if ( 'DE' !== $this->api_shop_country ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return is_admin() && PayUponInvoiceGateway::ID === $this->page_id;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice;
|
|||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use WC_Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PayUponInvoiceOrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\Button\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
@ -74,13 +75,13 @@ class PayUponInvoice {
|
|||
/**
|
||||
* PayUponInvoice constructor.
|
||||
*
|
||||
* @param string $module_url The module URL.
|
||||
* @param FraudNet $fraud_net The FraudNet entity.
|
||||
* @param PayUponInvoiceOrderEndpoint $order_endpoint The order endpoint.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
* @param Settings $settings The settings.
|
||||
* @param Environment $environment The environment.
|
||||
* @param string $asset_version The asset version.
|
||||
* @param string $module_url The module URL.
|
||||
* @param FraudNet $fraud_net The FraudNet entity.
|
||||
* @param PayUponInvoiceOrderEndpoint $order_endpoint The order endpoint.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
* @param Settings $settings The settings.
|
||||
* @param Environment $environment The environment.
|
||||
* @param string $asset_version The asset version.
|
||||
*/
|
||||
public function __construct(
|
||||
string $module_url,
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice;
|
|||
use Psr\Log\LoggerInterface;
|
||||
use RuntimeException;
|
||||
use WC_Payment_Gateway;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PayUponInvoiceOrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||
|
@ -64,11 +65,11 @@ class PayUponInvoiceGateway extends WC_Payment_Gateway {
|
|||
/**
|
||||
* PayUponInvoiceGateway constructor.
|
||||
*
|
||||
* @param PayUponInvoiceOrderEndpoint $order_endpoint The order endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory The purchase unit factory.
|
||||
* @param PaymentSourceFactory $payment_source_factory The payment source factory.
|
||||
* @param Environment $environment The environment.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
* @param PayUponInvoiceOrderEndpoint $order_endpoint The order endpoint.
|
||||
* @param PurchaseUnitFactory $purchase_unit_factory The purchase unit factory.
|
||||
* @param PaymentSourceFactory $payment_source_factory The payment source factory.
|
||||
* @param Environment $environment The environment.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
*/
|
||||
public function __construct(
|
||||
PayUponInvoiceOrderEndpoint $order_endpoint,
|
||||
|
|
|
@ -28,13 +28,22 @@ class SectionsRenderer {
|
|||
*/
|
||||
protected $page_id;
|
||||
|
||||
/**
|
||||
* The api shop country.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $api_shop_country;
|
||||
|
||||
/**
|
||||
* SectionsRenderer constructor.
|
||||
*
|
||||
* @param string $page_id ID of the current PPCP gateway settings page, or empty if it is not such page.
|
||||
* @param string $api_shop_country The api shop country.
|
||||
*/
|
||||
public function __construct( string $page_id ) {
|
||||
$this->page_id = $page_id;
|
||||
public function __construct( string $page_id, string $api_shop_country ) {
|
||||
$this->page_id = $page_id;
|
||||
$this->api_shop_country = $api_shop_country;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,6 +70,10 @@ class SectionsRenderer {
|
|||
WebhooksStatusPage::ID => __( 'Webhooks Status', 'woocommerce-paypal-payments' ),
|
||||
);
|
||||
|
||||
if ( 'DE' !== $this->api_shop_country ) {
|
||||
unset( $sections[ PayUponInvoiceGateway::ID ] );
|
||||
}
|
||||
|
||||
echo '<ul class="subsubsub">';
|
||||
|
||||
$array_keys = array_keys( $sections );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue