From 808843a3cf2c8e1a39d2df24757d25bd013a7399 Mon Sep 17 00:00:00 2001 From: condor2 Date: Wed, 27 Mar 2024 15:53:01 +0200 Subject: [PATCH] Added Phpstan lvl 1 Paypal fixes --- .../controller/extension/payment/paypal.php | 44 +++++++++---------- .../controller/extension/payment/paypal.php | 36 ++++++++------- 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/upload/admin/controller/extension/payment/paypal.php b/upload/admin/controller/extension/payment/paypal.php index c63b0088..c547ffdd 100644 --- a/upload/admin/controller/extension/payment/paypal.php +++ b/upload/admin/controller/extension/payment/paypal.php @@ -20,7 +20,7 @@ public function index() { $catalog = HTTP_CATALOG; } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -244,7 +244,7 @@ public function auth() { $data['catalog'] = HTTP_CATALOG; } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $data['setting'] = $_config->get('paypal_setting'); @@ -383,7 +383,7 @@ public function dashboard() { $data['catalog'] = HTTP_CATALOG; } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $data['setting'] = $_config->get('paypal_setting'); @@ -601,7 +601,7 @@ public function general() { $data['catalog'] = HTTP_CATALOG; } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $data['setting'] = $_config->get('paypal_setting'); @@ -825,7 +825,7 @@ public function button() { $data['catalog'] = HTTP_CATALOG; } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $data['setting'] = $_config->get('paypal_setting'); @@ -1060,7 +1060,7 @@ public function googlepay_button() { $data['catalog'] = HTTP_CATALOG; } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $data['setting'] = $_config->get('paypal_setting'); @@ -1302,7 +1302,7 @@ public function applepay_button() { $data['catalog'] = HTTP_CATALOG; } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $data['setting'] = $_config->get('paypal_setting'); @@ -1526,7 +1526,7 @@ public function card() { $data['catalog'] = HTTP_CATALOG; } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $data['setting'] = $_config->get('paypal_setting'); @@ -1698,7 +1698,7 @@ public function message_configurator() { $data['catalog'] = HTTP_CATALOG; } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $data['setting'] = $_config->get('paypal_setting'); @@ -1887,7 +1887,7 @@ public function message_setting() { $data['catalog'] = HTTP_CATALOG; } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $data['setting'] = $_config->get('paypal_setting'); @@ -2067,7 +2067,7 @@ public function order_status() { $data['catalog'] = HTTP_CATALOG; } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $data['setting'] = $_config->get('paypal_setting'); @@ -2205,7 +2205,7 @@ public function contact() { $data['catalog'] = HTTP_CATALOG; } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $data['setting'] = $_config->get('paypal_setting'); @@ -2275,7 +2275,7 @@ public function connect() { $catalog = HTTP_CATALOG; } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -2647,7 +2647,7 @@ public function install() { $this->model_extension_event->addEvent('paypal_order_delete_order', 'catalog/model/checkout/order/deleteOrder/before', 'extension/payment/paypal/order_delete_order_before'); $this->model_extension_event->addEvent('paypal_customer_delete_customer', 'admin/model/customer/customer/deleteCustomer/before', 'extension/payment/paypal/customer_delete_customer_before'); - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -2789,10 +2789,10 @@ public function capturePayment() { $this->load->model('extension/payment/paypal'); - $order_id = $this->request->post['order_id']; + $order_id = (int)$this->request->post['order_id']; $transaction_id = $this->request->post['transaction_id']; - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -2876,10 +2876,10 @@ public function reauthorizePayment() { $this->load->model('extension/payment/paypal'); - $order_id = $this->request->post['order_id']; + $order_id = (int)$this->request->post['order_id']; $transaction_id = $this->request->post['transaction_id']; - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -2963,10 +2963,10 @@ public function voidPayment() { $this->load->model('extension/payment/paypal'); - $order_id = $this->request->post['order_id']; + $order_id = (int)$this->request->post['order_id']; $transaction_id = $this->request->post['transaction_id']; - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -3048,10 +3048,10 @@ public function refundPayment() { $this->load->model('extension/payment/paypal'); - $order_id = $this->request->post['order_id']; + $order_id = (int)$this->request->post['order_id']; $transaction_id = $this->request->post['transaction_id']; - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); diff --git a/upload/catalog/controller/extension/payment/paypal.php b/upload/catalog/controller/extension/payment/paypal.php index 5ec15ce0..193752ff 100644 --- a/upload/catalog/controller/extension/payment/paypal.php +++ b/upload/catalog/controller/extension/payment/paypal.php @@ -23,7 +23,7 @@ public function index() { if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret') && !$this->callback() && !$this->webhook() && !$this->cron() && $agree_status) { $this->load->language('extension/payment/paypal'); - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -112,7 +112,7 @@ public function index() { public function modal() { $this->load->language('extension/payment/paypal'); - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -203,7 +203,7 @@ public function getData() { $this->load->model('localisation/country'); $this->load->model('checkout/order'); - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -872,7 +872,7 @@ public function createOrder() { } if (!$errors) { - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -970,7 +970,7 @@ public function createOrder() { $tax_total = number_format($tax_total * $currency_value, $decimal_place, '.', ''); $order_total = number_format($item_total + $tax_total, $decimal_place, '.', ''); - if ($page_code == 'checkout') { + if ($page_code == 'checkout' && isset($order_info)) { $discount_total = 0; $handling_total = 0; $shipping_total = 0; @@ -1006,7 +1006,7 @@ public function createOrder() { 'value' => $tax_total ]; - if ($page_code == 'checkout') { + if ($page_code == 'checkout' && isset($shipping_total) && isset($handling_total) && isset($discount_total) && isset($order_info) && isset($shipping_info)) { $amount_info['breakdown']['shipping'] = [ 'currency_code' => $currency_code, 'value' => $shipping_total @@ -1030,11 +1030,11 @@ public function createOrder() { $paypal_order_info['purchase_units'][0]['items'] = $item_info; $paypal_order_info['purchase_units'][0]['amount'] = $amount_info; - if ($page_code == 'checkout') { + if ($page_code == 'checkout' && isset($order_info)) { $paypal_order_info['purchase_units'][0]['description'] = 'Your order ' . $order_info['order_id']; $paypal_order_info['purchase_units'][0]['invoice_id'] = $order_info['order_id'] . '_' . date('Ymd_His'); - if ($this->cart->hasShipping()) { + if ($this->cart->hasShipping() && isset($shipping_info)) { $paypal_order_info['purchase_units'][0]['shipping'] = $shipping_info; } } @@ -1204,7 +1204,7 @@ public function approveOrder() { } } - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -1638,6 +1638,7 @@ public function approveOrder() { $card_nice_type = (!empty($this->request->post['card_nice_type']) ? $this->request->post['card_nice_type'] : ''); $card_last_digits = ''; $card_expiry = ''; + $paypal_order_data = []; if (!$this->cart->hasShipping()) { $seller_protection_status = 'NOT_ELIGIBLE'; @@ -2520,7 +2521,7 @@ public function completeOrder() { $order_data['order_id'] = $this->session->data['order_id']; - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -2907,6 +2908,7 @@ public function completeOrder() { $card_nice_type = ''; $card_last_digits = ''; $card_expiry = ''; + $paypal_order_data = []; if (!$this->cart->hasShipping()) { $seller_protection_status = 'NOT_ELIGIBLE'; @@ -3251,7 +3253,7 @@ public function deleteCustomerToken() { if (!empty($card_customer_tokens[$card_token_index]['vault_id'])) { $vault_id = $card_customer_tokens[$card_token_index]['vault_id']; - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -3335,7 +3337,7 @@ public function callback() { $this->load->model('extension/payment/paypal'); if (!empty($this->request->get['callback_token'])) { - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -3505,6 +3507,7 @@ public function callback() { $order_status_id = 0; $transaction_status = ''; $payment_method = 'card'; + $paypal_order_data = []; if (!$this->cart->hasShipping()) { $seller_protection_status = 'NOT_ELIGIBLE'; @@ -3608,6 +3611,7 @@ public function callback() { $order_status_id = 0; $transaction_status = ''; $payment_method = 'card'; + $paypal_order_data = []; if (!$this->cart->hasShipping()) { $seller_protection_status = 'NOT_ELIGIBLE'; @@ -3749,7 +3753,7 @@ public function callback() { public function webhook() { if (!empty($this->request->get['webhook_token'])) { - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -3950,7 +3954,7 @@ public function webhook() { public function cron() { if (!empty($this->request->get['cron_token'])) { - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -3981,7 +3985,7 @@ public function header_before($route, &$data) { $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret') && $agree_status) { - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting'); @@ -4049,7 +4053,7 @@ public function extension_get_extensions_after($route, $data, &$output) { $type = $data[0]; if ($type == 'payment') { - $_config = new Config(); + $_config = new \Config(); $_config->load('paypal'); $config_setting = $_config->get('paypal_setting');