mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Merge pull request #1828 from woocommerce/PCP-2257-chrome-browser-detected-as-eligible-for-apple-pay
Chrome browser detected as eligible for Apple Pay (2257)
This commit is contained in:
commit
a477770256
3 changed files with 32 additions and 6 deletions
|
@ -54,7 +54,7 @@ return array(
|
|||
}
|
||||
|
||||
// Device eligibility.
|
||||
$device_eligibility_text = __( 'Your current browser/device does not seem to support Apple Pay ❌.', 'woocommerce-paypal-payments' );
|
||||
$device_eligibility_text = __( 'Status: Your current browser/device does not seem to support Apple Pay ❌', 'woocommerce-paypal-payments' );
|
||||
$device_eligibility_notes = sprintf(
|
||||
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
|
||||
__( 'Though the button may display in previews, it won\'t appear in the shop. For details, refer to the %1$sApple Pay requirements%2$s.', 'woocommerce-paypal-payments' ),
|
||||
|
@ -62,7 +62,7 @@ return array(
|
|||
'</a>'
|
||||
);
|
||||
if ( $container->get( 'applepay.is_browser_supported' ) ) {
|
||||
$device_eligibility_text = __( 'Your browser/device supports Apple Pay ✔️.', 'woocommerce-paypal-payments' );
|
||||
$device_eligibility_text = __( 'Status: Your current browser/device seems to support Apple Pay ✔️', 'woocommerce-paypal-payments' );
|
||||
$device_eligibility_notes = __( 'The Apple Pay button will be visible both in previews and below the PayPal buttons in the shop.', 'woocommerce-paypal-payments' );
|
||||
}
|
||||
|
||||
|
|
|
@ -93,11 +93,29 @@ return array(
|
|||
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
$user_agent = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ?? '' );
|
||||
if ( $user_agent ) {
|
||||
foreach ( PropertiesDictionary::ALLOWED_USER_AGENTS as $allowed_agent ) {
|
||||
if ( strpos( $user_agent, $allowed_agent ) !== false ) {
|
||||
return true;
|
||||
foreach ( PropertiesDictionary::DISALLOWED_USER_AGENTS as $disallowed_agent ) {
|
||||
if ( strpos( $user_agent, $disallowed_agent ) !== false ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$browser_allowed = false;
|
||||
foreach ( PropertiesDictionary::ALLOWED_USER_BROWSERS as $allowed_browser ) {
|
||||
if ( strpos( $user_agent, $allowed_browser ) !== false ) {
|
||||
$browser_allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$device_allowed = false;
|
||||
foreach ( PropertiesDictionary::ALLOWED_USER_DEVICES as $allowed_devices ) {
|
||||
if ( strpos( $user_agent, $allowed_devices ) !== false ) {
|
||||
$device_allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $browser_allowed && $device_allowed;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
|
|
@ -13,7 +13,15 @@ namespace WooCommerce\PayPalCommerce\Applepay\Assets;
|
|||
* Class PropertiesDictionary
|
||||
*/
|
||||
class PropertiesDictionary {
|
||||
public const ALLOWED_USER_AGENTS = array( 'Safari', 'Macintosh', 'iPhone', 'iPad', 'iPod' );
|
||||
public const DISALLOWED_USER_AGENTS = array(
|
||||
'Chrome/',
|
||||
'CriOS/', // Chrome on iOS.
|
||||
'Firefox/',
|
||||
'OPR/', // Opera.
|
||||
'Edg/', // Edge.
|
||||
);
|
||||
public const ALLOWED_USER_BROWSERS = array( 'Safari' );
|
||||
public const ALLOWED_USER_DEVICES = array( 'Macintosh', 'iPhone', 'iPad', 'iPod' );
|
||||
|
||||
public const BILLING_CONTACT_INVALID = 'billing Contact Invalid';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue