mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Merge branch 'trunk' into PCP-3828_fix-missind-void-auth-button
This commit is contained in:
commit
1b1fa37e4d
64 changed files with 26745 additions and 27817 deletions
|
@ -12,18 +12,18 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"@paypal/paypal-js": "^5.1.1",
|
||||
"core-js": "^3.25.0"
|
||||
"core-js": "^3.39"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.19",
|
||||
"@babel/preset-env": "^7.19",
|
||||
"babel-loader": "^8.2",
|
||||
"@babel/core": "^7.26",
|
||||
"@babel/preset-env": "^7.26",
|
||||
"babel-loader": "^9.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"file-loader": "^6.2.0",
|
||||
"sass": "^1.42.1",
|
||||
"sass-loader": "^12.1.0",
|
||||
"webpack": "^5.76",
|
||||
"webpack-cli": "^4.10"
|
||||
"sass": "^1.80",
|
||||
"sass-loader": "^16",
|
||||
"webpack": "^5.96",
|
||||
"webpack-cli": "^5"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "cross-env BABEL_ENV=default NODE_ENV=production webpack",
|
||||
|
|
|
@ -31,6 +31,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Endpoint\RefreshFeatureStatusEndpoint;
|
|||
use WooCommerce\PayPalCommerce\WcGateway\Endpoint\VoidOrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\CartCheckoutDetector;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\FeesUpdater;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Notice\SendOnlyCountryNotice;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\WcTasks\Factory\SimpleRedirectTaskFactory;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\WcTasks\Factory\SimpleRedirectTaskFactoryInterface;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\WcTasks\Registrar\TaskRegistrar;
|
||||
|
@ -376,6 +377,113 @@ return array(
|
|||
$container->get( 'wcgateway.settings.status' )
|
||||
);
|
||||
},
|
||||
'wcgateway.store-country' => static function(): string {
|
||||
$location = wc_get_base_location();
|
||||
return $location['country'];
|
||||
},
|
||||
'wcgateway.send-only-message' => static function() {
|
||||
return __( "<strong>Important</strong>: Your current WooCommerce store location is in a \"send-only\" country, according to PayPal's policies. Sellers in these countries are unable to receive payments via PayPal. Since receiving payments is essential for using the PayPal Payments extension, you will not be able to connect your PayPal account while operating from a \"send-only\" country. To activate PayPal, please update your WooCommerce store location to a supported region and connect a PayPal account eligible for receiving payments.", 'woocommerce-paypal-payments' );
|
||||
},
|
||||
'wcgateway.send-only-countries' => static function() {
|
||||
return array(
|
||||
'AO',
|
||||
'AI',
|
||||
'AM',
|
||||
'AW',
|
||||
'AZ',
|
||||
'BY',
|
||||
'BJ',
|
||||
'BT',
|
||||
'BO',
|
||||
'VG',
|
||||
'BN',
|
||||
'BF',
|
||||
'BI',
|
||||
'CI',
|
||||
'KH',
|
||||
'CM',
|
||||
'CV',
|
||||
'TD',
|
||||
'KM',
|
||||
'CG',
|
||||
'CK',
|
||||
'DJ',
|
||||
'ER',
|
||||
'ET',
|
||||
'FK',
|
||||
'GA',
|
||||
'GM',
|
||||
'GN',
|
||||
'GW',
|
||||
'GY',
|
||||
'KI',
|
||||
'KG',
|
||||
'LA',
|
||||
'MK',
|
||||
'MG',
|
||||
'MV',
|
||||
'ML',
|
||||
'MH',
|
||||
'MR',
|
||||
'YT',
|
||||
'FM',
|
||||
'MN',
|
||||
'ME',
|
||||
'MS',
|
||||
'NA',
|
||||
'NR',
|
||||
'NP',
|
||||
'NE',
|
||||
'NG',
|
||||
'NU',
|
||||
'NF',
|
||||
'PG',
|
||||
'PY',
|
||||
'PN',
|
||||
'RW',
|
||||
'ST',
|
||||
'WS',
|
||||
'SL',
|
||||
'SB',
|
||||
'SO',
|
||||
'SH',
|
||||
'PM',
|
||||
'VC',
|
||||
'SR',
|
||||
'SJ',
|
||||
'TJ',
|
||||
'TZ',
|
||||
'TG',
|
||||
'TO',
|
||||
'TN',
|
||||
'TM',
|
||||
'TV',
|
||||
'UG',
|
||||
'UA',
|
||||
'VA',
|
||||
'WF',
|
||||
'YE',
|
||||
'ZM',
|
||||
'ZW',
|
||||
);
|
||||
},
|
||||
'wcgateway.is-send-only-country' => static function( ContainerInterface $container ) {
|
||||
$store_country = $container->get( 'wcgateway.store-country' );
|
||||
$send_only_countries = $container->get( 'wcgateway.send-only-countries' );
|
||||
return in_array( $store_country, $send_only_countries, true );
|
||||
},
|
||||
'wcgateway.notice.send-only-country' => static function ( ContainerInterface $container ) {
|
||||
$onboarding_state = $container->get( 'onboarding.state' );
|
||||
assert( $onboarding_state instanceof State );
|
||||
return new SendOnlyCountryNotice(
|
||||
$container->get( 'wcgateway.send-only-message' ),
|
||||
$container->get( 'wcgateway.is-send-only-country' ),
|
||||
$container->get( 'wcgateway.is-ppcp-settings-page' ),
|
||||
$container->get( 'wcgateway.is-wc-gateways-list-page' ),
|
||||
$onboarding_state->current_state()
|
||||
);
|
||||
},
|
||||
|
||||
'wcgateway.notice.authorize-order-action' =>
|
||||
static function ( ContainerInterface $container ): AuthorizeOrderActionNotice {
|
||||
return new AuthorizeOrderActionNotice();
|
||||
|
|
107
modules/ppcp-wc-gateway/src/Notice/SendOnlyCountryNotice.php
Normal file
107
modules/ppcp-wc-gateway/src/Notice/SendOnlyCountryNotice.php
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
/**
|
||||
* Creates an admin message that notifies user about send only country.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\WcGateway\Notice
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\WcGateway\Notice;
|
||||
|
||||
use WooCommerce\PayPalCommerce\AdminNotices\Entity\Message;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\State;
|
||||
|
||||
/**
|
||||
* Creates an admin message that notifies user about send only country.
|
||||
*/
|
||||
class SendOnlyCountryNotice {
|
||||
|
||||
/**
|
||||
* Notice text
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected string $message_text;
|
||||
|
||||
/**
|
||||
* Indicates if current country is on the send only list
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $is_send_only_country;
|
||||
/**
|
||||
* Indicates if we're on the WooCommerce gateways list page.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private bool $is_wc_gateways_list_page;
|
||||
|
||||
/**
|
||||
* Indicates if we're on a PPCP Settings page.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private bool $is_ppcp_settings_page;
|
||||
|
||||
/**
|
||||
* Onboarding state
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private int $onboarding_state;
|
||||
|
||||
/**
|
||||
* AdminNotice constructor.
|
||||
*
|
||||
* @param string $message_text The message text.
|
||||
* @param bool $is_send_only_country Determines if current WC country is a send only country.
|
||||
* @param bool $is_ppcp_settings_page Determines if current page is ppcp settings page.
|
||||
* @param bool $is_wc_gateways_list_page Determines if current page is ppcp gateway list page.
|
||||
* @param int $onboarding_state Determines current onboarding state.
|
||||
*/
|
||||
public function __construct(
|
||||
string $message_text,
|
||||
bool $is_send_only_country,
|
||||
bool $is_ppcp_settings_page,
|
||||
bool $is_wc_gateways_list_page,
|
||||
int $onboarding_state
|
||||
) {
|
||||
$this->message_text = $message_text;
|
||||
$this->is_send_only_country = $is_send_only_country;
|
||||
$this->is_ppcp_settings_page = $is_ppcp_settings_page;
|
||||
$this->is_wc_gateways_list_page = $is_wc_gateways_list_page;
|
||||
$this->onboarding_state = $onboarding_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the message.
|
||||
*
|
||||
* @return Message|null
|
||||
*/
|
||||
public function message(): ?Message {
|
||||
|
||||
if ( ! $this->is_send_only_country ||
|
||||
! $this->is_ppcp_page() ||
|
||||
$this->onboarding_state === State::STATE_START
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Message(
|
||||
$this->message_text,
|
||||
'warning',
|
||||
true,
|
||||
'ppcp-notice-wrapper'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if current page is ppcp page
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_ppcp_page():bool {
|
||||
return $this->is_ppcp_settings_page || $this->is_wc_gateways_list_page;
|
||||
}
|
||||
}
|
|
@ -12,10 +12,11 @@ declare(strict_types=1);
|
|||
namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\PurchaseUnitSanitizer;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingOptionsRenderer;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingOptionsRenderer;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingSendOnlyNoticeRenderer;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\State;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\DisplayManager;
|
||||
|
||||
|
@ -43,6 +44,13 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
$display_manager = $container->get( 'wcgateway.display-manager' );
|
||||
assert( $display_manager instanceof DisplayManager );
|
||||
|
||||
$onboarding_send_only_notice_renderer = $container->get( 'onboarding.render-send-only-notice' );
|
||||
assert( $onboarding_send_only_notice_renderer instanceof OnboardingSendOnlyNoticeRenderer );
|
||||
|
||||
$is_send_only_country = $container->get( 'wcgateway.is-send-only-country' );
|
||||
$onboarding_elements_class = $is_send_only_country ? 'hide' : 'ppcp-onboarding-element';
|
||||
$send_only_country_notice_class = $is_send_only_country ? 'ppcp-onboarding-element' : 'hide';
|
||||
|
||||
$connection_fields = array(
|
||||
'ppcp_onboarading_header' => array(
|
||||
'type' => 'ppcp-text',
|
||||
|
@ -101,10 +109,21 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
'gateway' => Settings::CONNECTION_TAB_ID,
|
||||
'description' => __( 'Your account is connected to sandbox, no real charging takes place. To accept live payments, turn off sandbox mode and connect your live PayPal account.', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
|
||||
'ppcp_send_only_countries_notice' => array(
|
||||
'type' => 'ppcp-text',
|
||||
'classes' => array( $send_only_country_notice_class ),
|
||||
'text' => $onboarding_send_only_notice_renderer->render(),
|
||||
'raw' => true,
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => Settings::CONNECTION_TAB_ID,
|
||||
),
|
||||
'ppcp_onboarading_options' => array(
|
||||
'type' => 'ppcp-text',
|
||||
'classes' => array( 'ppcp-onboarding-element' ),
|
||||
'classes' => array( $onboarding_elements_class ),
|
||||
'text' => $onboarding_options_renderer->render(
|
||||
$is_shop_supports_dcc,
|
||||
$container->get( 'api.shop.country' ) === 'CN'
|
||||
|
@ -123,7 +142,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
// is to have the buttons before loading the script.
|
||||
'ppcp_onboarding_production_ppcp' => array(
|
||||
'type' => 'ppcp_onboarding',
|
||||
'classes' => array( 'ppcp-onboarding-element' ),
|
||||
'classes' => array( $onboarding_elements_class ),
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
),
|
||||
|
@ -135,7 +154,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
),
|
||||
'ppcp_onboarding_production_express' => array(
|
||||
'type' => 'ppcp_onboarding',
|
||||
'classes' => array( 'ppcp-onboarding-element' ),
|
||||
'classes' => array( $onboarding_elements_class ),
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
),
|
||||
|
@ -147,7 +166,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
),
|
||||
'ppcp_onboarding_sandbox_ppcp' => array(
|
||||
'type' => 'ppcp_onboarding',
|
||||
'classes' => array( 'ppcp-onboarding-element' ),
|
||||
'classes' => array( $onboarding_elements_class ),
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
),
|
||||
|
@ -160,7 +179,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
),
|
||||
'ppcp_onboarding_sandbox_express' => array(
|
||||
'type' => 'ppcp_onboarding',
|
||||
'classes' => array( 'ppcp-onboarding-element' ),
|
||||
'classes' => array( $onboarding_elements_class ),
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
),
|
||||
|
@ -214,7 +233,7 @@ return function ( ContainerInterface $container, array $fields ): array {
|
|||
esc_html__( 'Further information on manual credential input:', 'woocommerce-paypal-payments' ),
|
||||
esc_html__( 'documentation', 'woocommerce-paypal-payments' )
|
||||
),
|
||||
'classes' => array( 'ppcp-onboarding-element' ),
|
||||
'classes' => array( $onboarding_elements_class ),
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
State::STATE_ONBOARDED,
|
||||
|
|
|
@ -24,6 +24,7 @@ use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule;
|
|||
use WooCommerce\PayPalCommerce\WcGateway\Assets\VoidButtonAssets;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Endpoint\RefreshFeatureStatusEndpoint;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Endpoint\VoidOrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Notice\SendOnlyCountryNotice;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\CreditCardOrderInfoHandlingTrait;
|
||||
use WC_Order;
|
||||
use WooCommerce\PayPalCommerce\AdminNotices\Repository\Repository;
|
||||
|
@ -237,6 +238,13 @@ class WCGatewayModule implements ServiceModule, ExtendingModule, ExecutableModul
|
|||
}
|
||||
}
|
||||
|
||||
$send_only_country_notice = $c->get( 'wcgateway.notice.send-only-country' );
|
||||
assert( $send_only_country_notice instanceof SendOnlyCountryNotice );
|
||||
$message = $send_only_country_notice->message();
|
||||
if ( $message ) {
|
||||
$notices[] = $message;
|
||||
}
|
||||
|
||||
$authorize_order_action = $c->get( 'wcgateway.notice.authorize-order-action' );
|
||||
$authorized_message = $authorize_order_action->message();
|
||||
if ( $authorized_message ) {
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue