From 045a588e1a9608ecba0993cd7e6d88e49c5279ef Mon Sep 17 00:00:00 2001 From: TheCartpenter Date: Sat, 25 May 2024 16:04:16 -0400 Subject: [PATCH] Renamed array conventional names --- .../controller/extension/payment/paypal.php | 564 +++++++++--------- .../admin/model/extension/payment/paypal.php | 58 +- .../controller/extension/payment/paypal.php | 512 ++++++++-------- .../extension/payment/paypal_applepay.php | 22 +- .../extension/payment/paypal_googlepay.php | 22 +- .../extension/payment/paypal_paylater.php | 22 +- .../controller/extension/recurring/paypal.php | 2 +- .../model/extension/payment/paypal.php | 72 +-- .../extension/payment/paypal_applepay.php | 6 +- .../extension/payment/paypal_googlepay.php | 6 +- .../extension/payment/paypal_paylater.php | 6 +- upload/system/config/paypal.php | 3 +- upload/system/library/paypal/paypal.php | 32 +- 13 files changed, 668 insertions(+), 659 deletions(-) diff --git a/upload/admin/controller/extension/payment/paypal.php b/upload/admin/controller/extension/payment/paypal.php index de714b764..70857bcc0 100644 --- a/upload/admin/controller/extension/payment/paypal.php +++ b/upload/admin/controller/extension/payment/paypal.php @@ -1,6 +1,6 @@ $cache_data['shared_id'], 'environment' => $environment, 'partner_attribution_id' => $config_setting['partner'][$environment]['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'authorization_code', 'code' => $cache_data['authorization_code'], 'code_verifier' => $cache_data['seller_nonce'] - ); + ]; $paypal->setAccessToken($token_info); @@ -63,19 +63,19 @@ public function index() { $secret = $result['client_secret']; } - $paypal_info = array( + $paypal_info = [ 'partner_id' => $config_setting['partner'][$environment]['partner_id'], 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $config_setting['partner'][$environment]['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); @@ -84,20 +84,20 @@ public function index() { $webhook_token = sha1(uniqid(mt_rand(), 1)); $cron_token = sha1(uniqid(mt_rand(), 1)); - $webhook_info = array( + $webhook_info = [ 'url' => $catalog . 'index.php?route=extension/payment/paypal&webhook_token=' . $webhook_token, - 'event_types' => array( - array('name' => 'PAYMENT.AUTHORIZATION.CREATED'), - array('name' => 'PAYMENT.AUTHORIZATION.VOIDED'), - array('name' => 'PAYMENT.CAPTURE.COMPLETED'), - array('name' => 'PAYMENT.CAPTURE.DENIED'), - array('name' => 'PAYMENT.CAPTURE.PENDING'), - array('name' => 'PAYMENT.CAPTURE.REFUNDED'), - array('name' => 'PAYMENT.CAPTURE.REVERSED'), - array('name' => 'CHECKOUT.ORDER.COMPLETED'), - array('name' => 'VAULT.PAYMENT-TOKEN.CREATED') - ) - ); + 'event_types' => [ + ['name' => 'PAYMENT.AUTHORIZATION.CREATED'], + ['name' => 'PAYMENT.AUTHORIZATION.VOIDED'], + ['name' => 'PAYMENT.CAPTURE.COMPLETED'], + ['name' => 'PAYMENT.CAPTURE.DENIED'], + ['name' => 'PAYMENT.CAPTURE.PENDING'], + ['name' => 'PAYMENT.CAPTURE.REFUNDED'], + ['name' => 'PAYMENT.CAPTURE.REVERSED'], + ['name' => 'CHECKOUT.ORDER.COMPLETED'], + ['name' => 'VAULT.PAYMENT-TOKEN.CREATED'] + ] + ]; $result = $paypal->createWebhook($webhook_info); @@ -108,8 +108,8 @@ public function index() { } if ($paypal->hasErrors()) { - $error_messages = array(); - + $error_messages = []; + $errors = $paypal->getErrors(); foreach ($errors as $error) { @@ -193,22 +193,22 @@ public function auth() { $this->document->setTitle($this->language->get('heading_title_main')); - $data['breadcrumbs'] = array(); + $data['breadcrumbs'] = []; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); $data['partner_url'] = str_replace('&', '%26', $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true)); @@ -234,16 +234,16 @@ public function auth() { $data['seller_nonce'] = $this->token(50); - $data['configure_url'] = array( - 'production' => array( + $data['configure_url'] = [ + 'production' => [ 'ppcp' => 'https://www.paypal.com/bizsignup/partner/entry?partnerId=' . $data['setting']['partner']['production']['partner_id'] . '&partnerClientId=' . $data['setting']['partner']['production']['client_id'] . '&features=PAYMENT,REFUND,ACCESS_MERCHANT_INFORMATION,VAULT,BILLING_AGREEMENT&product=PPCP,ADVANCED_VAULTING&capabilities=PAYPAL_WALLET_VAULTING_ADVANCED&integrationType=FO&returnToPartnerUrl=' . $data['partner_url'] . '&displayMode=minibrowser&sellerNonce=' . $data['seller_nonce'], 'express_checkout' => 'https://www.paypal.com/bizsignup/partner/entry?partnerId=' . $data['setting']['partner']['production']['partner_id'] . '&partnerClientId=' . $data['setting']['partner']['production']['client_id'] . '&features=PAYMENT,REFUND,ACCESS_MERCHANT_INFORMATION,VAULT,BILLING_AGREEMENT&product=EXPRESS_CHECKOUT,ADVANCED_VAULTING&capabilities=PAYPAL_WALLET_VAULTING_ADVANCED&integrationType=FO&returnToPartnerUrl=' . $data['partner_url'] . '&displayMode=minibrowser&sellerNonce=' . $data['seller_nonce'] - ), - 'sandbox' => array( + ], + 'sandbox' => [ 'ppcp' => 'https://www.sandbox.paypal.com/bizsignup/partner/entry?partnerId=' . $data['setting']['partner']['sandbox']['partner_id'] . '&partnerClientId=' . $data['setting']['partner']['sandbox']['client_id'] . '&features=PAYMENT,REFUND,ACCESS_MERCHANT_INFORMATION,VAULT,BILLING_AGREEMENT&product=PPCP,ADVANCED_VAULTING&capabilities=PAYPAL_WALLET_VAULTING_ADVANCED&integrationType=FO&returnToPartnerUrl=' . $data['partner_url'] . '&displayMode=minibrowser&sellerNonce=' . $data['seller_nonce'], 'express_checkout' => 'https://www.sandbox.paypal.com/bizsignup/partner/entry?partnerId=' . $data['setting']['partner']['sandbox']['partner_id'] . '&partnerClientId=' . $data['setting']['partner']['sandbox']['client_id'] . '&features=PAYMENT,REFUND,ACCESS_MERCHANT_INFORMATION,VAULT,BILLING_AGREEMENT&product=EXPRESS_CHECKOUT,ADVANCED_VAULTING&capabilities=PAYPAL_WALLET_VAULTING_ADVANCED&integrationType=FO&returnToPartnerUrl=' . $data['partner_url'] . '&displayMode=minibrowser&sellerNonce=' . $data['seller_nonce'] - ) - ); + ] + ]; $data['text_checkout_express'] = sprintf($this->language->get('text_checkout_express'), $data['configure_url'][$data['environment']]['express_checkout']); $data['text_support'] = sprintf($this->language->get('text_support'), $this->request->server['HTTP_HOST']); @@ -292,22 +292,22 @@ public function dashboard() { $this->document->setTitle($this->language->get('heading_title_main')); - $data['breadcrumbs'] = array(); + $data['breadcrumbs'] = []; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'user_token=' . $this->session->data['user_token'], true); @@ -423,22 +423,22 @@ public function general() { $this->document->setTitle($this->language->get('heading_title_main')); - $data['breadcrumbs'] = array(); + $data['breadcrumbs'] = []; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); @@ -544,22 +544,22 @@ public function button() { $this->document->setTitle($this->language->get('heading_title_main')); - $data['breadcrumbs'] = array(); + $data['breadcrumbs'] = []; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); @@ -611,25 +611,25 @@ public function button() { if ($data['client_id'] && $data['secret']) { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['setting']['partner'][$data['environment']]['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -696,22 +696,22 @@ public function googlepay_button() { $this->document->setTitle($this->language->get('heading_title_main')); - $data['breadcrumbs'] = array(); + $data['breadcrumbs'] = []; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); @@ -763,25 +763,25 @@ public function googlepay_button() { if ($data['client_id'] && $data['secret']) { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['setting']['partner'][$data['environment']]['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -848,22 +848,22 @@ public function applepay_button() { $this->document->setTitle($this->language->get('heading_title_main')); - $data['breadcrumbs'] = array(); + $data['breadcrumbs'] = []; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); @@ -917,25 +917,25 @@ public function applepay_button() { if ($data['client_id'] && $data['secret']) { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['setting']['partner'][$data['environment']]['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -1002,22 +1002,22 @@ public function card() { $this->document->setTitle($this->language->get('heading_title_main')); - $data['breadcrumbs'] = array(); + $data['breadcrumbs'] = []; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); @@ -1069,25 +1069,25 @@ public function card() { if ($data['client_id'] && $data['secret']) { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['setting']['partner'][$data['environment']]['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -1154,22 +1154,22 @@ public function message_configurator() { $this->document->setTitle($this->language->get('heading_title_main')); - $data['breadcrumbs'] = array(); + $data['breadcrumbs'] = []; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); @@ -1222,25 +1222,25 @@ public function message_configurator() { if ($data['client_id'] && $data['secret']) { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['setting']['partner'][$data['environment']]['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -1306,22 +1306,22 @@ public function message_setting() { $this->document->setTitle($this->language->get('heading_title_main')); - $data['breadcrumbs'] = array(); + $data['breadcrumbs'] = []; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); @@ -1382,25 +1382,25 @@ public function message_setting() { if ($data['client_id'] && $data['secret']) { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['setting']['partner'][$data['environment']]['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -1462,22 +1462,22 @@ public function order_status() { $this->document->setTitle($this->language->get('heading_title_main')); - $data['breadcrumbs'] = array(); + $data['breadcrumbs'] = []; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); @@ -1554,22 +1554,22 @@ public function contact() { $this->document->setTitle($this->language->get('heading_title_main')); - $data['breadcrumbs'] = array(); + $data['breadcrumbs'] = []; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'user_token=' . $this->session->data['user_token'], true) - ); + ]; // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'user_token=' . $this->session->data['user_token'], true); @@ -1636,6 +1636,8 @@ public function contact() { public function save() { $this->load->language('extension/payment/paypal'); + + $json = []; $this->load->model('setting/setting'); @@ -1646,17 +1648,19 @@ public function save() { $this->model_setting_setting->editSetting('payment_paypal', $setting); - $data['success'] = $this->language->get('success_save'); + $json['success'] = $this->language->get('success_save'); } - $data['error'] = $this->error; + $json['error'] = $this->error; $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($data)); + $this->response->setOutput(json_encode($json)); } public function connect() { $this->load->language('extension/payment/paypal'); + + $json = []; if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $server = HTTPS_SERVER; @@ -1681,19 +1685,19 @@ public function connect() { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $config_setting['partner'][$environment]['partner_id'], 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $config_setting['partner'][$environment]['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $result = $paypal->setAccessToken($token_info); @@ -1703,20 +1707,20 @@ public function connect() { $webhook_token = sha1(uniqid(mt_rand(), 1)); $cron_token = sha1(uniqid(mt_rand(), 1)); - $webhook_info = array( + $webhook_info = [ 'url' => $catalog . 'index.php?route=extension/payment/paypal&webhook_token=' . $webhook_token, - 'event_types' => array( - array('name' => 'PAYMENT.AUTHORIZATION.CREATED'), - array('name' => 'PAYMENT.AUTHORIZATION.VOIDED'), - array('name' => 'PAYMENT.CAPTURE.COMPLETED'), - array('name' => 'PAYMENT.CAPTURE.DENIED'), - array('name' => 'PAYMENT.CAPTURE.PENDING'), - array('name' => 'PAYMENT.CAPTURE.REFUNDED'), - array('name' => 'PAYMENT.CAPTURE.REVERSED'), - array('name' => 'CHECKOUT.ORDER.COMPLETED'), - array('name' => 'VAULT.PAYMENT-TOKEN.CREATED') - ) - ); + 'event_types' => [ + ['name' => 'PAYMENT.AUTHORIZATION.CREATED'], + ['name' => 'PAYMENT.AUTHORIZATION.VOIDED'], + ['name' => 'PAYMENT.CAPTURE.COMPLETED'], + ['name' => 'PAYMENT.CAPTURE.DENIED'], + ['name' => 'PAYMENT.CAPTURE.PENDING'], + ['name' => 'PAYMENT.CAPTURE.REFUNDED'], + ['name' => 'PAYMENT.CAPTURE.REVERSED'], + ['name' => 'CHECKOUT.ORDER.COMPLETED'], + ['name' => 'VAULT.PAYMENT-TOKEN.CREATED'] + ] + ]; $result = $paypal->createWebhook($webhook_info); @@ -1727,7 +1731,7 @@ public function connect() { } if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -1795,13 +1799,15 @@ public function connect() { $this->error['warning'] = $this->language->get('error_connect'); } - $data['error'] = $this->error; + $json['error'] = $this->error; $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($data)); + $this->response->setOutput(json_encode($json)); } public function disconnect() { + $json = []; + $this->load->model('setting/setting'); $setting = $this->model_setting_setting->getSetting('payment_paypal'); @@ -1813,13 +1819,15 @@ public function disconnect() { $this->model_setting_setting->editSetting('payment_paypal', $setting); - $data['error'] = $this->error; + $json['error'] = $this->error; $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($data)); + $this->response->setOutput(json_encode($json)); } public function callback() { + $json = []; + if (isset($this->request->post['environment']) && isset($this->request->post['authorization_code']) && isset($this->request->post['shared_id']) && isset($this->request->post['seller_nonce'])) { $cache_data['environment'] = $this->request->post['environment']; $cache_data['authorization_code'] = $this->request->post['authorization_code']; @@ -1829,27 +1837,27 @@ public function callback() { $this->cache->set('paypal', $cache_data, 30); } - $data['error'] = $this->error; + $json['error'] = $this->error; $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($data)); + $this->response->setOutput(json_encode($json)); } public function getSaleAnalytics() { $this->load->language('extension/payment/paypal'); - $data = array(); + $json = []; $this->load->model('extension/payment/paypal'); - $data['all_sale'] = array(); - $data['paypal_sale'] = array(); - $data['xaxis'] = array(); + $json['all_sale'] = []; + $json['paypal_sale'] = []; + $json['xaxis'] = []; - $data['all_sale']['label'] = $this->language->get('text_all_sales'); - $data['paypal_sale']['label'] = $this->language->get('text_paypal_sales'); - $data['all_sale']['data'] = array(); - $data['paypal_sale']['data'] = array(); + $json['all_sale']['label'] = $this->language->get('text_all_sales'); + $json['paypal_sale']['label'] = $this->language->get('text_paypal_sales'); + $json['all_sale']['data'] = []; + $json['paypal_sale']['data'] = []; if (isset($this->request->get['range'])) { $range = $this->request->get['range']; @@ -1863,12 +1871,12 @@ public function getSaleAnalytics() { $results = $this->model_extension_payment_paypal->getTotalSalesByDay(); foreach ($results as $key => $value) { - $data['all_sale']['data'][] = array($key, $value['total']); - $data['paypal_sale']['data'][] = array($key, $value['paypal_total']); + $json['all_sale']['data'][] = [$key, $value['total']]; + $json['paypal_sale']['data'][] = [$key, $value['paypal_total']]; } for ($i = 0; $i < 24; $i++) { - $data['xaxis'][] = array($i, $i); + $json['xaxis'][] = [$i, $i]; } break; @@ -1876,8 +1884,8 @@ public function getSaleAnalytics() { $results = $this->model_extension_payment_paypal->getTotalSalesByWeek(); foreach ($results as $key => $value) { - $data['all_sale']['data'][] = array($key, $value['total']); - $data['paypal_sale']['data'][] = array($key, $value['paypal_total']); + $json['all_sale']['data'][] = [$key, $value['total']]; + $json['paypal_sale']['data'][] = [$key, $value['paypal_total']]; } $date_start = strtotime('-' . date('w') . ' days'); @@ -1885,7 +1893,7 @@ public function getSaleAnalytics() { for ($i = 0; $i < 7; $i++) { $date = date('Y-m-d', $date_start + ($i * 86400)); - $data['xaxis'][] = array(date('w', strtotime($date)), date('D', strtotime($date))); + $json['xaxis'][] = [date('w', strtotime($date)), date('D', strtotime($date))]; } break; @@ -1893,14 +1901,14 @@ public function getSaleAnalytics() { $results = $this->model_extension_payment_paypal->getTotalSalesByMonth(); foreach ($results as $key => $value) { - $data['all_sale']['data'][] = array($key, $value['total']); - $data['paypal_sale']['data'][] = array($key, $value['paypal_total']); + $json['all_sale']['data'][] = [$key, $value['total']]; + $json['paypal_sale']['data'][] = [$key, $value['paypal_total']]; } for ($i = 1; $i <= date('t'); $i++) { $date = date('Y') . '-' . date('m') . '-' . $i; - $data['xaxis'][] = array(date('j', strtotime($date)), date('d', strtotime($date))); + $json['xaxis'][] = [date('j', strtotime($date)), date('d', strtotime($date))]; } break; @@ -1908,19 +1916,19 @@ public function getSaleAnalytics() { $results = $this->model_extension_payment_paypal->getTotalSalesByYear(); foreach ($results as $key => $value) { - $data['all_sale']['data'][] = array($key, $value['total']); - $data['paypal_sale']['data'][] = array($key, $value['paypal_total']); + $json['all_sale']['data'][] = [$key, $value['total']]; + $json['paypal_sale']['data'][] = [$key, $value['paypal_total']]; } for ($i = 1; $i <= 12; $i++) { - $data['xaxis'][] = array($i, date('M', mktime(0, 0, 0, $i))); + $json['xaxis'][] = [$i, date('M', mktime(0, 0, 0, $i))]; } break; } $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($data)); + $this->response->setOutput(json_encode($json)); } public function downloadAssociationFile() { @@ -2114,11 +2122,11 @@ public function order_info_before($route, &$data) { $content = $this->getPaymentDetails((int)$this->request->get['order_id']); if ($content) { - $data['tabs'][] = array( + $data['tabs'][] = [ 'code' => 'paypal', 'title' => $this->language->get('heading_title_main'), 'content' => $content - ); + ]; } } } @@ -2206,26 +2214,26 @@ private function getPaymentDetails($order_id) { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $paypal_order_info = $paypal->getOrder($data['paypal_order_id']); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -2323,7 +2331,7 @@ private function getPaymentDetails($order_id) { $this->model_extension_payment_paypal->addOrderHistory($setting['general']['order_history_token'], $order_id, $order_status_id); } - $paypal_order_data = array(); + $paypal_order_data = []; $paypal_order_data['order_id'] = $order_id; $paypal_order_data['transaction_status'] = $transaction_status; @@ -2388,34 +2396,34 @@ public function capturePayment() { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); - $transaction_info = array( - 'amount' => array( + $transaction_info = [ + 'amount' => [ 'value' => number_format($capture_amount, $decimal_place, '.', ''), 'currency_code' => $currency_code - ), + ], 'final_capture' => $final_capture - ); + ]; $result = $paypal->setPaymentCapture($transaction_id, $transaction_info); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -2452,7 +2460,7 @@ public function capturePayment() { $this->model_extension_payment_paypal->addOrderHistory($setting['general']['order_history_token'], $order_id, $order_status_id); } - $paypal_order_data = array(); + $paypal_order_data = []; $paypal_order_data['order_id'] = $order_id; $paypal_order_data['transaction_id'] = $transaction_id; @@ -2504,33 +2512,33 @@ public function reauthorizePayment() { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); - $transaction_info = array( + $transaction_info = [ 'amount' => array( 'value' => number_format($reauthorize_amount, $decimal_place, '.', ''), 'currency_code' => $currency_code ) - ); + ]; $result = $paypal->setPaymentReauthorize($transaction_id, $transaction_info); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -2555,11 +2563,11 @@ public function reauthorizePayment() { $transaction_id = $result['id']; $transaction_status = 'created'; - $paypal_order_data = array( + $paypal_order_data = [ 'order_id' => $order_id, 'transaction_id' => $transaction_id, 'transaction_status' => $transaction_status - ); + ]; $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); @@ -2603,26 +2611,26 @@ public function voidPayment() { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $result = $paypal->setPaymentVoid($transaction_id); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -2646,10 +2654,10 @@ public function voidPayment() { if (!$this->error) { $transaction_status = 'voided'; - $paypal_order_data = array( + $paypal_order_data = [ 'order_id' => $order_id, 'transaction_status' => $transaction_status - ); + ]; $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); @@ -2702,25 +2710,25 @@ public function refundPayment() { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $paypal_order_info = $paypal->getOrder($paypal_order_info['paypal_order_id']); - $capture_refund_amount = array(); + $capture_refund_amount = []; $available_refund_amount = 0; $final_capture_amount = 0; @@ -2768,12 +2776,12 @@ public function refundPayment() { } if ($refund_amount > $available_refund_amount) { - $transaction_info = array( - 'amount' => array( + $transaction_info = [ + 'amount' => [ 'value' => number_format($refund_amount, $decimal_place, '.', ''), 'currency_code' => $currency_code - ) - ); + ] + ]; $result = $paypal->setPaymentRefund($transaction_id, $transaction_info); } else { @@ -2786,12 +2794,12 @@ public function refundPayment() { $final_capture_first_amount = $final_capture_amount * 0.5; } - $transaction_info = array( - 'amount' => array( + $transaction_info = [ + 'amount' => [ 'value' => number_format($final_capture_first_amount * 0.5, $decimal_place, '.', ''), 'currency_code' => $currency_code - ) - ); + ] + ]; $result = $paypal->setPaymentRefund($transaction_id, $transaction_info); @@ -2803,23 +2811,23 @@ public function refundPayment() { if ($refund_amount > 0) { if (($capture['status'] == 'COMPLETED')) { if ($refund_amount <= $capture['amount']['value']) { - $transaction_info = array( - 'amount' => array( + $transaction_info = [ + 'amount' => [ 'value' => number_format($refund_amount, $decimal_place, '.', ''), 'currency_code' => $currency_code - ) - ); + ] + ]; $result = $paypal->setPaymentRefund($capture['id'], $transaction_info); $refund_amount = 0; } else { - $transaction_info = array( - 'amount' => array( + $transaction_info = [ + 'amount' => [ 'value' => number_format($capture['amount']['value'], $decimal_place, '.', ''), 'currency_code' => $currency_code - ) - ); + ] + ]; $result = $paypal->setPaymentRefund($capture['id'], $transaction_info); @@ -2830,23 +2838,23 @@ public function refundPayment() { if ($capture['status'] == 'PARTIALLY_REFUNDED') { if (!empty($capture_refund_amount[$capture['id']])) { if ($refund_amount <= ($capture['amount']['value'] - $capture_refund_amount[$capture['id']])) { - $transaction_info = array( - 'amount' => array( + $transaction_info = [ + 'amount' => [ 'value' => number_format($refund_amount, $decimal_place, '.', ''), 'currency_code' => $currency_code - ) - ); + ] + ]; $result = $paypal->setPaymentRefund($capture['id'], $transaction_info); $refund_amount = 0; } else { - $transaction_info = array( - 'amount' => array( + $transaction_info = [ + 'amount' => [ 'value' => number_format($capture['amount']['value'] - $capture_refund_amount[$capture['id']], $decimal_place, '.', ''), 'currency_code' => $currency_code - ) - ); + ] + ]; $result = $paypal->setPaymentRefund($capture['id'], $transaction_info); @@ -2861,7 +2869,7 @@ public function refundPayment() { } if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -2897,7 +2905,7 @@ public function refundPayment() { $this->model_extension_payment_paypal->addOrderHistory($setting['general']['order_history_token'], $order_id, $order_status_id); } - $paypal_order_data = array(); + $paypal_order_data = []; $paypal_order_data['order_id'] = $order_id; $paypal_order_data['transaction_status'] = $transaction_status; @@ -2918,7 +2926,7 @@ public function refundPayment() { public function autocompleteCarrier() { $this->load->model('extension/payment/paypal'); - $data = array(); + $json = []; if (!empty($this->request->post['filter_country_code']) && !empty($this->request->post['filter_carrier_name'])) { $filter_country_code = $this->request->post['filter_country_code']; @@ -2929,7 +2937,7 @@ public function autocompleteCarrier() { $config_carrier = $_config->get('paypal_carrier'); - $carriers = array(); + $carriers = []; if (!empty($config_carrier[$filter_country_code])) { $carriers = $config_carrier[$filter_country_code]; @@ -2939,19 +2947,21 @@ public function autocompleteCarrier() { foreach ($carriers as $carrier_name => $carrier_code) { if (strpos(strtolower($carrier_name), strtolower($filter_carrier_name)) !== false) { - $data[] = array( + $json[] = [ 'name' => $carrier_name, 'code' => $carrier_code - ); + ]; } } } $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($data)); + $this->response->setOutput(json_encode($json)); } public function createTracker() { + $json = []; + if ($this->config->get('payment_paypal_status') && !empty($this->request->post['order_id']) && !empty($this->request->post['country_code']) && isset($this->request->post['tracking_number']) && isset($this->request->post['carrier_name'])) { $this->load->language('extension/payment/paypal'); @@ -2973,7 +2983,7 @@ public function createTracker() { $config_carrier = $_config->get('paypal_carrier'); - $carriers = array(); + $carriers = []; if (!empty($config_carrier[$country_code])) { $carriers = $config_carrier[$country_code]; @@ -3003,23 +3013,23 @@ public function createTracker() { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); - $tracker_info = array(); + $tracker_info = []; $tracker_info['capture_id'] = $transaction_id; $tracker_info['tracking_number'] = $tracking_number; @@ -3033,7 +3043,7 @@ public function createTracker() { $result = $paypal->createOrderTracker($paypal_order_id, $tracker_info); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -3055,11 +3065,11 @@ public function createTracker() { } if (isset($result['id']) && isset($result['status']) && !$this->error) { - $paypal_order_data = array( + $paypal_order_data = [ 'order_id' => $order_id, 'tracking_number' => $tracking_number, 'carrier_name' => $carrier_name - ); + ]; $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); @@ -3075,15 +3085,15 @@ public function createTracker() { } } - $data['success'] = $this->language->get('success_create_tracker'); + $json['success'] = $this->language->get('success_create_tracker'); } } } - $data['error'] = $this->error; + $json['error'] = $this->error; $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($data)); + $this->response->setOutput(json_encode($json)); } public function cancelTracker() { @@ -3117,34 +3127,34 @@ public function cancelTracker() { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); - $tracker_info = array(); + $tracker_info = []; - $tracker_info[] = array( + $tracker_info[] = [ 'op' => 'replace', 'path' => '/status', 'value' => 'CANCELLED' - ); + ]; $result = $paypal->updateOrderTracker($paypal_order_id, $transaction_id . '-' . $tracking_number, $tracker_info); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -3166,11 +3176,11 @@ public function cancelTracker() { } if (!$this->error) { - $paypal_order_data = array( + $paypal_order_data = [ 'order_id' => $order_id, 'tracking_number' => '', 'carrier_name' => '' - ); + ]; $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); diff --git a/upload/admin/model/extension/payment/paypal.php b/upload/admin/model/extension/payment/paypal.php index 9505caa21..1b57d26f7 100644 --- a/upload/admin/model/extension/payment/paypal.php +++ b/upload/admin/model/extension/payment/paypal.php @@ -2,7 +2,7 @@ class ModelExtensionPaymentPayPal extends Model { public function getTotalSales() { - $implode = array(); + $implode = []; foreach ($this->config->get('config_complete_status') as $order_status_id) { $implode[] = "'" . (int)$order_status_id . "'"; @@ -14,126 +14,126 @@ public function getTotalSales() { } public function getTotalSalesByDay() { - $implode = array(); + $implode = []; foreach ($this->config->get('config_complete_status') as $order_status_id) { $implode[] = "'" . (int)$order_status_id . "'"; } - $sale_data = array(); + $sale_data = []; for ($i = 0; $i < 24; $i++) { - $sale_data[$i] = array( + $sale_data[$i] = [ 'hour' => $i, 'total' => 0, 'paypal_total' => 0 - ); + ]; } $query = $this->db->query("SELECT SUM(total) AS total, SUM(IF (payment_code = 'paypal', total, 0)) AS paypal_total, HOUR(date_added) AS hour FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(',', $implode) . ") AND DATE(date_added) = DATE(NOW()) GROUP BY HOUR(date_added) ORDER BY date_added ASC"); foreach ($query->rows as $result) { - $sale_data[$result['hour']] = array( + $sale_data[$result['hour']] = [ 'hour' => $result['hour'], 'total' => $result['total'], 'paypal_total' => $result['paypal_total'] - ); + ]; } return $sale_data; } public function getTotalSalesByWeek() { - $implode = array(); + $implode = []; foreach ($this->config->get('config_complete_status') as $order_status_id) { $implode[] = "'" . (int)$order_status_id . "'"; } - $sale_data = array(); + $sale_data = []; $date_start = strtotime('-' . date('w') . ' days'); for ($i = 0; $i < 7; $i++) { $date = date('Y-m-d', $date_start + ($i * 86400)); - $sale_data[date('w', strtotime($date))] = array( + $sale_data[date('w', strtotime($date))] = [ 'day' => date('D', strtotime($date)), 'total' => 0, 'paypal_total' => 0 - ); + ]; } $query = $this->db->query("SELECT SUM(total) AS total, SUM(IF (payment_code = 'paypal', total, 0)) AS paypal_total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(',', $implode) . ") AND DATE(date_added) >= DATE('" . $this->db->escape(date('Y-m-d', $date_start)) . "') GROUP BY DAYNAME(date_added)"); foreach ($query->rows as $result) { - $sale_data[date('w', strtotime($result['date_added']))] = array( + $sale_data[date('w', strtotime($result['date_added']))] = [ 'day' => date('D', strtotime($result['date_added'])), 'total' => $result['total'], 'paypal_total' => $result['paypal_total'] - ); + ]; } return $sale_data; } public function getTotalSalesByMonth() { - $implode = array(); + $implode = []; foreach ($this->config->get('config_complete_status') as $order_status_id) { $implode[] = "'" . (int)$order_status_id . "'"; } - $sale_data = array(); + $sale_data = []; for ($i = 1; $i <= date('t'); $i++) { $date = date('Y') . '-' . date('m') . '-' . $i; - $sale_data[date('j', strtotime($date))] = array( + $sale_data[date('j', strtotime($date))] = [ 'day' => date('d', strtotime($date)), 'total' => 0, 'paypal_total' => 0 - ); + ]; } $query = $this->db->query("SELECT SUM(total) AS total, SUM(IF (payment_code = 'paypal', total, 0)) AS paypal_total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(',', $implode) . ") AND DATE(date_added) >= '" . $this->db->escape(date('Y') . '-' . date('m') . '-1') . "' GROUP BY DATE(date_added)"); foreach ($query->rows as $result) { - $sale_data[date('j', strtotime($result['date_added']))] = array( + $sale_data[date('j', strtotime($result['date_added']))] = [ 'day' => date('d', strtotime($result['date_added'])), 'total' => $result['total'], 'paypal_total' => $result['paypal_total'] - ); + ]; } return $sale_data; } public function getTotalSalesByYear() { - $implode = array(); + $implode = []; foreach ($this->config->get('config_complete_status') as $order_status_id) { $implode[] = "'" . (int)$order_status_id . "'"; } - $sale_data = array(); + $sale_data = []; for ($i = 1; $i <= 12; $i++) { - $sale_data[$i] = array( + $sale_data[$i] = [ 'month' => date('M', mktime(0, 0, 0, $i)), 'total' => 0, 'paypal_total' => 0 - ); + ]; } $query = $this->db->query("SELECT SUM(total) AS total, SUM(IF (payment_code = 'paypal', total, 0)) AS paypal_total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(',', $implode) . ") AND YEAR(date_added) = YEAR(NOW()) GROUP BY MONTH(date_added)"); foreach ($query->rows as $result) { - $sale_data[date('n', strtotime($result['date_added']))] = array( + $sale_data[date('n', strtotime($result['date_added']))] = [ 'month' => date('M', strtotime($result['date_added'])), 'total' => $result['total'], 'paypal_total' => $result['paypal_total'] - ); + ]; } return $sale_data; @@ -152,7 +152,7 @@ public function deletePayPalCustomerTokens($customer_id) { public function editPayPalOrder($data) { $sql = "UPDATE `" . DB_PREFIX . "paypal_checkout_integration_order` SET"; - $implode = array(); + $implode = []; if (!empty($data['paypal_order_id'])) { $implode[] = "`paypal_order_id` = '" . $this->db->escape($data['paypal_order_id']) . "'"; @@ -233,7 +233,7 @@ public function getPayPalOrder($order_id) { if ($query->num_rows) { return $query->row; } else { - return array(); + return []; } } @@ -271,10 +271,10 @@ public function addOrderHistory($order_history_token, $order_id, $order_status_i $catalog = HTTP_CATALOG; } - $data = array( + $data = [ 'order_id' => $order_id, 'order_status_id' => $order_status_id - ); + ]; $curl = curl_init(); diff --git a/upload/catalog/controller/extension/payment/paypal.php b/upload/catalog/controller/extension/payment/paypal.php index 315d2c848..c277a964b 100644 --- a/upload/catalog/controller/extension/payment/paypal.php +++ b/upload/catalog/controller/extension/payment/paypal.php @@ -1,6 +1,6 @@ $data['partner_id'], 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -135,26 +135,26 @@ public function modal() { require_once DIR_SYSTEM .'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $data['partner_id'], 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -227,7 +227,7 @@ public function getData() { $data['decimal_place'] = $setting['currency'][$data['currency_code']]['decimal_place']; - $data['components'] = array(); + $data['components'] = []; if ($this->request->post['page_code'] == 'home') { if ($setting['message']['home']['status'] && !empty($setting['paylater_country'][$setting['general']['country_code']]) && ($data['currency_code'] == $setting['general']['currency_code'])) { @@ -279,7 +279,7 @@ public function getData() { if (isset($product['option'])) { $option = array_filter($product['option']); } else { - $option = array(); + $option = []; } $this->load->model('catalog/product'); @@ -344,8 +344,8 @@ public function getData() { $data['button_shape'] = $setting['button']['product']['shape']; $data['button_label'] = $setting['button']['product']['label']; - $data['button_enable_funding'] = array(); - $data['button_disable_funding'] = array(); + $data['button_enable_funding'] = []; + $data['button_disable_funding'] = []; foreach ($setting['button_funding'] as $button_funding) { if ($setting['button']['product']['funding'][$button_funding['code']] == 1) { @@ -424,8 +424,8 @@ public function getData() { $data['button_shape'] = $setting['button']['cart']['shape']; $data['button_label'] = $setting['button']['cart']['label']; - $data['button_enable_funding'] = array(); - $data['button_disable_funding'] = array(); + $data['button_enable_funding'] = []; + $data['button_disable_funding'] = []; foreach ($setting['button_funding'] as $button_funding) { if ($setting['button']['cart']['funding'][$button_funding['code']] == 1) { @@ -543,8 +543,8 @@ public function getData() { $data['button_shape'] = $setting['button']['checkout']['shape']; $data['button_label'] = $setting['button']['checkout']['label']; - $data['button_enable_funding'] = array(); - $data['button_disable_funding'] = array(); + $data['button_enable_funding'] = []; + $data['button_disable_funding'] = []; foreach ($setting['button_funding'] as $button_funding) { if ($setting['button']['checkout']['funding'][$button_funding['code']] == 1) { @@ -630,17 +630,17 @@ public function getData() { $data['card_size'] = $setting['card']['size']; $data['card_width'] = $setting['card_width'][$data['card_size']]; - $data['card_customer_tokens'] = array(); + $data['card_customer_tokens'] = []; if ($setting['general']['vault_status'] && $this->customer->isLogged()) { $card_customer_tokens = $this->model_extension_payment_paypal->getPayPalCustomerTokens($this->customer->getId(), 'card'); foreach ($card_customer_tokens as $card_customer_token) { - $data['card_customer_tokens'][] = array( + $data['card_customer_tokens'][] = [ 'vault_id' => $card_customer_token['vault_id'], 'card_type' => $card_customer_token['card_type'], 'card_number' => sprintf($this->language->get('text_card_number'), $card_customer_token['card_nice_type'], $card_customer_token['card_last_digits']) - ); + ]; } } } @@ -680,19 +680,19 @@ public function getData() { require_once DIR_SYSTEM .'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $data['partner_id'], 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials', - ); + ]; if ($setting['general']['vault_status'] && $this->customer->isLogged()) { $paypal_customer_token = $this->model_extension_payment_paypal->getPayPalCustomerMainToken($this->customer->getId(), 'paypal'); @@ -712,7 +712,7 @@ public function getData() { $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -763,7 +763,7 @@ public function createOrder() { $payment_method = 'card'; } - $errors = array(); + $errors = []; $data['paypal_order_id'] = ''; $data['url'] = ''; @@ -790,7 +790,7 @@ public function createOrder() { if (isset($product['option'])) { $option = array_filter($product['option']); } else { - $option = array(); + $option = []; } $product_options = $this->model_catalog_product->getProductOptions($product_id); @@ -810,7 +810,7 @@ public function createOrder() { $recurrings = $this->model_catalog_product->getProfiles($product_info['product_id']); if ($recurrings) { - $recurring_ids = array(); + $recurring_ids = []; foreach ($recurrings as $recurring) { $recurring_ids[] = $recurring['recurring_id']; @@ -840,7 +840,7 @@ public function createOrder() { $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - $shipping_info = array(); + $shipping_info = []; if ($this->cart->hasShipping()) { $shipping_info['name']['full_name'] = $order_info['shipping_firstname']; @@ -897,23 +897,23 @@ public function createOrder() { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); - $item_info = array(); + $item_info = []; $item_total = 0; $tax_total = 0; @@ -923,7 +923,7 @@ public function createOrder() { foreach ($this->cart->getProducts() as $product) { $product_price = number_format($product['price'] * $currency_value, $decimal_place, '.', ''); - $product_info = array(); + $product_info = []; $product_info['name'] = $product['name']; $product_info['quantity'] = $product['quantity']; @@ -934,10 +934,10 @@ public function createOrder() { $product_info['image_url'] = $this->model_tool_image->resize($product['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_thumb_height')); } - $product_info['unit_amount'] = array( + $product_info['unit_amount'] = [ 'currency_code' => $currency_code, 'value' => $product_price - ); + ]; $item_info[] = $product_info; @@ -954,15 +954,15 @@ public function createOrder() { if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $voucher) { - $voucher_info = array(); + $voucher_info = []; $voucher_info['name'] = $voucher['description']; $voucher_info['quantity'] = 1; - $voucher_info['unit_amount'] = array( + $voucher_info['unit_amount'] = [ 'currency_code' => $currency_code, 'value' => $voucher['amount'] - ); + ]; $item_info[] = $voucher_info; @@ -995,39 +995,39 @@ public function createOrder() { } } - $amount_info = array(); + $amount_info = []; $amount_info['currency_code'] = $currency_code; $amount_info['value'] = $order_total; - $amount_info['breakdown']['item_total'] = array( + $amount_info['breakdown']['item_total'] = [ 'currency_code' => $currency_code, 'value' => $item_total - ); + ]; - $amount_info['breakdown']['tax_total'] = array( + $amount_info['breakdown']['tax_total'] = [ 'currency_code' => $currency_code, 'value' => $tax_total - ); + ]; if ($page_code == 'checkout') { - $amount_info['breakdown']['shipping'] = array( + $amount_info['breakdown']['shipping'] = [ 'currency_code' => $currency_code, 'value' => $shipping_total - ); + ]; - $amount_info['breakdown']['handling'] = array( + $amount_info['breakdown']['handling'] = [ 'currency_code' => $currency_code, 'value' => $handling_total - ); + ]; - $amount_info['breakdown']['discount'] = array( + $amount_info['breakdown']['discount'] = [ 'currency_code' => $currency_code, 'value' => $discount_total - ); + ]; } - $paypal_order_info = array(); + $paypal_order_info = []; $paypal_order_info['intent'] = strtoupper($transaction_method); $paypal_order_info['purchase_units'][0]['reference_id'] = 'default'; @@ -1053,19 +1053,19 @@ public function createOrder() { if ($setting['general']['vault_status'] && ($this->customer->isLogged() || $this->cart->hasRecurringProducts())) { if ($payment_method == 'paypal') { - $paypal_customer_token = array(); + $paypal_customer_token = []; if ($this->customer->isLogged()) { $paypal_customer_token = $this->model_extension_payment_paypal->getPayPalCustomerMainToken($this->customer->getId(), $payment_method); } if (empty($paypal_customer_token['vault_id'])) { - $paypal_order_info['payment_source'][$payment_method]['attributes']['vault'] = array( + $paypal_order_info['payment_source'][$payment_method]['attributes']['vault'] = [ 'permit_multiple_payment_tokens' => 'false', 'store_in_vault' => 'ON_SUCCESS', 'usage_type' => 'MERCHANT', 'customer_type' => 'CONSUMER' - ); + ]; } } @@ -1106,7 +1106,7 @@ public function createOrder() { $result = $paypal->createOrder($paypal_order_info); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -1225,19 +1225,19 @@ public function approveOrder() { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); @@ -1247,7 +1247,7 @@ public function approveOrder() { $paypal_order_info = $paypal->getOrder($paypal_order_id); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -1298,7 +1298,7 @@ public function approveOrder() { $this->session->data['guest']['lastname'] = (isset($paypal_order_info['payer']['name']['surname']) ? $paypal_order_info['payer']['name']['surname'] : ''); $this->session->data['guest']['email'] = (isset($paypal_order_info['payer']['email_address']) ? $paypal_order_info['payer']['email_address'] : ''); $this->session->data['guest']['telephone'] = (isset($paypal_order_info['payer']['phone']['phone_number']['national_number']) ? $paypal_order_info['payer']['phone']['phone_number']['national_number'] : ''); - $this->session->data['guest']['custom_field'] = array(); + $this->session->data['guest']['custom_field'] = []; } if ($this->customer->isLogged() && $this->customer->getAddressId()) { @@ -1316,7 +1316,7 @@ public function approveOrder() { $this->session->data['payment_address']['address_format'] = ''; $this->session->data['payment_address']['zone'] = ''; $this->session->data['payment_address']['zone_id'] = 0; - $this->session->data['payment_address']['custom_field'] = array(); + $this->session->data['payment_address']['custom_field'] = []; if (isset($paypal_order_info['payer']['address']['country_code'])) { $country_info = $this->model_extension_payment_paypal->getCountryByCode($paypal_order_info['payer']['address']['country_code']); @@ -1351,7 +1351,7 @@ public function approveOrder() { $this->session->data['shipping_address']['address_format'] = ''; $this->session->data['shipping_address']['zone'] = ''; $this->session->data['shipping_address']['zone_id'] = 0; - $this->session->data['shipping_address']['custom_field'] = array(); + $this->session->data['shipping_address']['custom_field'] = []; if (isset($paypal_order_info['purchase_units'][0]['shipping']['address']['country_code'])) { $country_info = $this->model_extension_payment_paypal->getCountryByCode($paypal_order_info['purchase_units'][0]['shipping']['address']['country_code']); @@ -1471,30 +1471,30 @@ public function approveOrder() { } if ($payment_type == 'button') { - $this->session->data['payment_method'] = array( + $this->session->data['payment_method'] = [ 'code' => 'paypal', 'title' => $this->language->get('text_paypal_title'), 'terms' => '', 'sort_order' => $this->config->get('payment_paypal_sort_order') - ); + ]; } if ($payment_type == 'googlepay_button') { - $this->session->data['payment_method'] = array( + $this->session->data['payment_method'] = [ 'code' => 'paypal_googlepay', 'title' => $this->language->get('text_paypal_googlepay_title'), 'terms' => '', 'sort_order' => $this->config->get('payment_paypal_sort_order') - ); + ]; } if ($payment_type == 'applepay_button') { - $this->session->data['payment_method'] = array( + $this->session->data['payment_method'] = [ 'code' => 'paypal_applepay', 'title' => $this->language->get('text_paypal_applepay_title'), 'terms' => '', 'sort_order' => $this->config->get('payment_paypal_sort_order') - ); + ]; } $data['url'] = $this->url->link('extension/payment/paypal/confirmOrder', '', true); @@ -1508,7 +1508,7 @@ public function approveOrder() { $paypal_order_info = $paypal->getOrder($paypal_order_id); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -1584,7 +1584,7 @@ public function approveOrder() { } if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -1682,7 +1682,7 @@ public function approveOrder() { if (($authorization_status == 'CREATED') || ($authorization_status == 'DENIED') || ($authorization_status == 'PENDING')) { if ($payment_method == 'paypal') { - $paypal_customer_token = array(); + $paypal_customer_token = []; if ($setting['general']['vault_status'] && $this->customer->isLogged()) { $paypal_customer_token = $this->model_extension_payment_paypal->getPayPalCustomerMainToken($this->customer->getId(), $payment_method); @@ -1696,7 +1696,7 @@ public function approveOrder() { $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); - $paypal_order_data = array( + $paypal_order_data = [ 'order_id' => $this->session->data['order_id'], 'paypal_order_id' => $paypal_order_id, 'transaction_id' => $authorization_id, @@ -1711,7 +1711,7 @@ public function approveOrder() { 'total' => $order_info['total'], 'currency_code' => $order_info['currency_code'], 'environment' => $environment - ); + ]; $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); @@ -1721,7 +1721,7 @@ public function approveOrder() { $paypal_customer_token_info = $this->model_extension_payment_paypal->getPayPalCustomerToken($customer_id, $payment_method, $vault_id); if (!$paypal_customer_token_info) { - $paypal_customer_token_data = array( + $paypal_customer_token_data = [ 'customer_id' => $customer_id, 'payment_method' => $payment_method, 'vault_id' => $vault_id, @@ -1730,7 +1730,7 @@ public function approveOrder() { 'card_nice_type' => $card_nice_type, 'card_last_digits' => $card_last_digits, 'card_expiry' => $card_expiry - ); + ]; $this->model_extension_payment_paypal->addPayPalCustomerToken($paypal_customer_token_data); } @@ -1811,7 +1811,7 @@ public function approveOrder() { if (($capture_status == 'COMPLETED') || ($capture_status == 'DECLINED') || ($capture_status == 'PENDING')) { if ($payment_method == 'paypal') { - $paypal_customer_token = array(); + $paypal_customer_token = []; if ($setting['general']['vault_status'] && $this->customer->isLogged()) { $paypal_customer_token = $this->model_extension_payment_paypal->getPayPalCustomerMainToken($this->customer->getId(), $payment_method); @@ -1825,7 +1825,7 @@ public function approveOrder() { $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); - $paypal_order_data = array( + $paypal_order_data = [ 'order_id' => $this->session->data['order_id'], 'paypal_order_id' => $paypal_order_id, 'transaction_id' => $capture_id, @@ -1840,7 +1840,7 @@ public function approveOrder() { 'total' => $order_info['total'], 'currency_code' => $order_info['currency_code'], 'environment' => $environment - ); + ]; $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); @@ -1850,7 +1850,7 @@ public function approveOrder() { $paypal_customer_token_info = $this->model_extension_payment_paypal->getPayPalCustomerToken($customer_id, $payment_method, $vault_id); if (!$paypal_customer_token_info) { - $paypal_customer_token_data = array( + $paypal_customer_token_data = [ 'customer_id' => $customer_id, 'payment_method' => $payment_method, 'vault_id' => $vault_id, @@ -1859,7 +1859,7 @@ public function approveOrder() { 'card_nice_type' => $card_nice_type, 'card_last_digits' => $card_last_digits, 'card_expiry' => $card_expiry - ); + ]; $this->model_extension_payment_paypal->addPayPalCustomerToken($paypal_customer_token_data); } @@ -1946,22 +1946,22 @@ public function confirmOrder() { $data['heading_title'] = $this->language->get('text_paypal'); - $data['breadcrumbs'] = array(); + $data['breadcrumbs'] = []; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', '', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_cart'), 'href' => $this->url->link('checkout/cart', '', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_paypal'), 'href' => $this->url->link('extension/payment/paypal/confirmOrder', '', true) - ); + ]; $points_total = 0; @@ -1983,7 +1983,7 @@ public function confirmOrder() { $this->response->redirect($this->url->link('checkout/cart', '', true)); } - $data['products'] = array(); + $data['products'] = []; $products = $this->cart->getProducts(); @@ -2006,7 +2006,7 @@ public function confirmOrder() { $image = ''; } - $option_data = array(); + $option_data = []; foreach ($product['option'] as $option) { if ($option['type'] != 'file') { @@ -2021,10 +2021,10 @@ public function confirmOrder() { } } - $option_data[] = array( + $option_data[] = [ 'name' => $option['name'], 'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) - ); + ]; } // Display prices @@ -2041,13 +2041,13 @@ public function confirmOrder() { $recurring = ''; if ($product['recurring']) { - $frequencies = array( + $frequencies = [ 'day' => $this->language->get('text_day'), 'week' => $this->language->get('text_week'), 'semi_month' => $this->language->get('text_semi_month'), 'month' => $this->language->get('text_month'), 'year' => $this->language->get('text_year'), - ); + ]; if ($product['recurring']['trial']) { $recurring = sprintf($this->language->get('text_trial_description'), $this->currency->format($this->tax->calculate($product['recurring']['trial_price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']), $product['recurring']['trial_cycle'], $frequencies[$product['recurring']['trial_frequency']], $product['recurring']['trial_duration']) . ' '; @@ -2060,33 +2060,33 @@ public function confirmOrder() { } } - $data['products'][] = array( - 'cart_id' => $product['cart_id'], - 'thumb' => $image, - 'name' => $product['name'], - 'model' => $product['model'], - 'option' => $option_data, - 'recurring' => $recurring, - 'quantity' => $product['quantity'], - 'stock' => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')), - 'reward' => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''), - 'price' => $price, - 'total' => $total, - 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id'], true) - ); + $data['products'][] = [ + 'cart_id' => $product['cart_id'], + 'thumb' => $image, + 'name' => $product['name'], + 'model' => $product['model'], + 'option' => $option_data, + 'recurring' => $recurring, + 'quantity' => $product['quantity'], + 'stock' => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')), + 'reward' => ($product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : ''), + 'price' => $price, + 'total' => $total, + 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id'], true) + ]; } // Gift Voucher - $data['vouchers'] = array(); + $data['vouchers'] = []; if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $key => $voucher) { - $data['vouchers'][] = array( + $data['vouchers'][] = [ 'key' => $key, 'description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount'], $this->session->data['currency']), 'remove' => $this->url->link('checkout/cart', 'remove=' . $key, true) - ); + ]; } } @@ -2095,11 +2095,11 @@ public function confirmOrder() { if ($this->cart->hasShipping()) { $data['has_shipping'] = true; - $data['shipping_address'] = isset($this->session->data['shipping_address']) ? $this->session->data['shipping_address'] : array(); + $data['shipping_address'] = isset($this->session->data['shipping_address']) ? $this->session->data['shipping_address'] : []; if (!empty($data['shipping_address'])) { // Shipping Methods - $quote_data = array(); + $quote_data = []; $results = $this->model_setting_extension->getExtensions('shipping'); @@ -2111,18 +2111,18 @@ public function confirmOrder() { $quote = $this->{'model_extension_shipping_' . $result['code']}->getQuote($data['shipping_address']); if ($quote) { - $quote_data[$result['code']] = array( + $quote_data[$result['code']] = [ 'title' => $quote['title'], 'quote' => $quote['quote'], 'sort_order' => $quote['sort_order'], 'error' => $quote['error'] - ); + ]; } } } if (!empty($quote_data)) { - $sort_order = array(); + $sort_order = []; foreach ($quote_data as $key => $value) { $sort_order[$key] = $value['sort_order']; @@ -2159,24 +2159,24 @@ public function confirmOrder() { $data['has_shipping'] = false; } - $data['guest'] = isset($this->session->data['guest']) ? $this->session->data['guest'] : array(); - $data['payment_address'] = isset($this->session->data['payment_address']) ? $this->session->data['payment_address'] : array(); + $data['guest'] = isset($this->session->data['guest']) ? $this->session->data['guest'] : []; + $data['payment_address'] = isset($this->session->data['payment_address']) ? $this->session->data['payment_address'] : []; // Totals - $totals = array(); + $totals = []; $taxes = $this->cart->getTaxes(); $total = 0; // Because __call can not keep var references so we put them into an array. - $total_data = array( + $total_data = [ 'totals' => &$totals, 'taxes' => &$taxes, 'total' => &$total - ); + ]; // Display prices if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { - $sort_order = array(); + $sort_order = []; $results = $this->model_setting_extension->getExtensions('total'); @@ -2195,7 +2195,7 @@ public function confirmOrder() { } } - $sort_order = array(); + $sort_order = []; foreach ($totals as $key => $value) { $sort_order[$key] = $value['sort_order']; @@ -2207,7 +2207,7 @@ public function confirmOrder() { /** * Payment methods */ - $method_data = array(); + $method_data = []; $results = $this->model_setting_extension->getExtensions('payment'); @@ -2223,7 +2223,7 @@ public function confirmOrder() { } } - $sort_order = array(); + $sort_order = []; foreach ($method_data as $key => $value) { $sort_order[$key] = $value['sort_order']; @@ -2254,20 +2254,20 @@ public function confirmOrder() { $data['custom_fields'] = $this->model_account_custom_field->getCustomFields(); // Totals - $totals = array(); + $totals = []; $taxes = $this->cart->getTaxes(); $total = 0; // Because __call can not keep var references so we put them into an array. - $total_data = array( + $total_data = [ 'totals' => &$totals, 'taxes' => &$taxes, 'total' => &$total - ); + ]; // Display prices if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { - $sort_order = array(); + $sort_order = []; $results = $this->model_setting_extension->getExtensions('total'); @@ -2286,7 +2286,7 @@ public function confirmOrder() { } } - $sort_order = array(); + $sort_order = []; foreach ($totals as $key => $value) { $sort_order[$key] = $value['sort_order']; @@ -2295,13 +2295,13 @@ public function confirmOrder() { array_multisort($sort_order, SORT_ASC, $totals); } - $data['totals'] = array(); + $data['totals'] = []; foreach ($totals as $total) { - $data['totals'][] = array( + $data['totals'][] = [ 'title' => $total['title'], 'text' => $this->currency->format($total['value'], $this->session->data['currency']), - ); + ]; } $data['action_confirm'] = $this->url->link('extension/payment/paypal/completeOrder', '', true); @@ -2376,22 +2376,22 @@ public function completeOrder() { } if (isset($this->session->data['paypal_order_id'])) { - $order_data = array(); + $order_data = []; - $totals = array(); + $totals = []; $taxes = $this->cart->getTaxes(); $total = 0; // Because __call can not keep var references so we put them into an array. - $total_data = array( + $total_data = [ 'totals' => &$totals, 'taxes' => &$taxes, 'total' => &$total - ); + ]; $this->load->model('setting/extension'); - $sort_order = array(); + $sort_order = []; $results = $this->model_setting_extension->getExtensions('total'); @@ -2410,7 +2410,7 @@ public function completeOrder() { } } - $sort_order = array(); + $sort_order = []; foreach ($totals as $key => $value) { $sort_order[$key] = $value['sort_order']; @@ -2459,7 +2459,7 @@ public function completeOrder() { $order_data['payment_country'] = $this->session->data['payment_address']['country']; $order_data['payment_country_id'] = $this->session->data['payment_address']['country_id']; $order_data['payment_address_format'] = $this->session->data['payment_address']['address_format']; - $order_data['payment_custom_field'] = (isset($this->session->data['payment_address']['custom_field']) ? $this->session->data['payment_address']['custom_field'] : array()); + $order_data['payment_custom_field'] = (isset($this->session->data['payment_address']['custom_field']) ? $this->session->data['payment_address']['custom_field'] : []); if (isset($this->session->data['payment_method']['title'])) { $order_data['payment_method'] = $this->session->data['payment_method']['title']; @@ -2486,7 +2486,7 @@ public function completeOrder() { $order_data['shipping_country'] = $this->session->data['shipping_address']['country']; $order_data['shipping_country_id'] = $this->session->data['shipping_address']['country_id']; $order_data['shipping_address_format'] = $this->session->data['shipping_address']['address_format']; - $order_data['shipping_custom_field'] = (isset($this->session->data['shipping_address']['custom_field']) ? $this->session->data['shipping_address']['custom_field'] : array()); + $order_data['shipping_custom_field'] = (isset($this->session->data['shipping_address']['custom_field']) ? $this->session->data['shipping_address']['custom_field'] : []); if (isset($this->session->data['shipping_method']['title'])) { $order_data['shipping_method'] = $this->session->data['shipping_method']['title']; @@ -2512,18 +2512,18 @@ public function completeOrder() { $order_data['shipping_country'] = ''; $order_data['shipping_country_id'] = 0; $order_data['shipping_address_format'] = ''; - $order_data['shipping_custom_field'] = array(); + $order_data['shipping_custom_field'] = []; $order_data['shipping_method'] = ''; $order_data['shipping_code'] = ''; } - $order_data['products'] = array(); + $order_data['products'] = []; foreach ($this->cart->getProducts() as $product) { - $option_data = array(); + $option_data = []; foreach ($product['option'] as $option) { - $option_data[] = array( + $option_data[] = [ 'product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'option_id' => $option['option_id'], @@ -2531,10 +2531,10 @@ public function completeOrder() { 'name' => $option['name'], 'value' => $option['value'], 'type' => $option['type'] - ); + ]; } - $order_data['products'][] = array( + $order_data['products'][] = [ 'product_id' => $product['product_id'], 'name' => $product['name'], 'model' => $product['model'], @@ -2546,15 +2546,15 @@ public function completeOrder() { 'total' => $product['total'], 'tax' => $this->tax->getTax($product['price'], $product['tax_class_id']), 'reward' => $product['reward'] - ); + ]; } // Gift Voucher - $order_data['vouchers'] = array(); + $order_data['vouchers'] = []; if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $voucher) { - $order_data['vouchers'][] = array( + $order_data['vouchers'][] = [ 'description' => $voucher['description'], 'code' => token(10), 'to_name' => $voucher['to_name'], @@ -2564,7 +2564,7 @@ public function completeOrder() { 'voucher_theme_id' => $voucher['voucher_theme_id'], 'message' => $voucher['message'], 'amount' => $voucher['amount'] - ); + ]; } } @@ -2665,19 +2665,19 @@ public function completeOrder() { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); @@ -2686,7 +2686,7 @@ public function completeOrder() { $paypal_order_info = $paypal->getOrder($paypal_order_id); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -2711,29 +2711,29 @@ public function completeOrder() { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } - $shipping_info_name = array(); - $shipping_info_address = array(); + $shipping_info_name = []; + $shipping_info_address = []; if ($paypal_order_info && !$this->error) { - $shipping_info_name = (isset($paypal_order_info['purchase_units'][0]['shipping']['name']) ? $paypal_order_info['purchase_units'][0]['shipping']['name'] : array()); - $shipping_info_address = (isset($paypal_order_info['purchase_units'][0]['shipping']['address']) ? $paypal_order_info['purchase_units'][0]['shipping']['address'] : array()); + $shipping_info_name = (isset($paypal_order_info['purchase_units'][0]['shipping']['name']) ? $paypal_order_info['purchase_units'][0]['shipping']['name'] : []); + $shipping_info_address = (isset($paypal_order_info['purchase_units'][0]['shipping']['address']) ? $paypal_order_info['purchase_units'][0]['shipping']['address'] : []); } - $paypal_order_info = array(); + $paypal_order_info = []; - $paypal_order_info[] = array( + $paypal_order_info[] = [ 'op' => 'add', 'path' => '/purchase_units/@reference_id==\'default\'/description', 'value' => 'Your order ' . $this->session->data['order_id'] - ); + ]; - $paypal_order_info[] = array( + $paypal_order_info[] = [ 'op' => 'add', 'path' => '/purchase_units/@reference_id==\'default\'/invoice_id', 'value' => $this->session->data['order_id'] . '_' . date('Ymd_His') - ); + ]; - $shipping_info = array(); + $shipping_info = []; if ($this->cart->hasShipping()) { $shipping_info['name']['full_name'] = (isset($this->session->data['shipping_address']['firstname']) ? $this->session->data['shipping_address']['firstname'] : ''); @@ -2755,31 +2755,31 @@ public function completeOrder() { } if ($shipping_info_name) { - $paypal_order_info[] = array( + $paypal_order_info[] = [ 'op' => 'replace', 'path' => '/purchase_units/@reference_id==\'default\'/shipping/name', 'value' => $shipping_info['name'] - ); + ]; } else { - $paypal_order_info[] = array( + $paypal_order_info[] = [ 'op' => 'add', 'path' => '/purchase_units/@reference_id==\'default\'/shipping/name', 'value' => $shipping_info['name'] - ); + ]; } if ($shipping_info_address) { - $paypal_order_info[] = array( + $paypal_order_info[] = [ 'op' => 'replace', 'path' => '/purchase_units/@reference_id==\'default\'/shipping/address', 'value' => $shipping_info['address'] - ); + ]; } else { - $paypal_order_info[] = array( + $paypal_order_info[] = [ 'op' => 'add', 'path' => '/purchase_units/@reference_id==\'default\'/shipping/address', 'value' => $shipping_info['address'] - ); + ]; } } @@ -2828,46 +2828,46 @@ public function completeOrder() { $handling_total = -$rebate; } - $amount_info = array(); + $amount_info = []; $amount_info['currency_code'] = $currency_code; $amount_info['value'] = $order_total; - $amount_info['breakdown']['item_total'] = array( + $amount_info['breakdown']['item_total'] = [ 'currency_code' => $currency_code, 'value' => $item_total - ); + ]; - $amount_info['breakdown']['tax_total'] = array( + $amount_info['breakdown']['tax_total'] = [ 'currency_code' => $currency_code, 'value' => $tax_total - ); + ]; - $amount_info['breakdown']['shipping'] = array( + $amount_info['breakdown']['shipping'] = [ 'currency_code' => $currency_code, 'value' => $shipping_total - ); + ]; - $amount_info['breakdown']['handling'] = array( + $amount_info['breakdown']['handling'] = [ 'currency_code' => $currency_code, 'value' => $handling_total - ); + ]; - $amount_info['breakdown']['discount'] = array( + $amount_info['breakdown']['discount'] = [ 'currency_code' => $currency_code, 'value' => $discount_total - ); + ]; - $paypal_order_info[] = array( + $paypal_order_info[] = [ 'op' => 'replace', 'path' => '/purchase_units/@reference_id==\'default\'/amount', 'value' => $amount_info - ); + ]; $result = $paypal->updateOrder($paypal_order_id, $paypal_order_info); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -2900,7 +2900,7 @@ public function completeOrder() { } if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -2994,7 +2994,7 @@ public function completeOrder() { if (($authorization_status == 'CREATED') || ($authorization_status == 'DENIED') || ($authorization_status == 'PENDING')) { if ($payment_method == 'paypal') { - $paypal_customer_token = array(); + $paypal_customer_token = []; if ($setting['general']['vault_status'] && $this->customer->isLogged()) { $paypal_customer_token = $this->model_extension_payment_paypal->getPayPalCustomerMainToken($this->customer->getId(), $payment_method); @@ -3008,7 +3008,7 @@ public function completeOrder() { $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); - $paypal_order_data = array( + $paypal_order_data = [ 'order_id' => $this->session->data['order_id'], 'paypal_order_id' => $paypal_order_id, 'transaction_id' => $authorization_id, @@ -3023,7 +3023,7 @@ public function completeOrder() { 'total' => $order_data['total'], 'currency_code' => $order_data['currency_code'], 'environment' => $environment - ); + ]; $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); @@ -3033,7 +3033,7 @@ public function completeOrder() { $paypal_customer_token_info = $this->model_extension_payment_paypal->getPayPalCustomerToken($customer_id, $payment_method, $vault_id); if (!$paypal_customer_token_info) { - $paypal_customer_token_data = array( + $paypal_customer_token_data = [ 'customer_id' => $customer_id, 'payment_method' => $payment_method, 'vault_id' => $vault_id, @@ -3042,7 +3042,7 @@ public function completeOrder() { 'card_nice_type' => $card_nice_type, 'card_last_digits' => $card_last_digits, 'card_expiry' => $card_expiry, - ); + ]; $this->model_extension_payment_paypal->addPayPalCustomerToken($paypal_customer_token_data); } @@ -3123,7 +3123,7 @@ public function completeOrder() { if (($capture_status == 'COMPLETED') || ($capture_status == 'DECLINED') || ($capture_status == 'PENDING')) { if ($payment_method == 'paypal') { - $paypal_customer_token = array(); + $paypal_customer_token = []; if ($setting['general']['vault_status'] && $this->customer->isLogged()) { $paypal_customer_token = $this->model_extension_payment_paypal->getPayPalCustomerMainToken($this->customer->getId(), $payment_method); @@ -3137,7 +3137,7 @@ public function completeOrder() { $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); - $paypal_order_data = array( + $paypal_order_data = [ 'order_id' => $this->session->data['order_id'], 'paypal_order_id' => $paypal_order_id, 'transaction_id' => $capture_id, @@ -3152,7 +3152,7 @@ public function completeOrder() { 'total' => $order_data['total'], 'currency_code' => $order_data['currency_code'], 'environment' => $environment - ); + ]; $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); @@ -3162,7 +3162,7 @@ public function completeOrder() { $paypal_customer_token_info = $this->model_extension_payment_paypal->getPayPalCustomerToken($customer_id, $payment_method, $vault_id); if (!$paypal_customer_token_info) { - $paypal_customer_token_data = array( + $paypal_customer_token_data = [ 'customer_id' => $customer_id, 'payment_method' => $payment_method, 'vault_id' => $vault_id, @@ -3171,7 +3171,7 @@ public function completeOrder() { 'card_nice_type' => $card_nice_type, 'card_last_digits' => $card_last_digits, 'card_expiry' => $card_expiry, - ); + ]; $this->model_extension_payment_paypal->addPayPalCustomerToken($paypal_customer_token_data); } @@ -3211,8 +3211,8 @@ public function completeOrder() { public function paymentAddress() { $this->load->language('extension/payment/paypal'); - $data['guest'] = isset($this->session->data['guest']) ? $this->session->data['guest'] : array(); - $data['payment_address'] = isset($this->session->data['payment_address']) ? $this->session->data['payment_address'] : array(); + $data['guest'] = isset($this->session->data['guest']) ? $this->session->data['guest'] : []; + $data['payment_address'] = isset($this->session->data['payment_address']) ? $this->session->data['payment_address'] : []; $this->load->model('localisation/country'); @@ -3228,7 +3228,7 @@ public function paymentAddress() { public function shippingAddress() { $this->load->language('extension/payment/paypal'); - $data['shipping_address'] = isset($this->session->data['shipping_address']) ? $this->session->data['shipping_address'] : array(); + $data['shipping_address'] = isset($this->session->data['shipping_address']) ? $this->session->data['shipping_address'] : []; $this->load->model('localisation/country'); @@ -3261,7 +3261,7 @@ public function confirmPaymentAddress() { if (isset($this->request->post['custom_field']['account'])) { $this->session->data['guest']['custom_field'] = $this->request->post['custom_field']['account']; } else { - $this->session->data['guest']['custom_field'] = array(); + $this->session->data['guest']['custom_field'] = []; } $this->session->data['payment_address']['firstname'] = $this->request->post['firstname']; @@ -3293,7 +3293,7 @@ public function confirmPaymentAddress() { if (isset($this->request->post['custom_field']['address'])) { $this->session->data['payment_address']['custom_field'] = $this->request->post['custom_field']['address']; } else { - $this->session->data['payment_address']['custom_field'] = array(); + $this->session->data['payment_address']['custom_field'] = []; } $this->load->model('localisation/zone'); @@ -3362,7 +3362,7 @@ public function confirmShippingAddress() { if (isset($this->request->post['custom_field'])) { $this->session->data['shipping_address']['custom_field'] = $this->request->post['custom_field']['address']; } else { - $this->session->data['shipping_address']['custom_field'] = array(); + $this->session->data['shipping_address']['custom_field'] = []; } $data['url'] = $this->url->link('extension/payment/paypal/confirmOrder', '', true); @@ -3403,26 +3403,26 @@ public function deleteCustomerToken() { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $result = $paypal->setAccessToken($token_info); $result = $paypal->deletePaymentToken($vault_id); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -3532,26 +3532,26 @@ public function callback() { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $paypal_order_info = $paypal->getOrder($paypal_order_id); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -3626,7 +3626,7 @@ public function callback() { } if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -3709,7 +3709,7 @@ public function callback() { if (($authorization_status == 'CREATED') || ($authorization_status == 'DENIED') || ($authorization_status == 'PENDING')) { $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); - $paypal_order_data = array( + $paypal_order_data = [ 'order_id' => $this->session->data['order_id'], 'paypal_order_id' => $paypal_order_id, 'transaction_id' => $authorization_id, @@ -3724,7 +3724,7 @@ public function callback() { 'total' => $order_info['total'], 'currency_code' => $order_info['currency_code'], 'environment' => $environment - ); + ]; $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); @@ -3734,7 +3734,7 @@ public function callback() { $paypal_customer_token_info = $this->model_extension_payment_paypal->getPayPalCustomerToken($customer_id, $payment_method, $vault_id); if (!$paypal_customer_token_info) { - $paypal_customer_token_data = array( + $paypal_customer_token_data = [ 'customer_id' => $customer_id, 'payment_method' => $payment_method, 'vault_id' => $vault_id, @@ -3743,7 +3743,7 @@ public function callback() { 'card_nice_type' => $card_nice_type, 'card_last_digits' => $card_last_digits, 'card_expiry' => $card_expiry - ); + ]; $this->model_extension_payment_paypal->addPayPalCustomerToken($paypal_customer_token_data); } @@ -3810,7 +3810,7 @@ public function callback() { if (($capture_status == 'COMPLETED') || ($capture_status == 'DECLINED') || ($capture_status == 'PENDING')) { $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); - $paypal_order_data = array( + $paypal_order_data = [ 'order_id' => $this->session->data['order_id'], 'paypal_order_id' => $paypal_order_id, 'transaction_id' => $capture_id, @@ -3825,7 +3825,7 @@ public function callback() { 'total' => $order_info['total'], 'currency_code' => $order_info['currency_code'], 'environment' => $environment - ); + ]; $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); @@ -3835,7 +3835,7 @@ public function callback() { $paypal_customer_token_info = $this->model_extension_payment_paypal->getPayPalCustomerToken($customer_id, $payment_method, $vault_id); if (!$paypal_customer_token_info) { - $paypal_customer_token_data = array( + $paypal_customer_token_data = [ 'customer_id' => $customer_id, 'payment_method' => $payment_method, 'vault_id' => $vault_id, @@ -3844,7 +3844,7 @@ public function callback() { 'card_nice_type' => $card_nice_type, 'card_last_digits' => $card_last_digits, 'card_expiry' => $card_expiry - ); + ]; $this->model_extension_payment_paypal->addPayPalCustomerToken($paypal_customer_token_data); } @@ -3872,22 +3872,22 @@ public function callback() { $this->document->setTitle($this->language->get('text_failure_page_title')); - $data['breadcrumbs'] = array(); + $data['breadcrumbs'] = []; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', '', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_cart'), 'href' => $this->url->link('checkout/cart', '', true) - ); + ]; - $data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = [ 'text' => $this->language->get('text_paypal'), 'href' => $this->url->link('extension/payment/paypal/callback', '', true) - ); + ]; $data['text_title'] = $this->language->get('text_failure_page_title'); $data['text_message'] = sprintf($this->language->get('text_failure_page_message'), $this->url->link('information/contact', '', true)); @@ -3943,19 +3943,19 @@ public function webhook() { require_once DIR_SYSTEM .'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); @@ -3964,12 +3964,12 @@ public function webhook() { while ($webhook_repeat) { $webhook_event = $paypal->getWebhookEvent($webhook_event_id); - $errors = array(); + $errors = []; $webhook_repeat = 0; if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -4054,7 +4054,7 @@ public function webhook() { if (isset($webhook_event['resource']['id']) && $transaction_status) { $transaction_id = $webhook_event['resource']['id']; - $paypal_order_data = array(); + $paypal_order_data = []; $paypal_order_data['order_id'] = $order_id; $paypal_order_data['transaction_status'] = $transaction_status; @@ -4083,13 +4083,13 @@ public function webhook() { $card_last_digits = (isset($webhook_event['resource']['payment_source']['card']['last_digits']) ? $webhook_event['resource']['payment_source']['card']['last_digits'] : ''); $card_expiry = (isset($webhook_event['resource']['payment_source']['card']['expiry']) ? $webhook_event['resource']['payment_source']['card']['expiry'] : ''); - $paypal_order_data = array( + $paypal_order_data = [ 'order_id' => $order_id, 'vault_id' => $vault_id, 'vault_customer_id' => $vault_customer_id, 'card_last_digits' => $card_last_digits, 'card_expiry' => $card_expiry - ); + ]; $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); @@ -4101,7 +4101,7 @@ public function webhook() { $paypal_customer_token_info = $this->model_extension_payment_paypal->getPayPalCustomerToken($customer_id, $payment_method, $vault_id); if (!$paypal_customer_token_info) { - $paypal_customer_token_data = array( + $paypal_customer_token_data = [ 'customer_id' => $customer_id, 'payment_method' => $payment_method, 'vault_id' => $vault_id, @@ -4110,7 +4110,7 @@ public function webhook() { 'card_nice_type' => $card_nice_type, 'card_last_digits' => $card_last_digits, 'card_expiry' => $card_expiry - ); + ]; $this->model_extension_payment_paypal->addPayPalCustomerToken($paypal_customer_token_data); } @@ -4175,7 +4175,7 @@ public function header_before($route, &$data) { $route = 'common/home'; } - $params = array(); + $params = []; if (($route == 'common/home') && $setting['message']['home']['status']) { $params['page_code'] = 'home'; @@ -4242,31 +4242,31 @@ public function extension_get_extensions_after($route, $data, &$output) { if (!empty($setting['paylater_country'][$setting['general']['country_code']]) && ($currency_code == $setting['general']['currency_code']) && ($setting['button']['checkout']['funding']['paylater'] != 2)) { $this->config->set('payment_paypal_paylater_status', 1); - $output[] = array( + $output[] = [ 'extension_id' => 0, 'type' => 'payment', 'code' => 'paypal_paylater' - ); + ]; } if ($setting['googlepay_button']['checkout']['status']) { $this->config->set('payment_paypal_googlepay_status', 1); - $output[] = array( + $output[] = [ 'extension_id' => 0, 'type' => 'payment', 'code' => 'paypal_googlepay' - ); + ]; } if ($setting['applepay_button']['checkout']['status'] && $this->isApple()) { $this->config->set('payment_paypal_applepay_status', 1); - $output[] = array( + $output[] = [ 'extension_id' => 0, 'type' => 'payment', 'code' => 'paypal_applepay' - ); + ]; } } } @@ -4362,7 +4362,7 @@ private function validatePaymentAddress() { foreach ($custom_fields as $custom_field) { if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) { $this->error['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); - } elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) { + } elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $custom_field['validation']]])) { $this->error['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); } } @@ -4419,7 +4419,7 @@ private function validateShippingAddress() { if ($custom_field['location'] == 'address') { if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) { $this->error['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); - } elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) { + } elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $custom_field['validation']]])) { $this->error['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); } } @@ -4494,7 +4494,7 @@ 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'); + $apple_agents = ['ipod', 'iphone', 'ipad', 'apple']; foreach ($apple_agents as $apple_agent){ if (stripos($user_agent, $apple_agent)) { @@ -4507,7 +4507,7 @@ private function isApple() { } private function unserialize($str) { - $data = array(); + $data = []; $str = str_replace('&', '&', $str); diff --git a/upload/catalog/controller/extension/payment/paypal_applepay.php b/upload/catalog/controller/extension/payment/paypal_applepay.php index fb370ec64..ecfb4ac2e 100644 --- a/upload/catalog/controller/extension/payment/paypal_applepay.php +++ b/upload/catalog/controller/extension/payment/paypal_applepay.php @@ -1,6 +1,6 @@ load->model('extension/payment/paypal'); @@ -32,26 +32,26 @@ public function index() { require_once DIR_SYSTEM .'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $data['partner_id'], 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -108,26 +108,26 @@ public function modal() { require_once DIR_SYSTEM .'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $data['partner_id'], 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); diff --git a/upload/catalog/controller/extension/payment/paypal_googlepay.php b/upload/catalog/controller/extension/payment/paypal_googlepay.php index 6aef9a4d4..29eef611c 100644 --- a/upload/catalog/controller/extension/payment/paypal_googlepay.php +++ b/upload/catalog/controller/extension/payment/paypal_googlepay.php @@ -1,6 +1,6 @@ load->model('extension/payment/paypal'); @@ -32,26 +32,26 @@ public function index() { require_once DIR_SYSTEM .'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $data['partner_id'], 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -108,26 +108,26 @@ public function modal() { require_once DIR_SYSTEM .'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $data['partner_id'], 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); diff --git a/upload/catalog/controller/extension/payment/paypal_paylater.php b/upload/catalog/controller/extension/payment/paypal_paylater.php index c53a9e1e3..6157da322 100644 --- a/upload/catalog/controller/extension/payment/paypal_paylater.php +++ b/upload/catalog/controller/extension/payment/paypal_paylater.php @@ -1,6 +1,6 @@ load->model('extension/payment/paypal'); @@ -32,26 +32,26 @@ public function index() { require_once DIR_SYSTEM .'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $data['partner_id'], 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); @@ -108,26 +108,26 @@ public function modal() { require_once DIR_SYSTEM .'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $data['partner_id'], 'client_id' => $data['client_id'], 'secret' => $data['secret'], 'environment' => $data['environment'], 'partner_attribution_id' => $data['partner_attribution_id'] - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); $data['client_token'] = $paypal->getClientToken(); if ($paypal->hasErrors()) { - $error_messages = array(); + $error_messages = []; $errors = $paypal->getErrors(); diff --git a/upload/catalog/controller/extension/recurring/paypal.php b/upload/catalog/controller/extension/recurring/paypal.php index 7fded88a1..664dfab54 100644 --- a/upload/catalog/controller/extension/recurring/paypal.php +++ b/upload/catalog/controller/extension/recurring/paypal.php @@ -1,6 +1,6 @@ getAgreeStatus(); @@ -22,19 +22,19 @@ public function getMethod($address, $total) { } if ($status) { - $method_data = array( + $method_data = [ 'code' => 'paypal', 'title' => $this->language->get('text_paypal_title'), 'terms' => '', 'sort_order' => $this->config->get('payment_paypal_sort_order') - ); + ]; } } return $method_data; } - public function hasProductInCart($product_id, $option = array(), $recurring_id = 0) { + public function hasProductInCart($product_id, $option = [], $recurring_id = 0) { $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "cart WHERE api_id = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND customer_id = '" . (int)$this->customer->getId() . "' AND session_id = '" . $this->db->escape($this->session->getId()) . "' AND product_id = '" . (int)$product_id . "' AND recurring_id = '" . (int)$recurring_id . "' AND `option` = '" . $this->db->escape(json_encode($option)) . "'"); return $query->row['total']; @@ -55,7 +55,7 @@ public function getZoneByCode($country_id, $code) { public function addPayPalCustomerToken($data) { $sql = "INSERT INTO `" . DB_PREFIX . "paypal_checkout_integration_customer_token` SET"; - $implode = array(); + $implode = []; if (!empty($data['customer_id'])) { $implode[] = "`customer_id` = '" . (int)$data['customer_id'] . "'"; @@ -111,7 +111,7 @@ public function getPayPalCustomerMainToken($customer_id, $payment_method) { if ($query->num_rows) { return $query->row; } else { - return array(); + return []; } } @@ -121,7 +121,7 @@ public function getPayPalCustomerToken($customer_id, $payment_method, $vault_id) if ($query->num_rows) { return $query->row; } else { - return array(); + return []; } } @@ -135,14 +135,14 @@ public function getPayPalCustomerTokens($customer_id, $payment_method = '') { if ($query->num_rows) { return $query->rows; } else { - return array(); + return []; } } public function addPayPalOrder($data) { $sql = "INSERT INTO `" . DB_PREFIX . "paypal_checkout_integration_order` SET"; - $implode = array(); + $implode = []; if (!empty($data['order_id'])) { $implode[] = "`order_id` = '" . (int)$data['order_id'] . "'"; @@ -218,7 +218,7 @@ public function addPayPalOrder($data) { public function editPayPalOrder($data) { $sql = "UPDATE `" . DB_PREFIX . "paypal_checkout_integration_order` SET"; - $implode = array(); + $implode = []; if (!empty($data['paypal_order_id'])) { $implode[] = "`paypal_order_id` = '" . $this->db->escape($data['paypal_order_id']) . "'"; @@ -354,7 +354,7 @@ public function deleteOrderRecurring($order_id) { public function getOrderRecurrings() { $query = $this->db->query("SELECT `or`.`order_recurring_id` FROM `" . DB_PREFIX . "order_recurring` `or` JOIN `" . DB_PREFIX . "order` `o` USING(`order_id`) WHERE `o`.`payment_code` = 'paypal' AND `or`.`status` = '1'"); - $order_recurring_data = array(); + $order_recurring_data = []; foreach ($query->rows as $order_recurring) { $order_recurring_data[] = $this->getOrderRecurring($order_recurring['order_recurring_id']); @@ -459,35 +459,35 @@ public function recurringPayment($product_data, $order_data, $paypal_order_data) } if ($transaction_id && $transaction_status && $currency_code && $amount) { - $paypal_order_recurring_data = array( + $paypal_order_recurring_data = [ 'order_recurring_id' => $order_recurring_id, 'order_id' => $order_data['order_id'], 'trial_end' => date_format($trial_end, 'Y-m-d H:i:s'), 'subscription_end' => date_format($subscription_end, 'Y-m-d H:i:s'), 'currency_code' => $currency_code, 'amount' => $amount - ); + ]; $this->addPayPalOrderRecurring($paypal_order_recurring_data); if (($transaction_status == 'CREATED') || ($transaction_status == 'COMPLETED') || ($transaction_status == 'PENDING')) { - $order_recurring_transaction_data = array( + $order_recurring_transaction_data = [ 'order_recurring_id' => $order_recurring_id, 'reference' => $transaction_id, 'type' => '1', 'amount' => $amount - ); + ]; $this->addOrderRecurringTransaction($order_recurring_transaction_data); $this->editPayPalOrderRecurringNextPayment($order_recurring_id, date_format($next_payment, 'Y-m-d H:i:s')); } else { - $order_recurring_transaction_data = array( + $order_recurring_transaction_data = [ 'order_recurring_id' => $order_recurring_id, 'reference' => $transaction_id, 'type' => '4', 'amount' => $amount - ); + ]; $this->addOrderRecurringTransaction($order_recurring_transaction_data); } @@ -564,23 +564,23 @@ public function cronPayment() { if ($transaction_id && $transaction_status && $currency_code && $amount) { if (($transaction_status == 'CREATED') || ($transaction_status == 'COMPLETED') || ($transaction_status == 'PENDING')) { - $order_recurring_transaction_data = array( + $order_recurring_transaction_data = [ 'order_recurring_id' => $order_recurring['order_recurring_id'], 'reference' => $transaction_id, 'type' => '1', 'amount' => $amount - ); + ]; $this->addOrderRecurringTransaction($order_recurring_transaction_data); $this->editPayPalOrderRecurringNextPayment($order_recurring['order_recurring_id'], date_format($next_payment, 'Y-m-d H:i:s')); } else { - $order_recurring_transaction_data = array( + $order_recurring_transaction_data = [ 'order_recurring_id' => $order_recurring['order_recurring_id'], 'reference' => $transaction_id, 'type' => '4', 'amount' => $amount - ); + ]; $this->addOrderRecurringTransaction($order_recurring_transaction_data); } @@ -615,53 +615,53 @@ public function createPayment($order_data, $paypal_order_data, $price, $order_re require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - $paypal_info = array( + $paypal_info = [ 'partner_id' => $partner_id, 'client_id' => $client_id, 'secret' => $secret, 'environment' => $environment, 'partner_attribution_id' => $partner_attribution_id - ); + ]; $paypal = new PayPal($paypal_info); - $token_info = array( + $token_info = [ 'grant_type' => 'client_credentials' - ); + ]; $paypal->setAccessToken($token_info); - $item_info = array(); + $item_info = []; $item_total = 0; $product_price = number_format($price * $currency_value, $decimal_place, '.', ''); - $item_info[] = array( + $item_info[] = [ 'name' => $recurring_name, 'quantity' => 1, - 'unit_amount' => array( + 'unit_amount' => [ 'currency_code' => $currency_code, 'value' => $product_price - ) - ); + ] + ]; $item_total += $product_price; $item_total = number_format($item_total, $decimal_place, '.', ''); $order_total = number_format($item_total, $decimal_place, '.', ''); - $amount_info = array(); + $amount_info = []; $amount_info['currency_code'] = $currency_code; $amount_info['value'] = $order_total; - $amount_info['breakdown']['item_total'] = array( + $amount_info['breakdown']['item_total'] = [ 'currency_code' => $currency_code, 'value' => $item_total - ); + ]; - $paypal_order_info = array(); + $paypal_order_info = []; $paypal_order_info['intent'] = strtoupper($transaction_method); $paypal_order_info['purchase_units'][0]['reference_id'] = 'default'; @@ -685,7 +685,7 @@ public function createPayment($order_data, $paypal_order_data, $price, $order_re $result = $paypal->createOrder($paypal_order_info); - $errors = array(); + $errors = []; if ($paypal->hasErrors()) { $errors = $paypal->getErrors(); @@ -810,7 +810,7 @@ public function update() { $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'"); if ($this->config->get('paypal_version') < '3.1.0') { - $setting = array(); + $setting = []; $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "setting` WHERE store_id = '0' AND `key` = 'payment_paypal_setting'"); diff --git a/upload/catalog/model/extension/payment/paypal_applepay.php b/upload/catalog/model/extension/payment/paypal_applepay.php index df387171e..e42eb9ff8 100644 --- a/upload/catalog/model/extension/payment/paypal_applepay.php +++ b/upload/catalog/model/extension/payment/paypal_applepay.php @@ -2,7 +2,7 @@ class ModelExtensionPaymentPayPalApplePay extends Model { public function getMethod($address, $total) { - $method_data = array(); + $method_data = []; $this->load->model('extension/payment/paypal'); @@ -24,12 +24,12 @@ public function getMethod($address, $total) { } if ($status) { - $method_data = array( + $method_data = [ 'code' => 'paypal_applepay', 'title' => $this->language->get('text_paypal_applepay_title'), 'terms' => '', 'sort_order' => $this->config->get('payment_paypal_sort_order') - ); + ]; } } diff --git a/upload/catalog/model/extension/payment/paypal_googlepay.php b/upload/catalog/model/extension/payment/paypal_googlepay.php index a1a7e91e7..a07c35eb6 100644 --- a/upload/catalog/model/extension/payment/paypal_googlepay.php +++ b/upload/catalog/model/extension/payment/paypal_googlepay.php @@ -2,7 +2,7 @@ class ModelExtensionPaymentPayPalGooglePay extends Model { public function getMethod($address, $total) { - $method_data = array(); + $method_data = []; $this->load->model('extension/payment/paypal'); @@ -24,12 +24,12 @@ public function getMethod($address, $total) { } if ($status) { - $method_data = array( + $method_data = [ 'code' => 'paypal_googlepay', 'title' => $this->language->get('text_paypal_googlepay_title'), 'terms' => '', 'sort_order' => $this->config->get('payment_paypal_sort_order') - ); + ]; } } diff --git a/upload/catalog/model/extension/payment/paypal_paylater.php b/upload/catalog/model/extension/payment/paypal_paylater.php index 668e4289e..feaf2fa73 100644 --- a/upload/catalog/model/extension/payment/paypal_paylater.php +++ b/upload/catalog/model/extension/payment/paypal_paylater.php @@ -2,7 +2,7 @@ class ModelExtensionPaymentPayPalPayLater extends Model { public function getMethod($address, $total) { - $method_data = array(); + $method_data = []; $this->load->model('extension/payment/paypal'); @@ -38,12 +38,12 @@ public function getMethod($address, $total) { $message = ''; } - $method_data = array( + $method_data = [ 'code' => 'paypal_paylater', 'title' => $this->language->get('text_paypal_paylater_title') . $message, 'terms' => '', 'sort_order' => $this->config->get('payment_paypal_sort_order') - ); + ]; } } diff --git a/upload/system/config/paypal.php b/upload/system/config/paypal.php index b16b0e504..0fd79daea 100644 --- a/upload/system/config/paypal.php +++ b/upload/system/config/paypal.php @@ -1087,5 +1087,4 @@ 'name' => 'text_marketing_solutions' ), ) -); -?> \ No newline at end of file +); \ No newline at end of file diff --git a/upload/system/library/paypal/paypal.php b/upload/system/library/paypal/paypal.php index e588840c9..8d2474ca4 100644 --- a/upload/system/library/paypal/paypal.php +++ b/upload/system/library/paypal/paypal.php @@ -1,17 +1,17 @@ 'https://api.sandbox.paypal.com', 'production' => 'https://api.paypal.com' - ); + ]; private $environment = 'sandbox'; private $partner_id = ''; private $client_id = ''; private $secret = ''; private $partner_attribution_id = ''; private $access_token = ''; - private $errors = array(); - private $last_response = array(); + private $errors = []; + private $last_response = []; //IN: paypal info public function __construct($paypal_info) { @@ -76,9 +76,9 @@ public function getClientToken() { public function getUserInfo() { $command = '/v1/identity/oauth2/userinfo'; - $params = array( + $params = [ 'schema' => 'paypalv1.1' - ); + ]; $result = $this->execute('GET', $command, $params); @@ -254,7 +254,7 @@ public function getPaymentToken($payment_token_id) { public function getPaymentTokens($customer_id) { $command = '/v3/vault/payment-tokens'; - $params = array('customer_id' => $customer_id); + $params = ['customer_id' => $customer_id]; $result = $this->execute('GET', $command, $params); @@ -502,11 +502,11 @@ public function getResponse() { return $this->last_response; } - private function execute($method, $command, $params = array(), $json = false) { - $this->errors = array(); + private function execute($method, $command, $params = [], $json = false) { + $this->errors = []; if ($method && $command) { - $curl_options = array( + $curl_options = [ CURLOPT_URL => $this->server[$this->environment] . $command, CURLOPT_HEADER => true, CURLOPT_RETURNTRANSFER => true, @@ -516,7 +516,7 @@ private function execute($method, $command, $params = array(), $json = false) { CURLOPT_TIMEOUT => 10, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSL_VERIFYPEER => 0 - ); + ]; $curl_options[CURLOPT_HTTPHEADER][] = 'Accept-Charset: utf-8'; $curl_options[CURLOPT_HTTPHEADER][] = 'Accept: application/json'; @@ -567,7 +567,7 @@ private function execute($method, $command, $params = array(), $json = false) { $curl_options[CURLOPT_INFILE] = $buffer; $curl_options[CURLOPT_INFILESIZE] = strlen($params_string); } else { - $this->errors[] = array('name' => 'FAILED_OPEN_TEMP_FILE', 'message' => 'Unable to open a temporary file'); + $this->errors[] = ['name' => 'FAILED_OPEN_TEMP_FILE', 'message' => 'Unable to open a temporary file']; } } @@ -590,7 +590,7 @@ private function execute($method, $command, $params = array(), $json = false) { $constant = get_defined_constants(true); $curl_constant = preg_grep('/^CURLE_/', array_flip($constant['curl'])); - $this->errors[] = array('name' => $curl_constant[$curl_code], 'message' => curl_strerror($curl_code)); + $this->errors[] = ['name' => $curl_constant[$curl_code], 'message' => curl_strerror($curl_code)]; } $head = ''; @@ -600,13 +600,13 @@ private function execute($method, $command, $params = array(), $json = false) { if (isset($parts[0]) && isset($parts[1])) { if (($parts[0] == 'HTTP/1.1 100 Continue') && isset($parts[2])) { - list($head, $body) = array($parts[1], $parts[2]); + list($head, $body) = [$parts[1], $parts[2]]; } else { - list($head, $body) = array($parts[0], $parts[1]); + list($head, $body) = [$parts[0], $parts[1]]; } } - $response_headers = array(); + $response_headers = []; $header_lines = explode("\r\n", $head); array_shift($header_lines);