diff --git a/upload/catalog/controller/extension/payment/paypal.php b/upload/catalog/controller/extension/payment/paypal.php index 1ef4386e9..ba0c24f8e 100644 --- a/upload/catalog/controller/extension/payment/paypal.php +++ b/upload/catalog/controller/extension/payment/paypal.php @@ -44,7 +44,7 @@ public function index() { $data['googlepay_button_status'] = $setting['googlepay_button']['checkout']['status']; $data['card_status'] = $setting['card']['status']; - if ($setting['applepay_button']['checkout']['status'] && $this->isApple()) { + if ($setting['applepay_button']['checkout']['status'] && !empty($this->session->data['paypal']['applepay'])) { $data['applepay_button_status'] = $setting['applepay_button']['checkout']['status']; } else { $data['applepay_button_status'] = false; @@ -127,7 +127,7 @@ public function modal() { $data['googlepay_button_status'] = $setting['googlepay_button']['checkout']['status']; $data['card_status'] = $setting['card']['status']; - if ($setting['applepay_button']['checkout']['status'] && $this->isApple()) { + if ($setting['applepay_button']['checkout']['status'] && !empty($this->session->data['paypal']['applepay'])) { $data['applepay_button_status'] = $setting['applepay_button']['checkout']['status']; } else { $data['applepay_button_status'] = false; @@ -226,6 +226,10 @@ public function getData() { } $data['decimal_place'] = $setting['currency'][$data['currency_code']]['decimal_place']; + + if (!empty($this->request->post['applepay'])) { + $this->session->data['paypal']['applepay'] = true; + } $data['components'] = array(); @@ -375,7 +379,7 @@ public function getData() { } } - if ($setting['applepay_button']['product']['status'] && $this->isApple()) { + if ($setting['applepay_button']['product']['status'] && !empty($this->session->data['paypal']['applepay'])) { $data['components'][] = 'applepay'; $data['applepay_button_status'] = $setting['applepay_button']['product']['status']; $data['applepay_button_insert_tag'] = html_entity_decode($setting['applepay_button']['product']['insert_tag']); @@ -467,7 +471,7 @@ public function getData() { $data['googlepay_amount'] = number_format($item_total * $data['currency_value'], $data['decimal_place'], '.', ''); } - if ($setting['applepay_button']['cart']['status'] && $this->isApple()) { + if ($setting['applepay_button']['cart']['status'] && !empty($this->session->data['paypal']['applepay'])) { $data['components'][] = 'applepay'; $data['applepay_button_status'] = $setting['applepay_button']['cart']['status']; $data['applepay_button_insert_tag'] = html_entity_decode($setting['applepay_button']['cart']['insert_tag']); @@ -592,7 +596,7 @@ public function getData() { } } - if ($setting['applepay_button']['checkout']['status'] && $this->isApple()) { + if ($setting['applepay_button']['checkout']['status'] && !empty($this->session->data['paypal']['applepay'])) { $data['components'][] = 'applepay'; $data['applepay_button_status'] = $setting['applepay_button']['checkout']['status']; $data['applepay_button_align'] = $setting['applepay_button']['checkout']['align']; @@ -4233,7 +4237,7 @@ public function content_top_before($route, &$data) { $this->document->addScript('https://pay.google.com/gp/p/js/pay.js'); } - if (!empty($setting['applepay_button'][$params['page_code']]['status']) && $this->isApple()) { + if (!empty($setting['applepay_button'][$params['page_code']]['status'])) { $this->document->addScript('https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js'); } @@ -4286,7 +4290,7 @@ public function extension_get_extensions_after($route, $data, &$output) { ); } - if ($setting['applepay_button']['checkout']['status'] && $this->isApple()) { + if ($setting['applepay_button']['checkout']['status'] && !empty($this->session->data['paypal']['applepay'])) { $this->config->set('payment_paypal_applepay_status', 1); $output[] = array( @@ -4563,22 +4567,6 @@ private function validateReward() { } } - private function isApple() { - if (!empty($this->request->server['HTTP_USER_AGENT'])) { - $user_agent = strtolower($this->request->server['HTTP_USER_AGENT']); - - $apple_agents = array('ipod', 'iphone', 'ipad', 'apple'); - - foreach ($apple_agents as $apple_agent){ - if (stripos($user_agent, $apple_agent)) { - return true; - } - } - } - - return false; - } - private function unserialize($str) { $data = array(); diff --git a/upload/catalog/view/javascript/paypal/paypal.js b/upload/catalog/view/javascript/paypal/paypal.js index 2cc5e5cca..fd908e993 100644 --- a/upload/catalog/view/javascript/paypal/paypal.js +++ b/upload/catalog/view/javascript/paypal/paypal.js @@ -60,6 +60,10 @@ var PayPalAPI = (function () { } paypal_data = params; + + if (window.ApplePaySession && window.ApplePaySession?.supportsVersion(4) && ApplePaySession.canMakePayments()) { + paypal_data['applepay'] = true; + } if (paypal_data['page_code'] == 'product') { paypal_data['product'] = $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea').serialize(); diff --git a/upload/system/config/paypal.php b/upload/system/config/paypal.php index 51af83620..1057339ee 100644 --- a/upload/system/config/paypal.php +++ b/upload/system/config/paypal.php @@ -1,6 +1,6 @@ '3.1.4', + 'version' => '3.1.5', 'partner' => array( 'production' => array( 'partner_id' => 'TY2Q25KP2PX9L',