Skip to content

Commit

Permalink
Upgraded PayPal Checkout to v3.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCartpenter committed Jun 30, 2024
1 parent d9a6b20 commit fa54690
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
34 changes: 11 additions & 23 deletions upload/catalog/controller/extension/payment/paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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']);
Expand Down Expand Up @@ -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']);
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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');
}

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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();

Expand Down
4 changes: 4 additions & 0 deletions upload/catalog/view/javascript/paypal/paypal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion upload/system/config/paypal.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
$_['paypal_setting'] = array(
'version' => '3.1.4',
'version' => '3.1.5',
'partner' => array(
'production' => array(
'partner_id' => 'TY2Q25KP2PX9L',
Expand Down

0 comments on commit fa54690

Please sign in to comment.