Skip to content

Commit

Permalink
Added Phpstan lvl 1 Paypal fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
condor2 committed Mar 27, 2024
1 parent e284cd0 commit 808843a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 38 deletions.
44 changes: 22 additions & 22 deletions upload/admin/controller/extension/payment/paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
36 changes: 20 additions & 16 deletions upload/catalog/controller/extension/payment/paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -872,7 +872,7 @@ public function createOrder() {
}

if (!$errors) {
$_config = new Config();
$_config = new \Config();
$_config->load('paypal');

$config_setting = $_config->get('paypal_setting');
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -1204,7 +1204,7 @@ public function approveOrder() {
}
}

$_config = new Config();
$_config = new \Config();
$_config->load('paypal');

$config_setting = $_config->get('paypal_setting');
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 808843a

Please sign in to comment.