Skip to content

Commit

Permalink
Upgraded PayPal Checkout extension to v3.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCartpenter committed Jun 10, 2024
1 parent b283d63 commit e094da8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
7 changes: 5 additions & 2 deletions upload/admin/controller/extension/payment/paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -2018,12 +2018,13 @@ public function install() {

$this->model_setting_event->deleteEventByCode('paypal_order_info');
$this->model_setting_event->deleteEventByCode('paypal_header');
$this->model_setting_event->deleteEventByCode('paypal_content_top');
$this->model_setting_event->deleteEventByCode('paypal_extension_get_extensions');
$this->model_setting_event->deleteEventByCode('paypal_order_delete_order');
$this->model_setting_event->deleteEventByCode('paypal_customer_delete_customer');

$this->model_setting_event->addEvent('paypal_order_info', 'admin/view/sale/order_info/before', 'extension/payment/paypal/order_info_before');
$this->model_setting_event->addEvent('paypal_header', 'catalog/controller/common/header/before', 'extension/payment/paypal/header_before');
$this->model_setting_event->addEvent('paypal_content_top', 'catalog/controller/common/content_top/before', 'extension/payment/paypal/content_top_before');
$this->model_setting_event->addEvent('paypal_extension_get_extensions', 'catalog/model/setting/extension/getExtensions/after', 'extension/payment/paypal/extension_get_extensions_after');
$this->model_setting_event->addEvent('paypal_order_delete_order', 'catalog/model/checkout/order/deleteOrder/before', 'extension/payment/paypal/order_delete_order_before');
$this->model_setting_event->addEvent('paypal_customer_delete_customer', 'admin/model/customer/customer/deleteCustomer/before', 'extension/payment/paypal/customer_delete_customer_before');
Expand All @@ -2049,6 +2050,7 @@ public function uninstall() {

$this->model_setting_event->deleteEventByCode('paypal_order_info');
$this->model_setting_event->deleteEventByCode('paypal_header');
$this->model_setting_event->deleteEventByCode('paypal_content_top');
$this->model_setting_event->deleteEventByCode('paypal_extension_get_extensions');
$this->model_setting_event->deleteEventByCode('paypal_order_delete_order');
$this->model_setting_event->deleteEventByCode('paypal_customer_delete_customer');
Expand All @@ -2067,12 +2069,13 @@ public function update() {

$this->model_setting_event->deleteEventByCode('paypal_order_info');
$this->model_setting_event->deleteEventByCode('paypal_header');
$this->model_setting_event->deleteEventByCode('paypal_content_top');
$this->model_setting_event->deleteEventByCode('paypal_extension_get_extensions');
$this->model_setting_event->deleteEventByCode('paypal_order_delete_order');
$this->model_setting_event->deleteEventByCode('paypal_customer_delete_customer');

$this->model_setting_event->addEvent('paypal_order_info', 'admin/view/sale/order_info/before', 'extension/payment/paypal/order_info_before');
$this->model_setting_event->addEvent('paypal_header', 'catalog/controller/common/header/before', 'extension/payment/paypal/header_before');
$this->model_setting_event->addEvent('paypal_content_top', 'catalog/controller/common/content_top/before', 'extension/payment/paypal/content_top_before');
$this->model_setting_event->addEvent('paypal_extension_get_extensions', 'catalog/model/setting/extension/getExtensions/after', 'extension/payment/paypal/extension_get_extensions_after');
$this->model_setting_event->addEvent('paypal_order_delete_order', 'catalog/model/checkout/order/deleteOrder/before', 'extension/payment/paypal/order_delete_order_before');
$this->model_setting_event->addEvent('paypal_customer_delete_customer', 'admin/model/customer/customer/deleteCustomer/before', 'extension/payment/paypal/customer_delete_customer_before');
Expand Down
16 changes: 11 additions & 5 deletions upload/catalog/controller/extension/payment/paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -4181,7 +4181,7 @@ public function update() {
$this->model_extension_payment_paypal->update();
}

public function header_before($route, &$data) {
public function content_top_before($route, &$data) {
$this->load->model('extension/payment/paypal');

$agree_status = $this->model_extension_payment_paypal->getAgreeStatus();
Expand All @@ -4193,6 +4193,12 @@ public function header_before($route, &$data) {
$config_setting = $_config->get('paypal_setting');

$setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting'));

$currency_code = $this->session->data['currency'];

if (empty($setting['currency'][$currency_code]['status'])) {
$currency_code = $setting['general']['currency_code'];
}

if (isset($this->request->get['route'])) {
$route = $this->request->get['route'];
Expand All @@ -4202,19 +4208,19 @@ public function header_before($route, &$data) {

$params = array();

if (($route == 'common/home') && $setting['message']['home']['status']) {
if (($route == 'common/home') && ($setting['message']['home']['status'] && !empty($setting['paylater_country'][$setting['general']['country_code']]) && ($currency_code == $setting['general']['currency_code']))) {
$params['page_code'] = 'home';
}

if (($route == 'product/product') && ($setting['button']['product']['status'] || $setting['googlepay_button']['product']['status'] || $setting['applepay_button']['product']['status'] || $setting['message']['product']['status'])) {
if (($route == 'product/product') && ($setting['button']['product']['status'] || $setting['googlepay_button']['product']['status'] || $setting['applepay_button']['product']['status'] || ($setting['message']['product']['status'] && !empty($setting['paylater_country'][$setting['general']['country_code']]) && ($currency_code == $setting['general']['currency_code'])))) {
$params['page_code'] = 'product';
}

if (($route == 'checkout/cart') && ($setting['button']['cart']['status'] || $setting['googlepay_button']['cart']['status'] || $setting['applepay_button']['cart']['status'] || $setting['message']['cart']['status'])) {
if (($route == 'checkout/cart') && ($setting['button']['cart']['status'] || $setting['googlepay_button']['cart']['status'] || $setting['applepay_button']['cart']['status'] || ($setting['message']['cart']['status'] && !empty($setting['paylater_country'][$setting['general']['country_code']]) && ($currency_code == $setting['general']['currency_code'])))) {
$params['page_code'] = 'cart';
}

if (($route == $setting['general']['checkout_route']) && ($setting['button']['checkout']['status'] || $setting['googlepay_button']['checkout']['status'] || $setting['applepay_button']['checkout']['status'] || $setting['card']['status'] || $setting['message']['checkout']['status'])) {
if (($route == $setting['general']['checkout_route']) && ($setting['button']['checkout']['status'] || $setting['googlepay_button']['checkout']['status'] || $setting['applepay_button']['checkout']['status'] || $setting['card']['status'] || ($setting['message']['checkout']['status'] && !empty($setting['paylater_country'][$setting['general']['country_code']]) && ($currency_code == $setting['general']['currency_code'])))) {
$params['page_code'] = 'checkout';
}

Expand Down
3 changes: 2 additions & 1 deletion upload/catalog/model/extension/payment/paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -790,12 +790,13 @@ public function update() {

$this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = 'paypal_order_info'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = 'paypal_header'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = 'paypal_content_top'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = 'paypal_extension_get_extensions'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = 'paypal_order_delete_order'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = 'paypal_customer_delete_customer'");

$this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'paypal_order_info', `trigger` = 'admin/view/sale/order_info/before', `action` = 'extension/payment/paypal/order_info_before', `sort_order` = '0', `status` = '1'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'paypal_header', `trigger` = 'catalog/controller/common/header/before', `action` = 'extension/payment/paypal/header_before', `sort_order` = '0', `status` = '1'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'paypal_content_top', `trigger` = 'catalog/controller/common/content_top/before', `action` = 'extension/payment/paypal.content_top_before', `sort_order` = '0', `status` = '1'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'paypal_extension_get_extensions', `trigger` = 'catalog/model/setting/extension/getExtensions/after', `action` = 'extension/payment/paypal/extension_get_extensions_after', `sort_order` = '0', `status` = '1'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'paypal_order_delete_order', `trigger` = 'catalog/model/checkout/order/deleteOrder/before', `action` = 'extension/payment/paypal/order_delete_order_before', `sort_order` = '0', `status` = '1'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'paypal_customer_delete_customer', `trigger` = 'admin/model/customer/customer/deleteCustomer/before', `action` = 'extension/payment/paypal/customer_delete_customer_before', `sort_order` = '0', `status` = '1'");
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.3',
'version' => '3.1.4',
'partner' => array(
'production' => array(
'partner_id' => 'TY2Q25KP2PX9L',
Expand Down

0 comments on commit e094da8

Please sign in to comment.