From 2bcf37e6e143ee985344b9ed8be339fa183eb19c Mon Sep 17 00:00:00 2001 From: condor2 Date: Sat, 20 Jul 2024 09:30:35 +0300 Subject: [PATCH] Paypal updated to v3.1.6 --- .../controller/extension/payment/paypal.php | 2525 ++++++------ .../en-gb/extension/payment/paypal.php | 18 +- .../admin/model/extension/payment/paypal.php | 227 +- .../admin/view/stylesheet/paypal/paypal.css | 9 + .../extension/payment/paypal/button.tpl | 2 +- .../extension/payment/paypal/order_status.tpl | 17 +- .../controller/extension/payment/paypal.php | 3376 ++++++++--------- .../extension/payment/paypal_applepay.php | 136 +- .../extension/payment/paypal_googlepay.php | 136 +- .../extension/payment/paypal_paylater.php | 136 +- .../controller/extension/recurring/paypal.php | 56 +- .../en-gb/extension/payment/paypal.php | 2 +- .../en-gb/extension/recurring/paypal.php | 2 +- .../model/extension/payment/paypal.php | 490 +-- .../extension/payment/paypal_applepay.php | 17 +- .../extension/payment/paypal_googlepay.php | 15 +- .../extension/payment/paypal_paylater.php | 23 +- .../catalog/view/javascript/paypal/paypal.js | 329 +- upload/system/config/paypal.php | 1630 ++++---- upload/system/config/paypal_carrier.php | 2577 ++++++------- upload/system/library/paypal/paypal.php | 376 +- 21 files changed, 6017 insertions(+), 6082 deletions(-) diff --git a/upload/admin/controller/extension/payment/paypal.php b/upload/admin/controller/extension/payment/paypal.php index 41bddd18..64e5e834 100644 --- a/upload/admin/controller/extension/payment/paypal.php +++ b/upload/admin/controller/extension/payment/paypal.php @@ -1,16 +1,16 @@ config->get('paypal_version')) || (!empty($this->config->get('paypal_version')) && ($this->config->get('paypal_version') < '3.1.0'))) { + + if (empty($this->config->get('paypal_version')) || (!empty($this->config->get('paypal_version')) && ($this->config->get('paypal_version') < '3.1.4'))) { $this->update(); } } - - public function index() { + + public function index() { if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $server = HTTPS_SERVER; $catalog = HTTPS_CATALOG; @@ -18,123 +18,123 @@ public function index() { $server = HTTP_SERVER; $catalog = HTTP_CATALOG; } - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $cache_data = $this->cache->get('paypal'); - + $this->cache->delete('paypal'); - - if (!empty($cache_data['environment']) && !empty($cache_data['authorization_code']) && !empty($cache_data['shared_id']) && !empty($cache_data['seller_nonce']) && !empty($this->request->get['merchantIdInPayPal'])) { + + if (!empty($cache_data['environment']) && !empty($cache_data['authorization_code']) && !empty($cache_data['shared_id']) && !empty($cache_data['seller_nonce']) && !empty($this->request->get['merchantIdInPayPal'])) { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $environment = $cache_data['environment']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'client_id' => $cache_data['shared_id'], - 'environment' => $environment, + + $paypal_info = array( + 'client_id' => $cache_data['shared_id'], + 'environment' => $environment, 'partner_attribution_id' => $config_setting['partner'][$environment]['partner_attribution_id'] - ]; - + ); + $paypal = new PayPal($paypal_info); - - $token_info = [ - 'grant_type' => 'authorization_code', - 'code' => $cache_data['authorization_code'], + + $token_info = array( + 'grant_type' => 'authorization_code', + 'code' => $cache_data['authorization_code'], 'code_verifier' => $cache_data['seller_nonce'] - ]; - + ); + $paypal->setAccessToken($token_info); - + $result = $paypal->getSellerCredentials($config_setting['partner'][$environment]['partner_id']); - + $client_id = ''; $secret = ''; - + if (isset($result['client_id']) && isset($result['client_secret'])) { $client_id = $result['client_id']; $secret = $result['client_secret']; } - - $paypal_info = [ - 'partner_id' => $config_setting['partner'][$environment]['partner_id'], - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $order_history_token = sha1(uniqid(mt_rand(), 1)); $callback_token = sha1(uniqid(mt_rand(), 1)); $webhook_token = sha1(uniqid(mt_rand(), 1)); $cron_token = sha1(uniqid(mt_rand(), 1)); - - $webhook_info = [ - 'url' => $catalog . 'index.php?route=extension/payment/paypal&webhook_token=' . $webhook_token, - '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'] - ] - ]; - + + $webhook_info = array( + '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') + ) + ); + $result = $paypal->createWebhook($webhook_info); - + $webhook_id = ''; - + if (isset($result['id'])) { $webhook_id = $result['id']; } - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + $merchant_id = $this->request->get['merchantIdInPayPal']; - + $this->load->model('setting/setting'); - + $setting = $this->model_setting_setting->getSetting('paypal'); - + $setting['paypal_environment'] = $environment; $setting['paypal_client_id'] = $client_id; $setting['paypal_secret'] = $secret; @@ -148,53 +148,53 @@ public function index() { $setting['paypal_setting']['general']['callback_token'] = $callback_token; $setting['paypal_setting']['general']['webhook_token'] = $webhook_token; $setting['paypal_setting']['general']['cron_token'] = $cron_token; - + $this->load->model('localisation/country'); - + $country = $this->model_localisation_country->getCountry($this->config->get('config_country_id')); - + $setting['paypal_setting']['general']['country_code'] = $country['iso_code_2']; - + $currency_code = $this->config->get('config_currency'); $currency_value = $this->currency->getValue($this->config->get('config_currency')); - + if (!empty($config_setting['currency'][$currency_code]['status'])) { $setting['paypal_setting']['general']['currency_code'] = $currency_code; $setting['paypal_setting']['general']['currency_value'] = $currency_value; } - + if (!empty($config_setting['currency'][$currency_code]['card_status'])) { $setting['paypal_setting']['general']['card_currency_code'] = $currency_code; $setting['paypal_setting']['general']['card_currency_value'] = $currency_value; } - + $this->model_setting_setting->editSetting('paypal', $setting); } - + if (!empty($this->request->get['merchantIdInPayPal']) && !$this->error) { sleep(3); - + $this->response->redirect($this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true)); } - + if (!$this->config->get('paypal_client_id')) { $this->auth(); } else { $this->dashboard(); } } - + public function auth() { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); - + $this->document->setTitle($this->language->get('heading_title_main')); - + $data['heading_title_main'] = $this->language->get('heading_title_main'); - + $data['text_edit'] = $this->language->get('text_edit'); $data['text_welcome'] = $this->language->get('text_welcome'); $data['text_automatic'] = $this->language->get('text_automatic'); @@ -203,40 +203,40 @@ public function auth() { $data['text_production'] = $this->language->get('text_production'); $data['text_sandbox'] = $this->language->get('text_sandbox'); $data['text_loading'] = $this->language->get('text_loading'); - + $data['entry_authorization_type'] = $this->language->get('entry_authorization_type'); $data['entry_environment'] = $this->language->get('entry_environment'); $data['entry_merchant_id'] = $this->language->get('entry_merchant_id'); $data['entry_client_id'] = $this->language->get('entry_client_id'); $data['entry_client_secret'] = $this->language->get('entry_client_secret'); - + $data['button_cancel'] = $this->language->get('button_cancel'); $data['button_connect'] = $this->language->get('button_connect'); $data['button_view'] = $this->language->get('button_view'); + + $data['breadcrumbs'] = array(); - $data['breadcrumbs'] = []; - - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true) - ]; - + ); + $data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true); $data['partner_url'] = str_replace('&', '%26', $this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true)); $data['callback_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/callback', 'token=' . $this->session->data['token'], true)); $data['connect_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/connect', 'token=' . $this->session->data['token'], true)); $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'token=' . $this->session->data['token'], true)); - + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $data['server'] = HTTPS_SERVER; $data['catalog'] = HTTPS_CATALOG; @@ -244,77 +244,77 @@ public function auth() { $data['server'] = HTTP_SERVER; $data['catalog'] = HTTP_CATALOG; } - + $_config = new Config(); $_config->load('paypal'); - + $data['setting'] = $_config->get('paypal_setting'); - - $data['authorization_type'] = 'automatic'; + + $data['authorization_type'] = 'automatic'; $data['environment'] = 'production'; - + $data['seller_nonce'] = $this->token(50); - - $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'], + + $data['configure_url'] = array( + 'production' => array( + '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' => [ - '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'], + ), + 'sandbox' => array( + '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']); - + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); - + if (!empty($result['href'])) { $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); } else { $data['text_version'] = ''; } - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if (!$agree_status) { $this->error['warning'] = $this->language->get('error_agree'); } - + if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } - + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); $this->response->setOutput($this->load->view('extension/payment/paypal/auth', $data)); } - + public function dashboard() { if (!$this->config->get('paypal_client_id')) { $this->response->redirect($this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true)); } - + $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); $this->load->model('setting/setting'); - + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); - + $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); $this->document->setTitle($this->language->get('heading_title_main')); - + $data['heading_title_main'] = $this->language->get('heading_title_main'); - + $data['text_edit'] = $this->language->get('text_edit'); $data['text_tab_general'] = $this->language->get('text_tab_general'); $data['text_tab_button'] = $this->language->get('text_tab_button'); @@ -337,29 +337,29 @@ public function dashboard() { $data['text_week'] = $this->language->get('text_week'); $data['text_month'] = $this->language->get('text_month'); $data['text_year'] = $this->language->get('text_year'); - + $data['entry_status'] = $this->language->get('entry_status'); - + $data['button_save'] = $this->language->get('button_save'); $data['button_cancel'] = $this->language->get('button_cancel'); + + $data['breadcrumbs'] = array(); - $data['breadcrumbs'] = []; - - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true) - ]; - + ); + $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'token=' . $this->session->data['token'], true); $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'token=' . $this->session->data['token'], true); $data['href_button'] = $this->url->link('extension/payment/paypal/button', 'token=' . $this->session->data['token'], true); @@ -370,12 +370,12 @@ public function dashboard() { $data['href_message_setting'] = $this->url->link('extension/payment/paypal/message_setting', 'token=' . $this->session->data['token'], true); $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'token=' . $this->session->data['token'], true); $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'token=' . $this->session->data['token'], true); - + $data['action'] = $this->url->link('extension/payment/paypal/save', 'token=' . $this->session->data['token'], true); $data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true); $data['sale_analytics_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/getSaleAnalytics', 'token=' . $this->session->data['token'], true)); $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'token=' . $this->session->data['token'], true)); - + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $data['server'] = HTTPS_SERVER; $data['catalog'] = HTTPS_CATALOG; @@ -383,99 +383,99 @@ public function dashboard() { $data['server'] = HTTP_SERVER; $data['catalog'] = HTTP_CATALOG; } - + $_config = new Config(); $_config->load('paypal'); - + $data['setting'] = $_config->get('paypal_setting'); - + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('paypal_setting')); - + if ($this->config->get('paypal_status') != null) { $data['status'] = $this->config->get('paypal_status'); } else { $data['status'] = 1; } - + if ($data['setting']['button']['product']['status'] || $data['setting']['button']['cart']['status'] || $data['setting']['button']['checkout']['status']) { $data['button_status'] = 1; } else { $data['button_status'] = 0; } - + if ($data['setting']['googlepay_button']['product']['status'] || $data['setting']['googlepay_button']['cart']['status'] || $data['setting']['googlepay_button']['checkout']['status']) { $data['googlepay_button_status'] = 1; } else { $data['googlepay_button_status'] = 0; } - + if ($data['setting']['applepay_button']['product']['status'] || $data['setting']['applepay_button']['cart']['status'] || $data['setting']['applepay_button']['checkout']['status']) { $data['applepay_button_status'] = 1; } else { $data['applepay_button_status'] = 0; } - + if ($data['setting']['card']['status']) { $data['card_status'] = 1; } else { $data['card_status'] = 0; } - + if ($data['setting']['message']['home']['status'] || $data['setting']['message']['product']['status'] || $data['setting']['message']['cart']['status'] || $data['setting']['message']['checkout']['status']) { $data['message_status'] = 1; } else { $data['message_status'] = 0; } - + $paypal_sale_total = $this->model_extension_payment_paypal->getTotalSales(); - + $data['paypal_sale_total'] = $this->currency->format($paypal_sale_total, $this->config->get('config_currency')); - + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); - + if (!empty($result['href'])) { $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); } else { $data['text_version'] = ''; } - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if (!$agree_status) { $this->error['warning'] = $this->language->get('error_agree'); - } - + } + if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } - + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); $this->response->setOutput($this->load->view('extension/payment/paypal/dashboard', $data)); } - + public function general() { if (!$this->config->get('paypal_client_id')) { $this->response->redirect($this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true)); } - + $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); - + $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); $this->document->setTitle($this->language->get('heading_title_main')); - + $data['heading_title_main'] = $this->language->get('heading_title_main'); - + $data['text_edit'] = $this->language->get('text_edit'); $data['text_tab_dashboard'] = $this->language->get('text_tab_dashboard'); $data['text_tab_general'] = $this->language->get('text_tab_general'); @@ -524,7 +524,7 @@ public function general() { $data['text_currency_thb'] = $this->language->get('text_currency_thb'); $data['text_currency_usd'] = $this->language->get('text_currency_usd'); $data['text_confirm'] = $this->language->get('text_confirm'); - + $data['entry_connect'] = $this->language->get('entry_connect'); $data['entry_status'] = $this->language->get('entry_status'); $data['entry_vault_status'] = $this->language->get('entry_vault_status'); @@ -542,7 +542,7 @@ public function general() { $data['entry_card_currency_code'] = $this->language->get('entry_card_currency_code'); $data['entry_card_currency_value'] = $this->language->get('entry_card_currency_value'); $data['entry_cron_url'] = $this->language->get('entry_cron_url'); - + $data['help_vault_status'] = $this->language->get('help_vault_status'); $data['help_checkout_mode'] = $this->language->get('help_checkout_mode'); $data['help_checkout_route'] = $this->language->get('help_checkout_route'); @@ -553,30 +553,30 @@ public function general() { $data['help_card_currency_code'] = $this->language->get('help_card_currency_code'); $data['help_card_currency_value'] = $this->language->get('help_card_currency_value'); $data['help_cron_url'] = $this->language->get('help_cron_url'); - + $data['button_save'] = $this->language->get('button_save'); $data['button_cancel'] = $this->language->get('button_cancel'); $data['button_disconnect'] = $this->language->get('button_disconnect'); $data['button_all_settings'] = $this->language->get('button_all_settings'); $data['button_copy_url'] = $this->language->get('button_copy_url'); + + $data['breadcrumbs'] = array(); - $data['breadcrumbs'] = []; - - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true) - ]; - + ); + // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'token=' . $this->session->data['token'], true); $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'token=' . $this->session->data['token'], true); @@ -588,12 +588,12 @@ public function general() { $data['href_message_setting'] = $this->url->link('extension/payment/paypal/message_setting', 'token=' . $this->session->data['token'], true); $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'token=' . $this->session->data['token'], true); $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'token=' . $this->session->data['token'], true); - + $data['action'] = $this->url->link('extension/payment/paypal/save', 'token=' . $this->session->data['token'], true); $data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true); $data['disconnect_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/disconnect', 'token=' . $this->session->data['token'], true)); $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'token=' . $this->session->data['token'], true)); - + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $data['server'] = HTTPS_SERVER; $data['catalog'] = HTTPS_CATALOG; @@ -601,88 +601,88 @@ public function general() { $data['server'] = HTTP_SERVER; $data['catalog'] = HTTP_CATALOG; } - + $_config = new Config(); $_config->load('paypal'); - + $data['setting'] = $_config->get('paypal_setting'); - + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('paypal_setting')); - + if ($this->config->get('paypal_status') != null) { $data['status'] = $this->config->get('paypal_status'); } else { $data['status'] = 1; } - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); $data['webhook_id'] = $this->config->get('paypal_webhook_id'); $data['environment'] = $this->config->get('paypal_environment'); - + $data['text_connect'] = sprintf($this->language->get('text_connect'), $data['merchant_id'], $data['client_id'], $data['secret'], $data['webhook_id'], $data['environment']); $data['total'] = $this->config->get('paypal_total'); $data['geo_zone_id'] = $this->config->get('paypal_geo_zone_id'); $data['sort_order'] = $this->config->get('paypal_sort_order'); - + $this->load->model('localisation/geo_zone'); $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); - + $this->load->model('localisation/country'); $data['countries'] = $this->model_localisation_country->getCountries(); - + $data['cron_url'] = $data['catalog'] . 'index.php?route=extension/payment/paypal&cron_token=' . $data['setting']['general']['cron_token']; - + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); - + if (!empty($result['href'])) { $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); } else { $data['text_version'] = ''; } - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if (!$agree_status) { $this->error['warning'] = $this->language->get('error_agree'); - } - + } + if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } - + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); - + $this->response->setOutput($this->load->view('extension/payment/paypal/general', $data)); } - + public function button() { if (!$this->config->get('paypal_client_id')) { $this->response->redirect($this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true)); } - + $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); - + $this->document->addScript('view/javascript/paypal/paypal.js'); $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); $this->document->setTitle($this->language->get('heading_title_main')); - + $data['heading_title_main'] = $this->language->get('heading_title_main'); - + $data['text_edit'] = $this->language->get('text_edit'); $data['text_tab_dashboard'] = $this->language->get('text_tab_dashboard'); $data['text_tab_general'] = $this->language->get('text_tab_general'); @@ -730,7 +730,7 @@ public function button() { $data['text_insert_prepend'] = $this->language->get('text_insert_prepend'); $data['text_insert_append'] = $this->language->get('text_insert_append'); $data['text_insert_before'] = $this->language->get('text_insert_before'); - $data['text_insert_after'] = $this->language->get('text_insert_after'); + $data['text_insert_after'] = $this->language->get('text_insert_after'); $data['text_align_left'] = $this->language->get('text_align_left'); $data['text_align_center'] = $this->language->get('text_align_center'); $data['text_align_right'] = $this->language->get('text_align_right'); @@ -766,7 +766,7 @@ public function button() { $data['text_paylater'] = $this->language->get('text_paylater'); $data['text_text'] = $this->language->get('text_text'); $data['text_flex'] = $this->language->get('text_flex'); - + $data['entry_status'] = $this->language->get('entry_status'); $data['entry_button_insert_tag'] = $this->language->get('entry_button_insert_tag'); $data['entry_button_insert_type'] = $this->language->get('entry_button_insert_type'); @@ -776,32 +776,32 @@ public function button() { $data['entry_button_shape'] = $this->language->get('entry_button_shape'); $data['entry_button_label'] = $this->language->get('entry_button_label'); $data['entry_button_tagline'] = $this->language->get('entry_button_tagline'); - + $data['help_button_status'] = $this->language->get('help_button_status'); - + $data['button_save'] = $this->language->get('button_save'); $data['button_cancel'] = $this->language->get('button_cancel'); $data['button_all_settings'] = $this->language->get('button_all_settings'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_checkout'] = $this->language->get('button_checkout'); + + $data['breadcrumbs'] = array(); - $data['breadcrumbs'] = []; - - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true) - ]; - + ); + // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'token=' . $this->session->data['token'], true); $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'token=' . $this->session->data['token'], true); @@ -813,11 +813,11 @@ public function button() { $data['href_message_setting'] = $this->url->link('extension/payment/paypal/message_setting', 'token=' . $this->session->data['token'], true); $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'token=' . $this->session->data['token'], true); $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'token=' . $this->session->data['token'], true); - + $data['action'] = $this->url->link('extension/payment/paypal/save', 'token=' . $this->session->data['token'], true); $data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true); $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'token=' . $this->session->data['token'], true)); - + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $data['server'] = HTTPS_SERVER; $data['catalog'] = HTTPS_CATALOG; @@ -825,14 +825,14 @@ public function button() { $data['server'] = HTTP_SERVER; $data['catalog'] = HTTP_CATALOG; } - + $_config = new Config(); $_config->load('paypal'); - + $data['setting'] = $_config->get('paypal_setting'); - + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -841,104 +841,104 @@ public function button() { $data['partner_attribution_id'] = $data['setting']['partner'][$data['environment']]['partner_attribution_id']; $country = $this->model_extension_payment_paypal->getCountryByCode($data['setting']['general']['country_code']); - + $data['locale'] = preg_replace('/-(.+?)+/', '', $this->config->get('config_language')) . '_' . $country['iso_code_2']; - + $data['currency_code'] = $data['setting']['general']['currency_code']; $data['currency_value'] = $data['setting']['general']['currency_value']; - + $data['decimal_place'] = $data['setting']['currency'][$data['currency_code']]['decimal_place']; - - if ($data['client_id'] && $data['secret']) { + + if ($data['client_id'] && $data['secret']) { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } } - + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); - + if (!empty($result['href'])) { $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); } else { $data['text_version'] = ''; } - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if (!$agree_status) { $this->error['warning'] = $this->language->get('error_agree'); - } - + } + if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } - + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); - + $this->response->setOutput($this->load->view('extension/payment/paypal/button', $data)); } - + public function googlepay_button() { if (!$this->config->get('paypal_client_id')) { $this->response->redirect($this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true)); } - + $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); - + $this->document->addScript('view/javascript/paypal/paypal.js'); $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); $this->document->addScript('https://pay.google.com/gp/p/js/pay.js'); $this->document->setTitle($this->language->get('heading_title_main')); - + $data['heading_title_main'] = $this->language->get('heading_title_main'); - + $data['text_edit'] = $this->language->get('text_edit'); $data['text_tab_dashboard'] = $this->language->get('text_tab_dashboard'); $data['text_tab_general'] = $this->language->get('text_tab_general'); @@ -986,7 +986,7 @@ public function googlepay_button() { $data['text_insert_prepend'] = $this->language->get('text_insert_prepend'); $data['text_insert_append'] = $this->language->get('text_insert_append'); $data['text_insert_before'] = $this->language->get('text_insert_before'); - $data['text_insert_after'] = $this->language->get('text_insert_after'); + $data['text_insert_after'] = $this->language->get('text_insert_after'); $data['text_align_left'] = $this->language->get('text_align_left'); $data['text_align_center'] = $this->language->get('text_align_center'); $data['text_align_right'] = $this->language->get('text_align_right'); @@ -1003,7 +1003,7 @@ public function googlepay_button() { $data['text_plain'] = $this->language->get('text_plain'); $data['text_pay'] = $this->language->get('text_pay'); $data['text_check_out'] = $this->language->get('text_check_out'); - + $data['entry_status'] = $this->language->get('entry_status'); $data['entry_googlepay_button_insert_tag'] = $this->language->get('entry_googlepay_button_insert_tag'); $data['entry_googlepay_button_insert_type'] = $this->language->get('entry_googlepay_button_insert_type'); @@ -1012,31 +1012,31 @@ public function googlepay_button() { $data['entry_googlepay_button_color'] = $this->language->get('entry_googlepay_button_color'); $data['entry_googlepay_button_shape'] = $this->language->get('entry_googlepay_button_shape'); $data['entry_googlepay_button_type'] = $this->language->get('entry_googlepay_button_type'); - + $data['help_googlepay_button_status'] = $this->language->get('help_googlepay_button_status'); - + $data['button_save'] = $this->language->get('button_save'); $data['button_cancel'] = $this->language->get('button_cancel'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_checkout'] = $this->language->get('button_checkout'); + + $data['breadcrumbs'] = array(); - $data['breadcrumbs'] = []; - - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true) - ]; - + ); + // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'token=' . $this->session->data['token'], true); $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'token=' . $this->session->data['token'], true); @@ -1048,11 +1048,11 @@ public function googlepay_button() { $data['href_message_setting'] = $this->url->link('extension/payment/paypal/message_setting', 'token=' . $this->session->data['token'], true); $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'token=' . $this->session->data['token'], true); $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'token=' . $this->session->data['token'], true); - + $data['action'] = $this->url->link('extension/payment/paypal/save', 'token=' . $this->session->data['token'], true); $data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true); $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'token=' . $this->session->data['token'], true)); - + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $data['server'] = HTTPS_SERVER; $data['catalog'] = HTTPS_CATALOG; @@ -1060,14 +1060,14 @@ public function googlepay_button() { $data['server'] = HTTP_SERVER; $data['catalog'] = HTTP_CATALOG; } - + $_config = new Config(); $_config->load('paypal'); - + $data['setting'] = $_config->get('paypal_setting'); - + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -1076,104 +1076,104 @@ public function googlepay_button() { $data['partner_attribution_id'] = $data['setting']['partner'][$data['environment']]['partner_attribution_id']; $country = $this->model_extension_payment_paypal->getCountryByCode($data['setting']['general']['country_code']); - + $data['locale'] = preg_replace('/-(.+?)+/', '', $this->config->get('config_language')) . '_' . $country['iso_code_2']; - + $data['currency_code'] = $data['setting']['general']['currency_code']; $data['currency_value'] = $data['setting']['general']['currency_value']; - + $data['decimal_place'] = $data['setting']['currency'][$data['currency_code']]['decimal_place']; - - if ($data['client_id'] && $data['secret']) { + + if ($data['client_id'] && $data['secret']) { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } } - + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); - + if (!empty($result['href'])) { $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); } else { $data['text_version'] = ''; } - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if (!$agree_status) { $this->error['warning'] = $this->language->get('error_agree'); - } - + } + if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } - + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); - + $this->response->setOutput($this->load->view('extension/payment/paypal/googlepay_button', $data)); } - + public function applepay_button() { if (!$this->config->get('paypal_client_id')) { $this->response->redirect($this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true)); } - + $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); - + $this->document->addScript('view/javascript/paypal/paypal.js'); $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); $this->document->addScript('https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js'); $this->document->setTitle($this->language->get('heading_title_main')); - + $data['heading_title_main'] = $this->language->get('heading_title_main'); - + $data['text_edit'] = $this->language->get('text_edit'); $data['text_tab_dashboard'] = $this->language->get('text_tab_dashboard'); $data['text_tab_general'] = $this->language->get('text_tab_general'); @@ -1221,7 +1221,7 @@ public function applepay_button() { $data['text_insert_prepend'] = $this->language->get('text_insert_prepend'); $data['text_insert_append'] = $this->language->get('text_insert_append'); $data['text_insert_before'] = $this->language->get('text_insert_before'); - $data['text_insert_after'] = $this->language->get('text_insert_after'); + $data['text_insert_after'] = $this->language->get('text_insert_after'); $data['text_align_left'] = $this->language->get('text_align_left'); $data['text_align_center'] = $this->language->get('text_align_center'); $data['text_align_right'] = $this->language->get('text_align_right'); @@ -1241,7 +1241,7 @@ public function applepay_button() { $data['text_applepay_alert'] = $this->language->get('text_applepay_alert'); $data['text_applepay_step_1'] = $this->language->get('text_applepay_step_1'); $data['text_applepay_step_2'] = $this->language->get('text_applepay_step_2'); - + $data['entry_status'] = $this->language->get('entry_status'); $data['entry_applepay_button_insert_tag'] = $this->language->get('entry_applepay_button_insert_tag'); $data['entry_applepay_button_insert_type'] = $this->language->get('entry_applepay_button_insert_type'); @@ -1250,33 +1250,33 @@ public function applepay_button() { $data['entry_applepay_button_color'] = $this->language->get('entry_applepay_button_color'); $data['entry_applepay_button_shape'] = $this->language->get('entry_applepay_button_shape'); $data['entry_applepay_button_type'] = $this->language->get('entry_applepay_button_type'); - + $data['help_applepay_button_status'] = $this->language->get('help_applepay_button_status'); - + $data['button_save'] = $this->language->get('button_save'); $data['button_cancel'] = $this->language->get('button_cancel'); $data['button_download'] = $this->language->get('button_download'); $data['button_download_host'] = $this->language->get('button_download_host'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_checkout'] = $this->language->get('button_checkout'); + + $data['breadcrumbs'] = array(); - $data['breadcrumbs'] = []; - - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true) - ]; - + ); + // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'token=' . $this->session->data['token'], true); $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'token=' . $this->session->data['token'], true); @@ -1288,13 +1288,13 @@ public function applepay_button() { $data['href_message_setting'] = $this->url->link('extension/payment/paypal/message_setting', 'token=' . $this->session->data['token'], true); $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'token=' . $this->session->data['token'], true); $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'token=' . $this->session->data['token'], true); - + $data['action'] = $this->url->link('extension/payment/paypal/save', 'token=' . $this->session->data['token'], true); $data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true); $data['applepay_download_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/downloadAssociationFile', 'token=' . $this->session->data['token'], true)); $data['applepay_download_host_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/downloadHostAssociationFile', 'token=' . $this->session->data['token'], true)); $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'token=' . $this->session->data['token'], true)); - + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $data['server'] = HTTPS_SERVER; $data['catalog'] = HTTPS_CATALOG; @@ -1302,14 +1302,14 @@ public function applepay_button() { $data['server'] = HTTP_SERVER; $data['catalog'] = HTTP_CATALOG; } - + $_config = new Config(); $_config->load('paypal'); - + $data['setting'] = $_config->get('paypal_setting'); - + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -1318,104 +1318,104 @@ public function applepay_button() { $data['partner_attribution_id'] = $data['setting']['partner'][$data['environment']]['partner_attribution_id']; $country = $this->model_extension_payment_paypal->getCountryByCode($data['setting']['general']['country_code']); - + $data['locale'] = preg_replace('/-(.+?)+/', '', $this->config->get('config_language')) . '_' . $country['iso_code_2']; - + $data['currency_code'] = $data['setting']['general']['currency_code']; $data['currency_value'] = $data['setting']['general']['currency_value']; - + $data['decimal_place'] = $data['setting']['currency'][$data['currency_code']]['decimal_place']; - - if ($data['client_id'] && $data['secret']) { + + if ($data['client_id'] && $data['secret']) { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } } - + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); - + if (!empty($result['href'])) { $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); } else { $data['text_version'] = ''; } - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if (!$agree_status) { $this->error['warning'] = $this->language->get('error_agree'); - } - + } + if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } - + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); - + $this->response->setOutput($this->load->view('extension/payment/paypal/applepay_button', $data)); } - + public function card() { if (!$this->config->get('paypal_client_id')) { $this->response->redirect($this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true)); } - + $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); $this->document->addStyle('view/stylesheet/paypal/card.css'); $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); - + $this->document->addScript('view/javascript/paypal/paypal.js'); $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); $this->document->setTitle($this->language->get('heading_title_main')); - + $data['heading_title_main'] = $this->language->get('heading_title_main'); - + $data['text_edit'] = $this->language->get('text_edit'); $data['text_tab_dashboard'] = $this->language->get('text_tab_dashboard'); $data['text_tab_general'] = $this->language->get('text_tab_general'); @@ -1432,7 +1432,7 @@ public function card() { $data['text_cart'] = $this->language->get('text_cart'); $data['text_step_coupon'] = $this->language->get('text_step_coupon'); $data['text_step_shipping'] = $this->language->get('text_step_shipping'); - $data['text_step_payment_method'] = $this->language->get('text_step_payment_method'); + $data['text_step_payment_method'] = $this->language->get('text_step_payment_method'); $data['text_step_confirm_order'] = $this->language->get('text_step_confirm_order'); $data['text_cart_product_price_value'] = $this->language->get('text_cart_product_price_value'); $data['text_cart_product_total_value'] = $this->language->get('text_cart_product_total_value'); @@ -1466,7 +1466,7 @@ public function card() { $data['text_3ds_card_ineligible'] = $this->language->get('text_3ds_card_ineligible'); $data['text_3ds_system_unavailable'] = $this->language->get('text_3ds_system_unavailable'); $data['text_3ds_system_bypassed'] = $this->language->get('text_3ds_system_bypassed'); - + $data['entry_status'] = $this->language->get('entry_status'); $data['entry_card_align'] = $this->language->get('entry_card_align'); $data['entry_card_size'] = $this->language->get('entry_card_size'); @@ -1475,34 +1475,34 @@ public function card() { $data['entry_card_number'] = $this->language->get('entry_card_number'); $data['entry_expiration_date'] = $this->language->get('entry_expiration_date'); $data['entry_cvv'] = $this->language->get('entry_cvv'); - + $data['help_card_status'] = $this->language->get('help_card_status'); $data['help_card_secure_method'] = $this->language->get('help_card_secure_method'); $data['help_card_secure_scenario'] = $this->language->get('help_card_secure_scenario'); - + $data['button_save'] = $this->language->get('button_save'); $data['button_cancel'] = $this->language->get('button_cancel'); $data['button_all_settings'] = $this->language->get('button_all_settings'); $data['button_checkout'] = $this->language->get('button_checkout'); $data['button_pay'] = $this->language->get('button_pay'); + + $data['breadcrumbs'] = array(); - $data['breadcrumbs'] = []; - - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true) - ]; - + ); + // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'token=' . $this->session->data['token'], true); $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'token=' . $this->session->data['token'], true); @@ -1514,11 +1514,11 @@ public function card() { $data['href_message_setting'] = $this->url->link('extension/payment/paypal/message_setting', 'token=' . $this->session->data['token'], true); $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'token=' . $this->session->data['token'], true); $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'token=' . $this->session->data['token'], true); - + $data['action'] = $this->url->link('extension/payment/paypal/save', 'token=' . $this->session->data['token'], true); $data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true); $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'token=' . $this->session->data['token'], true)); - + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $data['server'] = HTTPS_SERVER; $data['catalog'] = HTTPS_CATALOG; @@ -1526,14 +1526,14 @@ public function card() { $data['server'] = HTTP_SERVER; $data['catalog'] = HTTP_CATALOG; } - + $_config = new Config(); $_config->load('paypal'); - + $data['setting'] = $_config->get('paypal_setting'); - + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -1542,104 +1542,104 @@ public function card() { $data['partner_attribution_id'] = $data['setting']['partner'][$data['environment']]['partner_attribution_id']; $country = $this->model_extension_payment_paypal->getCountryByCode($data['setting']['general']['country_code']); - + $data['locale'] = preg_replace('/-(.+?)+/', '', $this->config->get('config_language')) . '_' . $country['iso_code_2']; - + $data['currency_code'] = $data['setting']['general']['currency_code']; $data['currency_value'] = $data['setting']['general']['currency_value']; - + $data['decimal_place'] = $data['setting']['currency'][$data['currency_code']]['decimal_place']; - - if ($data['client_id'] && $data['secret']) { + + if ($data['client_id'] && $data['secret']) { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } } - + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); - + if (!empty($result['href'])) { $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); } else { $data['text_version'] = ''; } - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if (!$agree_status) { $this->error['warning'] = $this->language->get('error_agree'); - } - + } + if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } - + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); - + $this->response->setOutput($this->load->view('extension/payment/paypal/card', $data)); } - + public function message_configurator() { if (!$this->config->get('paypal_client_id')) { $this->response->redirect($this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true)); } - + $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); - + $this->document->addScript('view/javascript/paypal/paypal.js'); $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); $this->document->addScript('https://www.paypalobjects.com/merchant-library/merchant-configurator.js'); - + $this->document->setTitle($this->language->get('heading_title_main')); - + $data['heading_title_main'] = $this->language->get('heading_title_main'); - + $data['text_edit'] = $this->language->get('text_edit'); $data['text_tab_dashboard'] = $this->language->get('text_tab_dashboard'); $data['text_tab_general'] = $this->language->get('text_tab_general'); @@ -1651,30 +1651,30 @@ public function message_configurator() { $data['text_tab_message_setting'] = $this->language->get('text_tab_message_setting'); $data['text_tab_order_status'] = $this->language->get('text_tab_order_status'); $data['text_tab_contact'] = $this->language->get('text_tab_contact'); - + $data['button_save'] = $this->language->get('button_save'); $data['button_cancel'] = $this->language->get('button_cancel'); $data['button_all_settings'] = $this->language->get('button_all_settings'); $data['button_cart'] = $this->language->get('button_cart'); $data['button_checkout'] = $this->language->get('button_checkout'); + + $data['breadcrumbs'] = array(); - $data['breadcrumbs'] = []; - - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true) - ]; - + ); + // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'token=' . $this->session->data['token'], true); $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'token=' . $this->session->data['token'], true); @@ -1686,11 +1686,11 @@ public function message_configurator() { $data['href_message_setting'] = $this->url->link('extension/payment/paypal/message_setting', 'token=' . $this->session->data['token'], true); $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'token=' . $this->session->data['token'], true); $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'token=' . $this->session->data['token'], true); - + $data['action'] = $this->url->link('extension/payment/paypal/save', 'token=' . $this->session->data['token'], true); $data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true); $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'token=' . $this->session->data['token'], true)); - + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $data['server'] = HTTPS_SERVER; $data['catalog'] = HTTPS_CATALOG; @@ -1698,14 +1698,14 @@ public function message_configurator() { $data['server'] = HTTP_SERVER; $data['catalog'] = HTTP_CATALOG; } - + $_config = new Config(); $_config->load('paypal'); - + $data['setting'] = $_config->get('paypal_setting'); - + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -1713,105 +1713,105 @@ public function message_configurator() { $data['environment'] = $this->config->get('paypal_environment'); $data['partner_client_id'] = $data['setting']['partner'][$data['environment']]['client_id']; $data['partner_attribution_id'] = $data['setting']['partner'][$data['environment']]['partner_attribution_id']; - + $country = $this->model_extension_payment_paypal->getCountryByCode($data['setting']['general']['country_code']); - + $data['locale'] = preg_replace('/-(.+?)+/', '', $this->config->get('config_language')) . '_' . $country['iso_code_2']; - + $data['currency_code'] = $data['setting']['general']['currency_code']; $data['currency_value'] = $data['setting']['general']['currency_value']; - + $data['decimal_place'] = $data['setting']['currency'][$data['currency_code']]['decimal_place']; - - if ($data['client_id'] && $data['secret']) { + + if ($data['client_id'] && $data['secret']) { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } } - + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); - + if (!empty($result['href'])) { $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); } else { $data['text_version'] = ''; } - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if (!$agree_status) { $this->error['warning'] = $this->language->get('error_agree'); - } - + } + if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } - + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); - + $this->response->setOutput($this->load->view('extension/payment/paypal/message_configurator', $data)); } - + public function message_setting() { if (!$this->config->get('paypal_client_id')) { $this->response->redirect($this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true)); } - + $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); $this->document->addStyle('view/stylesheet/paypal/bootstrap-switch.css'); - + $this->document->addScript('view/javascript/paypal/paypal.js'); $this->document->addScript('view/javascript/paypal/bootstrap-switch.js'); - + $this->document->setTitle($this->language->get('heading_title_main')); - + $data['heading_title_main'] = $this->language->get('heading_title_main'); - + $data['text_edit'] = $this->language->get('text_edit'); $data['text_tab_dashboard'] = $this->language->get('text_tab_dashboard'); $data['text_tab_general'] = $this->language->get('text_tab_general'); @@ -1838,32 +1838,32 @@ public function message_setting() { $data['text_insert_prepend'] = $this->language->get('text_insert_prepend'); $data['text_insert_append'] = $this->language->get('text_insert_append'); $data['text_insert_before'] = $this->language->get('text_insert_before'); - $data['text_insert_after'] = $this->language->get('text_insert_after'); - + $data['text_insert_after'] = $this->language->get('text_insert_after'); + $data['entry_message_insert_tag'] = $this->language->get('entry_message_insert_tag'); $data['entry_message_insert_type'] = $this->language->get('entry_message_insert_type'); - + $data['button_save'] = $this->language->get('button_save'); $data['button_cancel'] = $this->language->get('button_cancel'); $data['button_all_settings'] = $this->language->get('button_all_settings'); + + $data['breadcrumbs'] = array(); - $data['breadcrumbs'] = []; - - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true) - ]; - + ); + // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'token=' . $this->session->data['token'], true); $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'token=' . $this->session->data['token'], true); @@ -1875,11 +1875,11 @@ public function message_setting() { $data['href_message_setting'] = $this->url->link('extension/payment/paypal/message_setting', 'token=' . $this->session->data['token'], true); $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'token=' . $this->session->data['token'], true); $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'token=' . $this->session->data['token'], true); - + $data['action'] = $this->url->link('extension/payment/paypal/save', 'token=' . $this->session->data['token'], true); $data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true); $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'token=' . $this->session->data['token'], true)); - + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $data['server'] = HTTPS_SERVER; $data['catalog'] = HTTPS_CATALOG; @@ -1887,14 +1887,14 @@ public function message_setting() { $data['server'] = HTTP_SERVER; $data['catalog'] = HTTP_CATALOG; } - + $_config = new Config(); $_config->load('paypal'); - + $data['setting'] = $_config->get('paypal_setting'); - + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -1902,16 +1902,16 @@ public function message_setting() { $data['environment'] = $this->config->get('paypal_environment'); $data['partner_client_id'] = $data['setting']['partner'][$data['environment']]['client_id']; $data['partner_attribution_id'] = $data['setting']['partner'][$data['environment']]['partner_attribution_id']; - + $country = $this->model_extension_payment_paypal->getCountryByCode($data['setting']['general']['country_code']); - + $data['locale'] = preg_replace('/-(.+?)+/', '', $this->config->get('config_language')) . '_' . $country['iso_code_2']; - + $data['currency_code'] = $data['setting']['general']['currency_code']; $data['currency_value'] = $data['setting']['general']['currency_value']; - + $data['decimal_place'] = $data['setting']['currency'][$data['currency_code']]['decimal_place']; - + if ($country['iso_code_2'] == 'GB') { $data['text_message_alert'] = $this->language->get('text_message_alert_uk'); $data['text_message_footnote'] = $this->language->get('text_message_footnote_uk'); @@ -1919,92 +1919,92 @@ public function message_setting() { $data['text_message_alert'] = $this->language->get('text_message_alert_us'); $data['text_message_footnote'] = $this->language->get('text_message_footnote_us'); } - - if ($data['client_id'] && $data['secret']) { + + if ($data['client_id'] && $data['secret']) { require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } } - + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); - + if (!empty($result['href'])) { $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); } else { $data['text_version'] = ''; } - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if (!$agree_status) { $this->error['warning'] = $this->language->get('error_agree'); - } - + } + if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } - + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); - + $this->response->setOutput($this->load->view('extension/payment/paypal/message_setting', $data)); } - + public function order_status() { if (!$this->config->get('paypal_client_id')) { $this->response->redirect($this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true)); } - + $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); $this->document->setTitle($this->language->get('heading_title_main')); - + $data['heading_title_main'] = $this->language->get('heading_title_main'); - + $data['text_edit'] = $this->language->get('text_edit'); $data['text_tab_dashboard'] = $this->language->get('text_tab_dashboard'); $data['text_tab_general'] = $this->language->get('text_tab_general'); @@ -2026,27 +2026,31 @@ public function order_status() { $data['text_reversed_status'] = $this->language->get('text_reversed_status'); $data['text_voided_status'] = $this->language->get('text_voided_status'); $data['text_shipped_status'] = $this->language->get('text_shipped_status'); - + + $data['entry_final_order_status'] = $this->language->get('entry_final_order_status'); + + $data['help_final_order_status'] = $this->language->get('help_final_order_status'); + $data['button_save'] = $this->language->get('button_save'); $data['button_cancel'] = $this->language->get('button_cancel'); + + $data['breadcrumbs'] = array(); - $data['breadcrumbs'] = []; - - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true) - ]; - + ); + // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'token=' . $this->session->data['token'], true); $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'token=' . $this->session->data['token'], true); @@ -2058,11 +2062,11 @@ public function order_status() { $data['href_message_setting'] = $this->url->link('extension/payment/paypal/message_setting', 'token=' . $this->session->data['token'], true); $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'token=' . $this->session->data['token'], true); $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'token=' . $this->session->data['token'], true); - + $data['action'] = $this->url->link('extension/payment/paypal/save', 'token=' . $this->session->data['token'], true); $data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true); $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'token=' . $this->session->data['token'], true)); - + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $data['server'] = HTTPS_SERVER; $data['catalog'] = HTTPS_CATALOG; @@ -2070,20 +2074,20 @@ public function order_status() { $data['server'] = HTTP_SERVER; $data['catalog'] = HTTP_CATALOG; } - + $_config = new Config(); $_config->load('paypal'); - + $data['setting'] = $_config->get('paypal_setting'); - + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('paypal_setting')); - + $this->load->model('localisation/order_status'); $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); - + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); - + if (!empty($result['href'])) { $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); } else { @@ -2091,39 +2095,39 @@ public function order_status() { } $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if (!$agree_status) { $this->error['warning'] = $this->language->get('error_agree'); - } - + } + if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; - } - + } + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); - + $this->response->setOutput($this->load->view('extension/payment/paypal/order_status', $data)); } - + public function contact() { if (!$this->config->get('paypal_client_id')) { $this->response->redirect($this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true)); } - + $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $this->document->addStyle('view/stylesheet/paypal/paypal.css'); $this->document->setTitle($this->language->get('heading_title_main')); - + $data['heading_title_main'] = $this->language->get('heading_title_main'); - + $data['text_edit'] = $this->language->get('text_edit'); $data['text_tab_dashboard'] = $this->language->get('text_tab_dashboard'); $data['text_tab_general'] = $this->language->get('text_tab_general'); @@ -2148,7 +2152,7 @@ public function contact() { $data['text_paypal_here'] = $this->language->get('text_paypal_here'); $data['text_payouts'] = $this->language->get('text_payouts'); $data['text_marketing_solutions'] = $this->language->get('text_marketing_solutions'); - + $data['entry_contact_company'] = $this->language->get('entry_contact_company'); $data['entry_contact_first_name'] = $this->language->get('entry_contact_first_name'); $data['entry_contact_last_name'] = $this->language->get('entry_contact_last_name'); @@ -2162,28 +2166,28 @@ public function contact() { $data['entry_contact_merchant_name'] = $this->language->get('entry_contact_merchant_name'); $data['entry_contact_product'] = $this->language->get('entry_contact_product'); $data['entry_contact_send'] = $this->language->get('entry_contact_send'); - + $data['button_save'] = $this->language->get('button_save'); $data['button_cancel'] = $this->language->get('button_cancel'); $data['button_send'] = $this->language->get('button_send'); + + $data['breadcrumbs'] = array(); - $data['breadcrumbs'] = []; - - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_extensions'), 'href' => $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('heading_title_main'), 'href' => $this->url->link('extension/payment/paypal', 'token=' . $this->session->data['token'], true) - ]; - + ); + // Action $data['href_dashboard'] = $this->url->link('extension/payment/paypal/dashboard', 'token=' . $this->session->data['token'], true); $data['href_general'] = $this->url->link('extension/payment/paypal/general', 'token=' . $this->session->data['token'], true); @@ -2195,12 +2199,12 @@ public function contact() { $data['href_message_setting'] = $this->url->link('extension/payment/paypal/message_setting', 'token=' . $this->session->data['token'], true); $data['href_order_status'] = $this->url->link('extension/payment/paypal/order_status', 'token=' . $this->session->data['token'], true); $data['href_contact'] = $this->url->link('extension/payment/paypal/contact', 'token=' . $this->session->data['token'], true); - + $data['action'] = $this->url->link('extension/payment/paypal/save', 'token=' . $this->session->data['token'], true); $data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=payment', true); $data['contact_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/sendContact', 'token=' . $this->session->data['token'], true)); $data['agree_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/agree', 'token=' . $this->session->data['token'], true)); - + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $data['server'] = HTTPS_SERVER; $data['catalog'] = HTTPS_CATALOG; @@ -2208,69 +2212,69 @@ public function contact() { $data['server'] = HTTP_SERVER; $data['catalog'] = HTTP_CATALOG; } - + $_config = new Config(); $_config->load('paypal'); - + $data['setting'] = $_config->get('paypal_setting'); - + $data['setting'] = array_replace_recursive((array)$data['setting'], (array)$this->config->get('paypal_setting')); - + $this->load->model('localisation/country'); $data['countries'] = $this->model_localisation_country->getCountries(); - + $result = $this->model_extension_payment_paypal->checkVersion(VERSION, $data['setting']['version']); - + if (!empty($result['href'])) { $data['text_version'] = sprintf($this->language->get('text_version'), $result['href']); } else { $data['text_version'] = ''; } - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if (!$agree_status) { $this->error['warning'] = $this->language->get('error_agree'); - } - + } + if (isset($this->error['warning'])) { $data['error_warning'] = $this->error['warning']; } else { $data['error_warning'] = ''; } - + $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); - + $this->response->setOutput($this->load->view('extension/payment/paypal/contact', $data)); } - + public function save() { $this->load->language('extension/payment/paypal'); - + $this->load->model('setting/setting'); - + if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $setting = $this->model_setting_setting->getSetting('paypal'); - + $setting = array_replace_recursive($setting, $this->request->post); - + $this->model_setting_setting->editSetting('paypal', $setting); - + $data['success'] = $this->language->get('success_save'); } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($data)); + $this->response->setOutput(json_encode($data)); } - + public function connect() { $this->load->language('extension/payment/paypal'); - + if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $server = HTTPS_SERVER; $catalog = HTTPS_CATALOG; @@ -2278,94 +2282,94 @@ public function connect() { $server = HTTP_SERVER; $catalog = HTTP_CATALOG; } - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - - if (!empty($this->request->post['environment']) && !empty($this->request->post['client_id']) && !empty($this->request->post['client_secret']) && !empty($this->request->post['merchant_id'])) { + + if (!empty($this->request->post['environment']) && !empty($this->request->post['client_id']) && !empty($this->request->post['client_secret']) && !empty($this->request->post['merchant_id'])) { $this->load->model('extension/payment/paypal'); - + $environment = $this->request->post['environment']; $client_id = $this->request->post['client_id']; $secret = $this->request->post['client_secret']; $merchant_id = $this->request->post['merchant_id']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $config_setting['partner'][$environment]['partner_id'], - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $result = $paypal->setAccessToken($token_info); - + if ($result) { $order_history_token = sha1(uniqid(mt_rand(), 1)); $callback_token = sha1(uniqid(mt_rand(), 1)); $webhook_token = sha1(uniqid(mt_rand(), 1)); $cron_token = sha1(uniqid(mt_rand(), 1)); - - $webhook_info = [ - 'url' => $catalog . 'index.php?route=extension/payment/paypal&webhook_token=' . $webhook_token, - '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'] - ] - ]; - + + $webhook_info = array( + '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') + ) + ); + $result = $paypal->createWebhook($webhook_info); - + $webhook_id = ''; - + if (isset($result['id'])) { $webhook_id = $result['id']; } - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + if (!$this->error) { $this->load->model('setting/setting'); - + $setting = $this->model_setting_setting->getSetting('paypal'); - + $setting['paypal_environment'] = $environment; $setting['paypal_client_id'] = $client_id; $setting['paypal_secret'] = $secret; @@ -2379,90 +2383,90 @@ public function connect() { $setting['paypal_setting']['general']['callback_token'] = $callback_token; $setting['paypal_setting']['general']['webhook_token'] = $webhook_token; $setting['paypal_setting']['general']['cron_token'] = $cron_token; - + $this->load->model('localisation/country'); - + $country = $this->model_localisation_country->getCountry($this->config->get('config_country_id')); - + $setting['paypal_setting']['general']['country_code'] = $country['iso_code_2']; - + $currency_code = $this->config->get('config_currency'); $currency_value = $this->currency->getValue($this->config->get('config_currency')); - + if (!empty($config_setting['currency'][$currency_code]['status'])) { $setting['paypal_setting']['general']['currency_code'] = $currency_code; $setting['paypal_setting']['general']['currency_value'] = $currency_value; } - + if (!empty($config_setting['currency'][$currency_code]['card_status'])) { $setting['paypal_setting']['general']['card_currency_code'] = $currency_code; $setting['paypal_setting']['general']['card_currency_value'] = $currency_value; } - + $this->model_setting_setting->editSetting('paypal', $setting); } } else { $this->error['warning'] = $this->language->get('error_connect'); } } else { - $this->error['warning'] = $this->language->get('error_connect'); + $this->error['warning'] = $this->language->get('error_connect'); } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function disconnect() { $this->load->model('setting/setting'); - + $setting = $this->model_setting_setting->getSetting('paypal'); - + $setting['paypal_client_id'] = ''; $setting['paypal_secret'] = ''; $setting['paypal_merchant_id'] = ''; $setting['paypal_webhook_id'] = ''; - + $this->model_setting_setting->editSetting('paypal', $setting); - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function callback() { 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']; $cache_data['shared_id'] = $this->request->post['shared_id']; $cache_data['seller_nonce'] = $this->request->post['seller_nonce']; - + $this->cache->set('paypal', $cache_data, 30); } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); - } - + } + public function getSaleAnalytics() { $this->load->language('extension/payment/paypal'); - $data = []; + $data = array(); $this->load->model('extension/payment/paypal'); - $data['all_sale'] = []; - $data['paypal_sale'] = []; - $data['xaxis'] = []; - + $data['all_sale'] = array(); + $data['paypal_sale'] = array(); + $data['xaxis'] = array(); + $data['all_sale']['label'] = $this->language->get('text_all_sales'); $data['paypal_sale']['label'] = $this->language->get('text_paypal_sales'); - $data['all_sale']['data'] = []; - $data['paypal_sale']['data'] = []; + $data['all_sale']['data'] = array(); + $data['paypal_sale']['data'] = array(); if (isset($this->request->get['range'])) { $range = $this->request->get['range']; @@ -2476,21 +2480,21 @@ public function getSaleAnalytics() { $results = $this->model_extension_payment_paypal->getTotalSalesByDay(); foreach ($results as $key => $value) { - $data['all_sale']['data'][] = [$key, $value['total']]; - $data['paypal_sale']['data'][] = [$key, $value['paypal_total']]; + $data['all_sale']['data'][] = array($key, $value['total']); + $data['paypal_sale']['data'][] = array($key, $value['paypal_total']); } for ($i = 0; $i < 24; $i++) { - $data['xaxis'][] = [$i, $i]; + $data['xaxis'][] = array($i, $i); } - + break; case 'week': $results = $this->model_extension_payment_paypal->getTotalSalesByWeek(); foreach ($results as $key => $value) { - $data['all_sale']['data'][] = [$key, $value['total']]; - $data['paypal_sale']['data'][] = [$key, $value['paypal_total']]; + $data['all_sale']['data'][] = array($key, $value['total']); + $data['paypal_sale']['data'][] = array($key, $value['paypal_total']); } $date_start = strtotime('-' . date('w') . ' days'); @@ -2498,220 +2502,223 @@ public function getSaleAnalytics() { for ($i = 0; $i < 7; $i++) { $date = date('Y-m-d', $date_start + ($i * 86400)); - $data['xaxis'][] = [date('w', strtotime($date)), date('D', strtotime($date))]; + $data['xaxis'][] = array(date('w', strtotime($date)), date('D', strtotime($date))); } - + break; case 'month': $results = $this->model_extension_payment_paypal->getTotalSalesByMonth(); foreach ($results as $key => $value) { - $data['all_sale']['data'][] = [$key, $value['total']]; - $data['paypal_sale']['data'][] = [$key, $value['paypal_total']]; + $data['all_sale']['data'][] = array($key, $value['total']); + $data['paypal_sale']['data'][] = array($key, $value['paypal_total']); } for ($i = 1; $i <= date('t'); $i++) { $date = date('Y') . '-' . date('m') . '-' . $i; - $data['xaxis'][] = [date('j', strtotime($date)), date('d', strtotime($date))]; + $data['xaxis'][] = array(date('j', strtotime($date)), date('d', strtotime($date))); } - + break; case 'year': $results = $this->model_extension_payment_paypal->getTotalSalesByYear(); foreach ($results as $key => $value) { - $data['all_sale']['data'][] = [$key, $value['total']]; - $data['paypal_sale']['data'][] = [$key, $value['paypal_total']]; + $data['all_sale']['data'][] = array($key, $value['total']); + $data['paypal_sale']['data'][] = array($key, $value['paypal_total']); } for ($i = 1; $i <= 12; $i++) { - $data['xaxis'][] = [$i, date('M', mktime(0, 0, 0, $i))]; + $data['xaxis'][] = array($i, date('M', mktime(0, 0, 0, $i))); } - + break; } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function downloadAssociationFile() { $environment = $this->config->get('paypal_environment'); - + if ($environment == 'production') { $file = 'https://developer.paypal.com/downloads/apple-pay/production/domain-association-file-live'; } else { $file = 'https://www.paypalobjects.com/sandbox/apple-developer-merchantid-domain-association'; } - + header('Content-Description: File Transfer'); header('Content-Type: text/plain'); header('Content-Disposition: attachment; filename="' . basename($file, '.txt') . '"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); - + readfile($file); } - + public function downloadHostAssociationFile() { $this->load->language('extension/payment/paypal'); - + $environment = $this->config->get('paypal_environment'); - + if ($environment == 'production') { $file = 'https://developer.paypal.com/downloads/apple-pay/production/domain-association-file-live'; } else { $file = 'https://www.paypalobjects.com/sandbox/apple-developer-merchantid-domain-association'; } - + $content = file_get_contents($file); - + if ($content) { $dir = str_replace('admin/', '.well-known/', DIR_APPLICATION); - + if (!file_exists($dir)) { mkdir($dir, 0777, true); } - + if (file_exists($dir)) { $fh = fopen($dir . basename($file, '.txt'), 'w'); fwrite($fh, $content); fclose($fh); } - + $data['success'] = $this->language->get('success_download_host'); } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function sendContact() { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + if (isset($this->request->post['paypal_setting']['contact'])) { $this->model_extension_payment_paypal->sendContact($this->request->post['paypal_setting']['contact']); - + $data['success'] = $this->language->get('success_send'); } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - - public function agree() { + + public function agree() { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $this->model_extension_payment_paypal->setAgreeStatus(); - + $data['success'] = $this->language->get('success_agree'); - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - - public function install() { + + public function install() { $this->load->model('extension/payment/paypal'); - + $this->model_extension_payment_paypal->install(); - + $this->load->model('extension/event'); - + $this->model_extension_event->deleteEvent('paypal_order_info'); $this->model_extension_event->deleteEvent('paypal_header'); + $this->model_extension_event->deleteEvent('paypal_content_top'); $this->model_extension_event->deleteEvent('paypal_extension_get_extensions'); $this->model_extension_event->deleteEvent('paypal_order_delete_order'); $this->model_extension_event->deleteEvent('paypal_customer_delete_customer'); - + $this->model_extension_event->addEvent('paypal_order_info', 'admin/view/sale/order_info/before', 'extension/payment/paypal/order_info_before'); - $this->model_extension_event->addEvent('paypal_header', 'catalog/controller/common/header/before', 'extension/payment/paypal/header_before'); + $this->model_extension_event->addEvent('paypal_content_top', 'catalog/controller/common/content_top/before', 'extension/payment/paypal/content_top_before'); $this->model_extension_event->addEvent('paypal_extension_get_extensions', 'catalog/model/extension/extension/getExtensions/after', 'extension/payment/paypal/extension_get_extensions_after'); $this->model_extension_event->addEvent('paypal_order_delete_order', 'catalog/model/checkout/order/deleteOrder/before', 'extension/payment/paypal/order_delete_order_before'); $this->model_extension_event->addEvent('paypal_customer_delete_customer', 'admin/model/customer/customer/deleteCustomer/before', 'extension/payment/paypal/customer_delete_customer_before'); - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting['paypal_version'] = $config_setting['version']; - + $this->load->model('setting/setting'); - + $this->model_setting_setting->editSetting('paypal_version', $setting); } - + public function uninstall() { $this->load->model('extension/payment/paypal'); - + $this->model_extension_payment_paypal->uninstall(); - + $this->load->model('extension/event'); - + $this->model_extension_event->deleteEvent('paypal_order_info'); $this->model_extension_event->deleteEvent('paypal_header'); + $this->model_extension_event->deleteEvent('paypal_content_top'); $this->model_extension_event->deleteEvent('paypal_extension_get_extensions'); $this->model_extension_event->deleteEvent('paypal_order_delete_order'); $this->model_extension_event->deleteEvent('paypal_customer_delete_customer'); - + $this->load->model('setting/setting'); - + $this->model_setting_setting->deleteSetting('paypal_version'); } - + public function update() { $this->load->model('extension/payment/paypal'); - + $this->model_extension_payment_paypal->update(); - + $this->load->model('extension/event'); - + $this->model_extension_event->deleteEvent('paypal_order_info'); $this->model_extension_event->deleteEvent('paypal_header'); + $this->model_extension_event->deleteEvent('paypal_content_top'); $this->model_extension_event->deleteEvent('paypal_extension_get_extensions'); $this->model_extension_event->deleteEvent('paypal_order_delete_order'); $this->model_extension_event->deleteEvent('paypal_customer_delete_customer'); - + $this->model_extension_event->addEvent('paypal_order_info', 'admin/view/sale/order_info/before', 'extension/payment/paypal/order_info_before'); - $this->model_extension_event->addEvent('paypal_header', 'catalog/controller/common/header/before', 'extension/payment/paypal/header_before'); + $this->model_extension_event->addEvent('paypal_content_top', 'catalog/controller/common/content_top/before', 'extension/payment/paypal/content_top_before'); $this->model_extension_event->addEvent('paypal_extension_get_extensions', 'catalog/model/extension/extension/getExtensions/after', 'extension/payment/paypal/extension_get_extensions_after'); $this->model_extension_event->addEvent('paypal_order_delete_order', 'catalog/model/checkout/order/deleteOrder/before', 'extension/payment/paypal/order_delete_order_before'); $this->model_extension_event->addEvent('paypal_customer_delete_customer', 'admin/model/customer/customer/deleteCustomer/before', 'extension/payment/paypal/customer_delete_customer_before'); - - if ($this->config->get('paypal_version') < '3.1.0') { + + if ($this->config->get('paypal_version') < '3.1.0') { $this->load->model('setting/setting'); - + $setting = $this->model_setting_setting->getSetting('paypal'); - + $setting['paypal_setting']['general']['order_history_token'] = sha1(uniqid(mt_rand(), 1)); - + $this->model_setting_setting->editSetting('paypal', $setting); } - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting['paypal_version'] = $config_setting['version']; - + $this->load->model('setting/setting'); - + $this->model_setting_setting->editSetting('paypal_version', $setting); } - + public function customer_delete_customer_before($route, &$data) { $this->load->model('extension/payment/paypal'); @@ -2719,43 +2726,43 @@ public function customer_delete_customer_before($route, &$data) { $this->model_extension_payment_paypal->deletePayPalCustomerTokens($customer_id); } - + public function order_info_before($route, &$data) { if ($this->config->get('paypal_status') && !empty($this->request->get['order_id'])) { - $this->load->language('extension/payment/paypal','extension_payment_paypal'); - + $this->load->language('extension/payment/paypal'); + $content = $this->getPaymentDetails((int)$this->request->get['order_id']); - - if ($content) { - $data['tabs'][] = [ - 'code' => 'paypal', - 'title' => $this->language->get('extension_payment_paypal')->get('heading_title_main'), - 'content' => $content - ]; + + if ($content) { + $data['tabs'][] = array( + 'code' => 'paypal', + 'title' => $this->language->get('heading_title_main'), + 'content' => $content + ); } } } - + public function getPaymentInfo() { $content = ''; - + if (!empty($this->request->get['order_id'])) { $this->load->language('payment/paypal'); - + $content = $this->getPaymentDetails((int)$this->request->get['order_id']); } - + $this->response->setOutput($content); } - + private function getPaymentDetails($order_id) { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); $this->load->model('sale/order'); - + $order_info = $this->model_sale_order->getOrder($order_id); - + $paypal_order_info = $this->model_extension_payment_paypal->getPayPalOrder($order_id); if ($order_info && $paypal_order_info) { @@ -2770,10 +2777,10 @@ private function getPaymentDetails($order_id) { $data['text_transaction_pending'] = $this->language->get('text_transaction_pending'); $data['text_transaction_refunded'] = $this->language->get('text_transaction_refunded'); $data['text_transaction_partially_refunded'] = $this->language->get('text_transaction_partially_refunded'); - $data['text_transaction_reversed'] = $this->language->get('text_transaction_reversed'); + $data['text_transaction_reversed'] = $this->language->get('text_transaction_reversed'); $data['text_transaction_comment'] = $this->language->get('text_transaction_comment'); $data['text_transaction_notify'] = $this->language->get('text_transaction_notify'); - $data['text_transaction_action'] = $this->language->get('text_transaction_action'); + $data['text_transaction_action'] = $this->language->get('text_transaction_action'); $data['text_final_capture'] = $this->language->get('text_final_capture'); $data['text_tracker_information'] = $this->language->get('text_tracker_information'); $data['text_tracking_number'] = $this->language->get('text_tracking_number'); @@ -2781,33 +2788,33 @@ private function getPaymentDetails($order_id) { $data['text_tracker_comment'] = $this->language->get('text_tracker_comment'); $data['text_tracker_notify'] = $this->language->get('text_tracker_notify'); $data['text_tracker_action'] = $this->language->get('text_tracker_action'); - + $data['button_capture_payment'] = $this->language->get('button_capture_payment'); $data['button_reauthorize_payment'] = $this->language->get('button_reauthorize_payment'); $data['button_void_payment'] = $this->language->get('button_void_payment'); $data['button_refund_payment'] = $this->language->get('button_refund_payment'); $data['button_create_tracker'] = $this->language->get('button_create_tracker'); $data['button_cancel_tracker'] = $this->language->get('button_cancel_tracker'); - + $data['order_id'] = $order_id; $data['paypal_order_id'] = $paypal_order_info['paypal_order_id']; $data['transaction_id'] = $paypal_order_info['transaction_id']; $data['transaction_status'] = $paypal_order_info['transaction_status']; - + $data['order_id'] = $order_id; $data['paypal_order_id'] = $paypal_order_info['paypal_order_id']; $data['transaction_id'] = $paypal_order_info['transaction_id']; $data['transaction_status'] = $paypal_order_info['transaction_status']; - + if ($paypal_order_info['environment'] == 'production') { $data['transaction_url'] = 'https://www.paypal.com/activity/payment/' . $data['transaction_id']; } else { $data['transaction_url'] = 'https://www.sandbox.paypal.com/activity/payment/' . $data['transaction_id']; } - + $data['tracking_number'] = $paypal_order_info['tracking_number']; $data['carrier_name'] = $paypal_order_info['carrier_name']; - + $data['info_payment_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/getPaymentInfo', 'token=' . $this->session->data['token'] . '&order_id=' . $data['order_id'], true)); $data['capture_payment_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/capturePayment', 'token=' . $this->session->data['token'], true)); $data['reauthorize_payment_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/reauthorizePayment', 'token=' . $this->session->data['token'], true)); @@ -2817,32 +2824,32 @@ private function getPaymentDetails($order_id) { $data['create_tracker_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/createTracker', 'token=' . $this->session->data['token'], true)); $data['cancel_tracker_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/cancelTracker', 'token=' . $this->session->data['token'], true)); $data['info_order_history_url'] = str_replace('&', '&', $this->url->link('sale/order/history', 'token=' . $this->session->data['token'] . '&order_id=' . $data['order_id'], true)); - + $data['country_code'] = ''; - + $country_id = $this->config->get('config_country_id'); - + if ($order_info['shipping_country_id']) { $country_id = $order_info['shipping_country_id']; } if ($country_id) { $this->load->model('localisation/country'); - + $country_info = $this->model_localisation_country->getCountry($order_info['shipping_country_id']); - + if ($country_info) { $data['country_code'] = $country_info['iso_code_3']; } } - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('payment_paypal_setting')); - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $environment = $this->config->get('paypal_environment'); @@ -2850,108 +2857,108 @@ private function getPaymentDetails($order_id) { $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; $vault_status = $setting['general']['vault_status']; $transaction_method = $setting['general']['transaction_method']; - + $decimal_place = $setting['currency'][$paypal_order_info['currency_code']]['decimal_place']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $paypal_order_info = $paypal->getOrder($data['paypal_order_id']); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + $authorization_amount = 0; $capture_amount = 0; $refund_amount = 0; - + if (isset($paypal_order_info['purchase_units'][0]['payments']) && !$this->error) { $payments = $paypal_order_info['purchase_units'][0]['payments']; - + $transaction_id = $data['transaction_id']; $transaction_status = $data['transaction_status']; if (!empty($payments['authorizations'])) { - foreach ($payments['authorizations'] as $authorization) { + foreach ($payments['authorizations'] as $authorization) { $transaction_id = $authorization['id']; - + if (($authorization['status'] == 'CREATED') || ($authorization['status'] == 'PENDING')) { $transaction_status = 'created'; } - + if ($authorization['status'] == 'CAPTURED') { $transaction_status = 'completed'; } - + if ($authorization['status'] == 'PARTIALLY_CAPTURED') { $transaction_status = 'partially_captured'; } - + if ($authorization['status'] == 'VOIDED') { $transaction_status = 'voided'; } - + if (($authorization['status'] == 'CREATED') || ($authorization['status'] == 'CAPTURED') || ($authorization['status'] == 'PARTIALLY_CAPTURED') || ($authorization['status'] == 'PENDING')) { $authorization_amount = $authorization['amount']['value']; } } } - + if (!empty($payments['captures'])) { foreach ($payments['captures'] as $capture) { if (($capture['status'] == 'COMPLETED') && ($transaction_status == 'completed')) { $transaction_id = $capture['id']; $transaction_status = 'completed'; } - + if ($capture['status'] == 'PARTIALLY_REFUNDED') { $transaction_status = 'partially_refunded'; } - + if ($capture['status'] == 'REFUNDED') { $transaction_status = 'refunded'; } - + if (($capture['status'] == 'COMPLETED') || ($capture['status'] == 'PARTIALLY_REFUNDED') || ($capture['status'] == 'REFUNDED')) { - $capture_amount += $capture['amount']['value']; + $capture_amount += $capture['amount']['value']; } } } - + if (!empty($payments['refunds'])) { foreach ($payments['refunds'] as $refund) { if ($refund['status'] == 'COMPLETED') { @@ -2959,129 +2966,128 @@ private function getPaymentDetails($order_id) { } } } - - $paypal_order_data = []; - + + $paypal_order_data = array(); + $paypal_order_data['order_id'] = $order_id; $paypal_order_data['transaction_status'] = $transaction_status; - $paypal_order_data['transaction_id'] = $transaction_id; + $paypal_order_data['transaction_id'] = $transaction_id; $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); - + $data['transaction_id'] = $transaction_id; $data['transaction_status'] = $transaction_status; } - + $data['capture_amount'] = number_format($authorization_amount - $capture_amount, $decimal_place, '.', ''); $data['reauthorize_amount'] = number_format($authorization_amount, $decimal_place, '.', ''); $data['refund_amount'] = number_format($capture_amount - $refund_amount, $decimal_place, '.', ''); - + return $this->load->view('extension/payment/paypal/order', $data); } - + return ''; } - - public function capturePayment() { + + public function capturePayment() { if ($this->config->get('paypal_status') && !empty($this->request->post['order_id'])) { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); $this->load->model('sale/order'); - + $order_id = (int)$this->request->post['order_id']; $capture_amount = (float)$this->request->post['capture_amount']; - + if (!empty($this->request->post['final_capture'])) { $final_capture = true; } else { $final_capture = false; } - + $comment = $this->request->post['comment']; - + if (!empty($this->request->post['notify'])) { $notify = true; } else { $notify = false; } - + $order_info = $this->model_sale_order->getOrder($order_id); - + $paypal_order_info = $this->model_extension_payment_paypal->getPayPalOrder($order_id); if ($order_info && $paypal_order_info) { $transaction_id = $paypal_order_info['transaction_id']; $currency_code = $paypal_order_info['currency_code']; $order_status_id = 0; - $transaction_status = ''; - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $environment = $this->config->get('paypal_environment'); $partner_id = $setting['partner'][$environment]['partner_id']; $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; $transaction_method = $setting['general']['transaction_method']; - + $decimal_place = $setting['currency'][$paypal_order_info['currency_code']]['decimal_place']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - - $transaction_info = [ - 'amount' => [ - 'value' => number_format($capture_amount, $decimal_place, '.', ''), + + $transaction_info = array( + 'amount' => array( + '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 = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + if (isset($result['id']) && isset($result['status']) && !$this->error) { $result = $paypal->getPaymentAuthorize($transaction_id); @@ -3093,268 +3099,274 @@ public function capturePayment() { $order_status_id = $setting['order_status']['partially_captured']['id']; $transaction_status = 'partially_captured'; } - - if ($order_status_id) { - $this->model_extension_payment_paypal->addOrderHistory($setting['general']['order_history_token'], $order_id, $order_status_id, $comment, $notify); - } - - $paypal_order_data = []; - + + $paypal_order_data = array(); + $paypal_order_data['order_id'] = $order_id; - $paypal_order_data['transaction_id'] = $transaction_id; + $paypal_order_data['transaction_id'] = $transaction_id; $paypal_order_data['transaction_status'] = $transaction_status; $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); - + + if ($order_status_id && ($order_info['order_status_id'] != $order_status_id) && !in_array($order_info['order_status_id'], $setting['final_order_status'])) { + $this->model_extension_payment_paypal->addOrderHistory($setting['general']['order_history_token'], $order_id, $order_status_id, $comment, $notify); + } + $data['success'] = $this->language->get('success_capture_payment'); } } } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function reauthorizePayment() { if ($this->config->get('paypal_status') && !empty($this->request->post['order_id'])) { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $this->load->model('sale/order'); + $order_id = (int)$this->request->post['order_id']; $reauthorize_amount = (float)$this->request->post['reauthorize_amount']; $comment = $this->request->post['comment']; - + if (!empty($this->request->post['notify'])) { $notify = true; } else { $notify = false; } - + + $order_info = $this->model_sale_order->getOrder($order_id); + $paypal_order_info = $this->model_extension_payment_paypal->getPayPalOrder($order_id); - if ($paypal_order_info) { + if ($order_info && $paypal_order_info) { $transaction_id = $paypal_order_info['transaction_id']; $currency_code = $paypal_order_info['currency_code']; $order_status_id = 0; $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $environment = $this->config->get('paypal_environment'); $partner_id = $setting['partner'][$environment]['partner_id']; $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; $transaction_method = $setting['general']['transaction_method']; - + $decimal_place = $setting['currency'][$paypal_order_info['currency_code']]['decimal_place']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - - $transaction_info = [ - 'amount' => [ - 'value' => number_format($reauthorize_amount, $decimal_place, '.', ''), + + $transaction_info = array( + '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 = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + if (isset($result['id']) && isset($result['status']) && !$this->error) { $order_status_id = $setting['order_status']['pending']['id']; $transaction_id = $result['id']; $transaction_status = 'created'; - - if ($order_status_id) { - $this->model_extension_payment_paypal->addOrderHistory($setting['general']['order_history_token'], $order_id, $order_status_id, $comment, $notify); - } - - $paypal_order_data = [ - 'order_id' => $order_id, - 'transaction_id' => $transaction_id, + + $paypal_order_data = array( + 'order_id' => $order_id, + 'transaction_id' => $transaction_id, 'transaction_status' => $transaction_status - ]; - + ); + $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); - + + if ($order_status_id && ($order_info['order_status_id'] != $order_status_id) && !in_array($order_info['order_status_id'], $setting['final_order_status'])) { + $this->model_extension_payment_paypal->addOrderHistory($setting['general']['order_history_token'], $order_id, $order_status_id, $comment, $notify); + } + $data['success'] = $this->language->get('success_reauthorize_payment'); } } } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function voidPayment() { if ($this->config->get('paypal_status') && !empty($this->request->post['order_id'])) { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $this->load->model('sale/order'); + $order_id = (int)$this->request->post['order_id']; $comment = $this->request->post['comment']; - + if (!empty($this->request->post['notify'])) { $notify = true; } else { $notify = false; } - + + $order_info = $this->model_sale_order->getOrder($order_id); + $paypal_order_info = $this->model_extension_payment_paypal->getPayPalOrder($order_id); - if ($paypal_order_info) { + if ($order_info && $paypal_order_info) { $transaction_id = $paypal_order_info['transaction_id']; $order_status_id = 0; - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $environment = $this->config->get('paypal_environment'); $partner_id = $setting['partner'][$environment]['partner_id']; $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; $transaction_method = $setting['general']['transaction_method']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $result = $paypal->setPaymentVoid($transaction_id); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + if (!$this->error) { $order_status_id = $setting['order_status']['voided']['id']; $transaction_status = 'voided'; - - if ($order_status_id) { - $this->model_extension_payment_paypal->addOrderHistory($setting['general']['order_history_token'], $order_id, $order_status_id, $comment, $notify); - } - - $paypal_order_data = [ - 'order_id' => $order_id, + + $paypal_order_data = array( + 'order_id' => $order_id, 'transaction_status' => $transaction_status - ]; + ); $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); - + + if ($order_status_id && ($order_info['order_status_id'] != $order_status_id) && !in_array($order_info['order_status_id'], $setting['final_order_status'])) { + $this->model_extension_payment_paypal->addOrderHistory($setting['general']['order_history_token'], $order_id, $order_status_id, $comment, $notify); + } + $data['success'] = $this->language->get('success_void_payment'); } } } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function refundPayment() { if ($this->config->get('paypal_status') && !empty($this->request->post['order_id'])) { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); $this->load->model('sale/order'); - + $order_id = (int)$this->request->post['order_id']; $refund_amount = (float)$this->request->post['refund_amount']; $comment = $this->request->post['comment']; - + if (!empty($this->request->post['notify'])) { $notify = true; } else { $notify = false; } - + $order_info = $this->model_sale_order->getOrder($order_id); - + $paypal_order_info = $this->model_extension_payment_paypal->getPayPalOrder($order_id); if ($order_info && $paypal_order_info) { @@ -3362,60 +3374,60 @@ public function refundPayment() { $transaction_status = $paypal_order_info['transaction_status']; $currency_code = $paypal_order_info['currency_code']; $order_status_id = 0; - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $environment = $this->config->get('paypal_environment'); $partner_id = $setting['partner'][$environment]['partner_id']; $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; $transaction_method = $setting['general']['transaction_method']; - + $decimal_place = $setting['currency'][$paypal_order_info['currency_code']]['decimal_place']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $paypal_order_info = $paypal->getOrder($paypal_order_info['paypal_order_id']); - - $capture_refund_amount = []; + + $capture_refund_amount = array(); $available_refund_amount = 0; $final_capture_amount = 0; - + if (isset($paypal_order_info['purchase_units'][0]['payments'])) { $payments = $paypal_order_info['purchase_units'][0]['payments']; - + if (!empty($payments['refunds'])) { foreach ($payments['refunds'] as $refund) { if ($refund['status'] == 'COMPLETED') { foreach ($refund['links'] as $refund_link) { if ($refund_link['rel'] == 'up') { $pos = strpos($refund_link['href'], '/captures/'); - + if ($pos !== false) { $capture_id = substr($refund_link['href'], $pos + 10); - + if (empty($capture_refund_amount[$capture_id])) { $capture_refund_amount[$capture_id] = $refund['amount']['value']; } else { @@ -3427,108 +3439,108 @@ public function refundPayment() { } } } - + if (!empty($payments['captures'])) { foreach ($payments['captures'] as $capture) { if (($capture['status'] == 'COMPLETED')) { $available_refund_amount += $capture['amount']['value']; } - + if ($capture['status'] == 'PARTIALLY_REFUNDED') { if (!empty($capture_refund_amount[$capture['id']])) { $available_refund_amount += ($capture['amount']['value'] - $capture_refund_amount[$capture['id']]); } } - + if ($capture['id'] == $transaction_id) { $final_capture_amount = $capture['amount']['value']; } } } - + if ($refund_amount > $available_refund_amount) { - $transaction_info = [ - 'amount' => [ - 'value' => number_format($refund_amount, $decimal_place, '.', ''), + $transaction_info = array( + 'amount' => array( + 'value' => number_format($refund_amount, $decimal_place, '.', ''), 'currency_code' => $currency_code - ] - ]; + ) + ); $result = $paypal->setPaymentRefund($transaction_id, $transaction_info); } else { if (($transaction_status == 'completed') && ($refund_amount < $available_refund_amount) && (count($payments['captures']) > 1)) { $final_capture_first_amount = 0; - + if ($refund_amount < $final_capture_amount) { $final_capture_first_amount = $refund_amount * 0.5; } else { $final_capture_first_amount = $final_capture_amount * 0.5; } - - $transaction_info = [ - 'amount' => [ - 'value' => number_format($final_capture_first_amount * 0.5, $decimal_place, '.', ''), + + $transaction_info = array( + 'amount' => array( + 'value' => number_format($final_capture_first_amount * 0.5, $decimal_place, '.', ''), 'currency_code' => $currency_code - ] - ]; + ) + ); $result = $paypal->setPaymentRefund($transaction_id, $transaction_info); - + $refund_amount -= ($final_capture_first_amount * 0.5); } - + if (!empty($payments['captures'])) { foreach ($payments['captures'] as $capture) { if ($refund_amount > 0) { if (($capture['status'] == 'COMPLETED')) { if ($refund_amount <= $capture['amount']['value']) { - $transaction_info = [ - 'amount' => [ - 'value' => number_format($refund_amount, $decimal_place, '.', ''), + $transaction_info = array( + 'amount' => array( + 'value' => number_format($refund_amount, $decimal_place, '.', ''), 'currency_code' => $currency_code - ] - ]; + ) + ); $result = $paypal->setPaymentRefund($capture['id'], $transaction_info); - + $refund_amount = 0; } else { - $transaction_info = [ - 'amount' => [ - 'value' => number_format($capture['amount']['value'], $decimal_place, '.', ''), + $transaction_info = array( + 'amount' => array( + 'value' => number_format($capture['amount']['value'], $decimal_place, '.', ''), 'currency_code' => $currency_code - ] - ]; + ) + ); $result = $paypal->setPaymentRefund($capture['id'], $transaction_info); - + $refund_amount -= $capture['amount']['value']; } } - + 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 = [ - 'amount' => [ - 'value' => number_format($refund_amount, $decimal_place, '.', ''), + $transaction_info = array( + 'amount' => array( + 'value' => number_format($refund_amount, $decimal_place, '.', ''), 'currency_code' => $currency_code - ] - ]; + ) + ); $result = $paypal->setPaymentRefund($capture['id'], $transaction_info); - + $refund_amount = 0; } else { - $transaction_info = [ - 'amount' => [ - 'value' => number_format($capture['amount']['value'] - $capture_refund_amount[$capture['id']], $decimal_place, '.', ''), + $transaction_info = array( + 'amount' => array( + 'value' => number_format($capture['amount']['value'] - $capture_refund_amount[$capture['id']], $decimal_place, '.', ''), 'currency_code' => $currency_code - ] - ]; + ) + ); $result = $paypal->setPaymentRefund($capture['id'], $transaction_info); - + $refund_amount -= ($capture['amount']['value'] - $capture_refund_amount[$capture['id']]); } } @@ -3538,29 +3550,29 @@ public function refundPayment() { } } } - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + if (isset($result['id']) && isset($result['status']) && !$this->error) { $result = $paypal->getPaymentCapture($transaction_id); @@ -3571,397 +3583,394 @@ public function refundPayment() { $order_status_id = $setting['order_status']['partially_refunded']['id']; $transaction_status = 'partially_refunded'; } - - if ($order_status_id) { - $this->model_extension_payment_paypal->addOrderHistory($setting['general']['order_history_token'], $order_id, $order_status_id, $comment, $notify); - } - - $paypal_order_data = []; - - $paypal_order_data['order_id'] = $order_id; + + $paypal_order_data = array(); + + $paypal_order_data['order_id'] = $order_id; $paypal_order_data['transaction_status'] = $transaction_status; $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); - + + if ($order_status_id && ($order_info['order_status_id'] != $order_status_id) && !in_array($order_info['order_status_id'], $setting['final_order_status'])) { + $this->model_extension_payment_paypal->addOrderHistory($setting['general']['order_history_token'], $order_id, $order_status_id, $comment, $notify); + } + $data['success'] = $this->language->get('success_refund_payment'); } } } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function autocompleteCarrier() { $this->load->model('extension/payment/paypal'); - - $data = []; - - if (!empty($this->request->post['filter_country_code']) && !empty($this->request->post['filter_carrier_name'])) { + + $data = array(); + + if (!empty($this->request->post['filter_country_code']) && !empty($this->request->post['filter_carrier_name'])) { $filter_country_code = $this->request->post['filter_country_code']; $filter_carrier_name = $this->request->post['filter_carrier_name']; - + $_config = new Config(); $_config->load('paypal_carrier'); - + $config_carrier = $_config->get('paypal_carrier'); - - $carriers = []; - + + $carriers = array(); + if (!empty($config_carrier[$filter_country_code])) { $carriers = $config_carrier[$filter_country_code]; } - - $carriers += $config_carrier['GLOBAL']; - + + $carriers = $carriers + $config_carrier['GLOBAL']; + foreach ($carriers as $carrier_name => $carrier_code) { if (strpos(strtolower($carrier_name), strtolower($filter_carrier_name)) !== false) { - $data[] = [ + $data[] = array( 'name' => $carrier_name, 'code' => $carrier_code - ]; + ); } } - } - + } + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - - public function createTracker() { + + public function createTracker() { if ($this->config->get('paypal_status') && !empty($this->request->post['order_id'])) { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - - $order_id = (int)$this->request->post['order_id']; + $this->load->model('sale/order'); + + $order_id = $this->request->post['order_id']; $country_code = $this->request->post['country_code']; $tracking_number = $this->request->post['tracking_number']; $carrier_name = $this->request->post['carrier_name']; $comment = $this->request->post['comment']; - + if (!empty($this->request->post['notify'])) { $notify = true; } else { $notify = false; } - + + $order_info = $this->model_sale_order->getOrder($order_id); + $paypal_order_info = $this->model_extension_payment_paypal->getPayPalOrder($order_id); - if ($paypal_order_info) { + if ($order_info && $paypal_order_info) { $paypal_order_id = $paypal_order_info['paypal_order_id']; $transaction_id = $paypal_order_info['transaction_id']; - + $_config = new Config(); $_config->load('paypal_carrier'); - + $config_carrier = $_config->get('paypal_carrier'); - - $carriers = []; - + + $carriers = array(); + if (!empty($config_carrier[$country_code])) { $carriers = $config_carrier[$country_code]; } - - $carriers += $config_carrier['GLOBAL']; - + + $carriers = $carriers + $config_carrier['GLOBAL']; + $carrier_code = 'OTHER'; - + if (!empty($carriers[$carrier_name])) { $carrier_code = $carriers[$carrier_name]; } - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $environment = $this->config->get('paypal_environment'); $partner_id = $setting['partner'][$environment]['partner_id']; $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; $transaction_method = $setting['general']['transaction_method']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - - $tracker_info = []; - + + $tracker_info = array(); + $tracker_info['capture_id'] = $transaction_id; $tracker_info['tracking_number'] = $tracking_number; $tracker_info['carrier'] = $carrier_code; $tracker_info['notify_payer'] = $notify; - + if ($carrier_code == 'OTHER') { $tracker_info['carrier_name_other'] = $carrier_name; } - + $result = $paypal->createOrderTracker($paypal_order_id, $tracker_info); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - - if (isset($result['id']) && isset($result['status']) && !$this->error) { - $paypal_order_data = [ - 'order_id' => $order_id, + + if (isset($result['id']) && isset($result['status']) && !$this->error) { + $paypal_order_data = array( + 'order_id' => $order_id, 'tracking_number' => $tracking_number, - 'carrier_name' => $carrier_name - ]; - + 'carrier_name' => $carrier_name + ); + $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); - - $this->load->model('sale/order'); - - $order_info = $this->model_sale_order->getOrder($order_id); - - if ($order_info) { - $order_status_id = $setting['order_status']['shipped']['id']; - - if ($order_status_id) { - $this->model_extension_payment_paypal->addOrderHistory($setting['general']['order_history_token'], $order_id, $order_status_id, $comment, $notify); - } + + $order_status_id = $setting['order_status']['shipped']['id']; + + if ($order_status_id && ($order_info['order_status_id'] != $order_status_id) && !in_array($order_info['order_status_id'], $setting['final_order_status'])) { + $this->model_extension_payment_paypal->addOrderHistory($setting['general']['order_history_token'], $order_id, $order_status_id, $comment, $notify); } - + $data['success'] = $this->language->get('success_create_tracker'); } } } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - - public function cancelTracker() { + + public function cancelTracker() { if ($this->config->get('paypal_status') && !empty($this->request->post['order_id'])) { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - - $order_id = (int)$this->request->post['order_id']; + + $order_id = $this->request->post['order_id']; $tracking_number = $this->request->post['tracking_number']; - + $paypal_order_info = $this->model_extension_payment_paypal->getPayPalOrder($order_id); if ($paypal_order_info) { $paypal_order_id = $paypal_order_info['paypal_order_id']; - $transaction_id = $paypal_order_info['transaction_id']; - + $transaction_id = $paypal_order_info['transaction_id']; + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('_paypal_setting')); - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $environment = $this->config->get('paypal_environment'); $partner_id = $setting['partner'][$environment]['partner_id']; $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; $transaction_method = $setting['general']['transaction_method']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - - $tracker_info = []; - - $tracker_info[] = [ - 'op' => 'replace', - 'path' => '/status', + + $tracker_info = array(); + + $tracker_info[] = array( + 'op' => 'replace', + 'path' => '/status', 'value' => 'CANCELLED' - ]; - + ); + $result = $paypal->updateOrderTracker($paypal_order_id, $transaction_id . '-' . $tracking_number, $tracker_info); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - - if (!$this->error) { - $paypal_order_data = [ - 'order_id' => $order_id, + + if (!$this->error) { + $paypal_order_data = array( + 'order_id' => $order_id, 'tracking_number' => '', - 'carrier_name' => '' - ]; - + 'carrier_name' => '' + ); + $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); - + $data['success'] = $this->language->get('success_cancel_tracker'); } } } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function recurringButtons() { $content = ''; - + if ($this->config->get('paypal_status') && !empty($this->request->get['order_recurring_id'])) { $this->load->language('extension/payment/paypal'); - + $this->load->model('sale/recurring'); - + $data['order_recurring_id'] = $this->request->get['order_recurring_id']; $order_recurring_info = $this->model_sale_recurring->getRecurring($data['order_recurring_id']); - + if ($order_recurring_info) { $data['button_enable_recurring'] = $this->language->get('button_enable_recurring'); $data['button_disable_recurring'] = $this->language->get('button_disable_recurring'); - + $data['recurring_status'] = $order_recurring_info['status']; $data['info_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/getRecurringInfo', 'token=' . $this->session->data['token'] . '&order_recurring_id=' . $data['order_recurring_id'], true)); $data['enable_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/enableRecurring', 'token=' . $this->session->data['token'], true)); $data['disable_url'] = str_replace('&', '&', $this->url->link('extension/payment/paypal/disableRecurring', 'token=' . $this->session->data['token'], true)); - + $content = $this->load->view('extension/payment/paypal/recurring', $data); } } - + return $content; } - + public function getRecurringInfo() { $this->response->setOutput($this->recurringButtons()); } - + public function enableRecurring() { if ($this->config->get('paypal_status') && !empty($this->request->post['order_recurring_id'])) { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $order_recurring_id = $this->request->post['order_recurring_id']; - + $this->model_extension_payment_paypal->editOrderRecurringStatus($order_recurring_id, 1); - - $data['success'] = $this->language->get('success_enable_recurring'); + + $data['success'] = $this->language->get('success_enable_recurring'); } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function disableRecurring() { if ($this->config->get('paypal_status') && !empty($this->request->post['order_recurring_id'])) { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $order_recurring_id = $this->request->post['order_recurring_id']; - + $this->model_extension_payment_paypal->editOrderRecurringStatus($order_recurring_id, 2); - - $data['success'] = $this->language->get('success_disable_recurring'); + + $data['success'] = $this->language->get('success_disable_recurring'); } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + private function validate() { if (!$this->user->hasPermission('modify', 'extension/payment/paypal')) { $this->error['warning'] = $this->language->get('error_permission'); } - + return !$this->error; } - + private function token($length = 32) { // Create random token $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - + $max = strlen($string) - 1; - + $token = ''; - + for ($i = 0; $i < $length; $i++) { $token .= $string[mt_rand(0, $max)]; - } - + } + return $token; } -} +} \ No newline at end of file diff --git a/upload/admin/language/en-gb/extension/payment/paypal.php b/upload/admin/language/en-gb/extension/payment/paypal.php index be2c7959..7527e97b 100644 --- a/upload/admin/language/en-gb/extension/payment/paypal.php +++ b/upload/admin/language/en-gb/extension/payment/paypal.php @@ -1,6 +1,6 @@ PayPal Checkout Integration (Highly Recommended)'; +$_['heading_title'] = 'PayPal Checkout Integration (Highly Recommended)'; $_['heading_title_main'] = 'PayPal Checkout Integration'; // Text @@ -57,7 +57,7 @@ $_['text_applepay_step_2'] = 'Register your live domain
1. Go to the Payment Methods page on your PayPal account.
2. Register all high-level domains such as business.example.com, and subdomains such as checkout.business.example.com, that show the Apple Pay button.'; $_['text_message_alert_uk'] = 'Turn browsers into buyers with Pay in 3.¹ Help increase sales while giving your customers flexible payments and more buying power. With Pay in 3, customers can pay over time in three interest-free payments while you get paid in full, up front on purchases — at no additional cost.'; $_['text_message_footnote_uk'] = '¹Pay in 3 availability is subject to merchant status, sector and integration. Consumer eligibility is subject to status and approval. See product terms for more details.'; -$_['text_message_alert_us'] = "Help increase your sales with our built-in Pay Later options.\u{a0}With PayPal Pay Later, your business can offer Pay in 4 and Pay Monthly¹ — two valuable ways for your customers to make a purchase and pay for it over time while you get paid in full, up front. Both are included at no additional cost to your business."; +$_['text_message_alert_us'] = 'Help increase your sales with our built-in Pay Later options. With PayPal Pay Later, your business can offer Pay in 4 and Pay Monthly¹ — two valuable ways for your customers to make a purchase and pay for it over time while you get paid in full, up front. Both are included at no additional cost to your business.'; $_['text_message_footnote_us'] = '¹About Pay in 4: Loans to California residents are made or arranged pursuant to a California Financing Law License. PayPal, Inc. is a Georgia Installment Lender Licensee, NMLS #910457. Rhode Island Small Loan Lender Licensee.
Pay Monthly is subject to consumer credit approval. 9.99-29.99% APR based on the customer’s creditworthiness. PayPal, Inc.: RI Loan Broker Licensee. The lender for Pay Monthly is WebBank.'; $_['text_currency_aud'] = 'Australian Dollar'; $_['text_currency_brl'] = 'Brazilian Real'; @@ -164,7 +164,7 @@ $_['text_credit_installments'] = 'PayPal Credit'; $_['text_point_of_sale'] = 'PayPal InStore'; $_['text_invoicing_api'] = 'Invoicing'; -$_['text_paypal_working_capital'] = 'Working Capital/Bsuiness Loans'; +$_['text_paypal_working_capital'] = 'Working Capital/Business Loans'; $_['text_risk_servicing'] = 'Risk Servicing'; $_['text_paypal_here'] = 'Subscriptions'; $_['text_payouts'] = 'Payouts'; @@ -276,6 +276,7 @@ $_['entry_cvv'] = 'CVV'; $_['entry_message_insert_tag'] = 'Message Insert Tag'; $_['entry_message_insert_type'] = 'Message Insert Type'; +$_['entry_final_order_status'] = 'Final Order Status'; $_['entry_contact_company'] = 'Company'; $_['entry_contact_first_name'] = 'First Name'; $_['entry_contact_last_name'] = 'Last Name'; @@ -293,12 +294,12 @@ // Help $_['help_status'] = 'Enable/Disable extension.'; $_['help_vault_status'] = 'Vault allows merchant to securely save buyer’s payment method for future transactions. Vault substitutes the sensitive payment data with non-sensitive payment token and allows merchant to use the payment Token for future purchases.'; -$_['help_button_status'] = 'When activated PayPal will display personalized Smart Buttons avalible to your customers based on their location.'; +$_['help_button_status'] = 'When activated PayPal will display personalized Smart Buttons available to your customers based on their location.'; $_['help_googlepay_button_status'] = 'PayPal verifies if you are eligible for Google Pay payment and will display this option on the checkout step if available.'; $_['help_applepay_button_status'] = 'PayPal verifies if you are eligible for Apple Pay payment and will display this option on the checkout step if available.'; $_['help_card_status'] = 'PayPal verifies if you are eligible for advanced card payment and will display this option on the checkout step if available.'; $_['help_checkout_mode'] = 'If your checkout is incompatible with this payment, then we advise you to set the \'One Button\' mode.'; -$_['help_checkout_route'] = 'If your checkout has its own route, different from OpenCart\'s (checkout/checkout), then enter it here.'; +$_['help_checkout_route'] = 'If your checkout has its own route, different from the default route (checkout/checkout), then enter it here.'; $_['help_total'] = 'The checkout total the order must reach before this payment method becomes active.'; $_['help_country_code'] = 'Select the default country for PayPal.'; $_['help_currency_code'] = 'Select the default currency for PayPal.'; @@ -307,7 +308,8 @@ $_['help_card_currency_value'] = 'Set to 1.00000 if this is your default currency.'; $_['help_cron_url'] = 'Set a cron to call this URL. This integration is typically used for subscription/recurring product purchase.'; $_['help_card_secure_method'] = '3D Secure enables you to authenticate card holders through card issuers. \'SCA Always\' method trigger 3D Secure for every transaction, regardless of SCA requirements. \'SCA When Required\' method returns a 3D Secure contingency when it is a mandate in the region where you operate.'; -$_['help_card_secure_scenario'] = '3D Secure authentication is perfomed only if the card is enrolled for the service. In scenarios where the 3D Secure authentication has not been successful, you have the option to complete the payment at your own risk, meaning that you -the merchant- will be liable in case of a chargeback.'; +$_['help_card_secure_scenario'] = '3D Secure authentication is performed only if the card is enrolled for the service. In scenarios where the 3D Secure authentication has not been successful, you have the option to complete the payment at your own risk, meaning that you -the merchant- will be liable in case of a chargeback.'; +$_['help_final_order_status'] = 'Set the order status to final and PayPal will not be able to change it.'; // Button $_['button_connect'] = 'Connect'; @@ -332,7 +334,7 @@ // Success $_['success_save'] = 'Success: You have modified PayPal!'; -$_['success_send'] = 'Success: Your contact details have been successfully sent to paypal!'; +$_['success_send'] = 'Success: Your contact details have been successfully sent to PayPal!'; $_['success_download_host'] = 'Success: Association file has been successfully uploaded and hosted!'; $_['success_agree'] = 'Success: Deactivation was successful!'; $_['success_capture_payment'] = 'Success: Payment capture was completed.'; @@ -348,4 +350,4 @@ $_['error_permission'] = 'Warning: You do not have permission to modify payment PayPal!'; $_['error_connect'] = 'Warning: Client ID or Secret is incorrect!'; $_['error_timeout'] = 'Sorry, PayPal is currently busy. Please try again later!'; -$_['error_agree'] = 'We discovered that a few countries under sanctions are featured on your website. Please click the button to deactivate them (Cuba, Iran, Syria, North Korea, Crimea, Donetsk, and Lugansk regions of Ukraine).

'; +$_['error_agree'] = 'We discovered that a few countries under sanctions are featured on your website. Please click the button to deactivate them (Cuba, Iran, Syria, North Korea, Crimea, Donetsk, and Lugansk regions of Ukraine).

'; \ No newline at end of file diff --git a/upload/admin/model/extension/payment/paypal.php b/upload/admin/model/extension/payment/paypal.php index d98490f9..729103fd 100644 --- a/upload/admin/model/extension/payment/paypal.php +++ b/upload/admin/model/extension/payment/paypal.php @@ -1,284 +1,285 @@ config->get('config_complete_status') as $order_status_id) { $implode[] = "'" . (int)$order_status_id . "'"; } - + $query = $this->db->query("SELECT SUM(total) AS paypal_total FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(',', $implode) . ") AND payment_code = 'paypal'"); return $query->row['paypal_total']; } - + public function getTotalSalesByDay() { - $implode = []; + $implode = array(); foreach ($this->config->get('config_complete_status') as $order_status_id) { $implode[] = "'" . (int)$order_status_id . "'"; } - $sale_data = []; + $sale_data = array(); for ($i = 0; $i < 24; $i++) { - $sale_data[$i] = [ - 'hour' => $i, - 'total' => 0, - 'paypal_total' => 0 - ]; + $sale_data[$i] = array( + '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']] = [ - 'hour' => $result['hour'], - 'total' => $result['total'], - 'paypal_total' => $result['paypal_total'] - ]; + $sale_data[$result['hour']] = array( + 'hour' => $result['hour'], + 'total' => $result['total'], + 'paypal_total' => $result['paypal_total'] + ); } return $sale_data; } public function getTotalSalesByWeek() { - $implode = []; + $implode = array(); foreach ($this->config->get('config_complete_status') as $order_status_id) { $implode[] = "'" . (int)$order_status_id . "'"; } - $sale_data = []; + $sale_data = array(); $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))] = [ - 'day' => date('D', strtotime($date)), - 'total' => 0, - 'paypal_total' => 0 - ]; + $sale_data[date('w', strtotime($date))] = array( + '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']))] = [ - 'day' => date('D', strtotime($result['date_added'])), - 'total' => $result['total'], - 'paypal_total' => $result['paypal_total'] - ]; + $sale_data[date('w', strtotime($result['date_added']))] = array( + 'day' => date('D', strtotime($result['date_added'])), + 'total' => $result['total'], + 'paypal_total' => $result['paypal_total'] + ); } return $sale_data; } public function getTotalSalesByMonth() { - $implode = []; + $implode = array(); foreach ($this->config->get('config_complete_status') as $order_status_id) { $implode[] = "'" . (int)$order_status_id . "'"; } - $sale_data = []; + $sale_data = array(); for ($i = 1; $i <= date('t'); $i++) { $date = date('Y') . '-' . date('m') . '-' . $i; - $sale_data[date('j', strtotime($date))] = [ - 'day' => date('d', strtotime($date)), - 'total' => 0, - 'paypal_total' => 0 - ]; + $sale_data[date('j', strtotime($date))] = array( + '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']))] = [ - 'day' => date('d', strtotime($result['date_added'])), - 'total' => $result['total'], - 'paypal_total' => $result['paypal_total'] - ]; + $sale_data[date('j', strtotime($result['date_added']))] = array( + 'day' => date('d', strtotime($result['date_added'])), + 'total' => $result['total'], + 'paypal_total' => $result['paypal_total'] + ); } return $sale_data; } public function getTotalSalesByYear() { - $implode = []; + $implode = array(); foreach ($this->config->get('config_complete_status') as $order_status_id) { $implode[] = "'" . (int)$order_status_id . "'"; } - $sale_data = []; + $sale_data = array(); for ($i = 1; $i <= 12; $i++) { - $sale_data[$i] = [ - 'month' => date('M', mktime(0, 0, 0, $i)), - 'total' => 0, - 'paypal_total' => 0 - ]; + $sale_data[$i] = array( + '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']))] = [ - 'month' => date('M', strtotime($result['date_added'])), - 'total' => $result['total'], - 'paypal_total' => $result['paypal_total'] - ]; + $sale_data[date('n', strtotime($result['date_added']))] = array( + 'month' => date('M', strtotime($result['date_added'])), + 'total' => $result['total'], + 'paypal_total' => $result['paypal_total'] + ); } return $sale_data; } - + public function getCountryByCode($code) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country WHERE iso_code_2 = '" . $this->db->escape($code) . "'"); - + return $query->row; } - + public function deletePayPalCustomerTokens($customer_id) { $query = $this->db->query("DELETE FROM `" . DB_PREFIX . "paypal_checkout_integration_customer_token` WHERE `customer_id` = '" . (int)$customer_id . "'"); } - + public function editPayPalOrder($data) { $sql = "UPDATE `" . DB_PREFIX . "paypal_checkout_integration_order` SET"; - $implode = []; - + $implode = array(); + if (!empty($data['paypal_order_id'])) { $implode[] = "`paypal_order_id` = '" . $this->db->escape($data['paypal_order_id']) . "'"; } - + if (!empty($data['transaction_id'])) { $implode[] = "`transaction_id` = '" . $this->db->escape($data['transaction_id']) . "'"; } - + if (!empty($data['transaction_status'])) { $implode[] = "`transaction_status` = '" . $this->db->escape($data['transaction_status']) . "'"; } - + if (!empty($data['payment_method'])) { $implode[] = "`payment_method` = '" . $this->db->escape($data['payment_method']) . "'"; } - + if (!empty($data['vault_id'])) { $implode[] = "`vault_id` = '" . $this->db->escape($data['vault_id']) . "'"; } - + if (!empty($data['vault_customer_id'])) { $implode[] = "`vault_customer_id` = '" . $this->db->escape($data['vault_customer_id']) . "'"; } - + if (!empty($data['card_type'])) { $implode[] = "`card_type` = '" . $this->db->escape($data['card_type']) . "'"; } - + if (!empty($data['card_nice_type'])) { $implode[] = "`card_nice_type` = '" . $this->db->escape($data['card_nice_type']) . "'"; } - + if (!empty($data['card_last_digits'])) { $implode[] = "`card_last_digits` = '" . $this->db->escape($data['card_last_digits']) . "'"; } - + if (!empty($data['card_expiry'])) { $implode[] = "`card_expiry` = '" . $this->db->escape($data['card_expiry']) . "'"; } - + if (!empty($data['total'])) { $implode[] = "`total` = '" . (float)$data['total'] . "'"; } - + if (!empty($data['currency_code'])) { $implode[] = "`currency_code` = '" . $this->db->escape($data['currency_code']) . "'"; } - + if (!empty($data['environment'])) { $implode[] = "`environment` = '" . $this->db->escape($data['environment']) . "'"; } - + if (isset($data['tracking_number'])) { $implode[] = "`tracking_number` = '" . $this->db->escape($data['tracking_number']) . "'"; } - + if (isset($data['carrier_name'])) { $implode[] = "`carrier_name` = '" . $this->db->escape($data['carrier_name']) . "'"; } - + if ($implode) { $sql .= implode(", ", $implode); } $sql .= " WHERE `order_id` = '" . (int)$data['order_id'] . "'"; - + $this->db->query($sql); } - + public function deletePayPalOrder($order_id) { $query = $this->db->query("DELETE FROM `" . DB_PREFIX . "paypal_checkout_integration_order` WHERE `order_id` = '" . (int)$order_id . "'"); } - + public function getPayPalOrder($order_id) { $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "paypal_checkout_integration_order` WHERE `order_id` = '" . (int)$order_id . "'"); - + if ($query->num_rows) { return $query->row; } else { - return []; + return array(); } } - + public function editOrderRecurringStatus($order_recurring_id, $status) { $this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `status` = '" . (int)$status . "' WHERE `order_recurring_id` = '" . (int)$order_recurring_id . "'"); } - + public function setAgreeStatus() { $this->db->query("UPDATE " . DB_PREFIX . "country SET status = '0' WHERE (iso_code_2 = 'CU' OR iso_code_2 = 'IR' OR iso_code_2 = 'SY' OR iso_code_2 = 'KP')"); $this->db->query("UPDATE " . DB_PREFIX . "zone SET status = '0' WHERE country_id = '220' AND (`code` = '43' OR `code` = '14' OR `code` = '09')"); } - + public function getAgreeStatus() { $agree_status = true; - + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country WHERE status = '1' AND (iso_code_2 = 'CU' OR iso_code_2 = 'IR' OR iso_code_2 = 'SY' OR iso_code_2 = 'KP')"); - + if ($query->rows) { $agree_status = false; } - + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE country_id = '220' AND status = '1' AND (`code` = '43' OR `code` = '14' OR `code` = '09')"); - + if ($query->rows) { $agree_status = false; } - + return $agree_status; } - + public function addOrderHistory($order_history_token, $order_id, $order_status_id, $comment = '', $notify = false) { if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $catalog = HTTPS_CATALOG; } else { $catalog = HTTP_CATALOG; } - - $data = [ - 'order_id' => $order_id, + + $data = array( + 'order_id' => $order_id, 'order_status_id' => $order_status_id, - 'notify' => $notify, - 'comment' => $comment - ]; - + 'notify' => $notify, + 'comment' => $comment + ); + $curl = curl_init(); - + curl_setopt($curl, CURLOPT_URL, $catalog . 'index.php?route=extension/payment/paypal/addOrderHistory&order_history_token=' . $order_history_token); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); @@ -290,21 +291,21 @@ public function addOrderHistory($order_history_token, $order_id, $order_status_i curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); $response = curl_exec($curl); - + curl_close($curl); - + $result = json_decode($response, true); - + if (!empty($result['success'])) { return true; } else { return false; - } + } } - + public function checkVersion($opencart_version, $paypal_version) { $curl = curl_init(); - + curl_setopt($curl, CURLOPT_URL, 'https://www.opencart.com/index.php?route=api/promotion/paypalCheckoutIntegration&opencart=' . $opencart_version . '&paypal=' . $paypal_version); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); @@ -312,20 +313,20 @@ public function checkVersion($opencart_version, $paypal_version) { curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false); curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1); - + $response = curl_exec($curl); - + curl_close($curl); - + $result = json_decode($response, true); - + if ($result) { return $result; } else { return false; } } - + public function sendContact($data) { $curl = curl_init(); @@ -343,39 +344,39 @@ public function sendContact($data) { curl_close($curl); } - + public function log($data, $title = null) { $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + if ($setting['general']['debug']) { $log = new Log('paypal.log'); $log->write('PayPal debug (' . $title . '): ' . json_encode($data)); } } - + public function install() { $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_checkout_integration_customer_token` (`customer_id` INT(11) NOT NULL, `payment_method` VARCHAR(20) NOT NULL, `vault_id` VARCHAR(50) NOT NULL, `vault_customer_id` VARCHAR(50) NOT NULL, `card_type` VARCHAR(40) NOT NULL, `card_nice_type` VARCHAR(40) NOT NULL, `card_last_digits` VARCHAR(4) NOT NULL, `card_expiry` VARCHAR(20) NOT NULL, `main_token_status` TINYINT(1) NOT NULL, PRIMARY KEY (`customer_id`, `payment_method`, `vault_id`), KEY `vault_customer_id` (`vault_customer_id`), KEY `main_token_status` (`main_token_status`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci"); $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order` (`order_id` INT(11) NOT NULL, `paypal_order_id` VARCHAR(20) NOT NULL, `transaction_id` VARCHAR(20) NOT NULL, `transaction_status` VARCHAR(20) NOT NULL, `payment_method` VARCHAR(20) NOT NULL, `vault_id` VARCHAR(50) NOT NULL, `vault_customer_id` VARCHAR(50) NOT NULL, `card_type` VARCHAR(40) NOT NULL, `card_nice_type` VARCHAR(40) NOT NULL, `card_last_digits` VARCHAR(4) NOT NULL, `card_expiry` VARCHAR(20) NOT NULL, `total` DECIMAL(15,2) NOT NULL, `currency_code` VARCHAR(3) NOT NULL, `environment` VARCHAR(20) NOT NULL, `tracking_number` VARCHAR(64) NOT NULL, `carrier_name` VARCHAR(64) NOT NULL, PRIMARY KEY (`order_id`), KEY `paypal_order_id` (`paypal_order_id`), KEY `transaction_id` (`transaction_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci"); $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order_recurring` (`paypal_order_recurring_id` INT(11) NOT NULL AUTO_INCREMENT, `order_id` INT(11) NOT NULL, `order_recurring_id` INT(11) NOT NULL, `date_added` DATETIME NOT NULL, `date_modified` DATETIME NOT NULL, `next_payment` DATETIME NOT NULL, `trial_end` DATETIME DEFAULT NULL, `subscription_end` DATETIME DEFAULT NULL, `currency_code` CHAR(3) NOT NULL, `total` DECIMAL(10, 2) NOT NULL, PRIMARY KEY (`paypal_order_recurring_id`), KEY (`order_id`), KEY (`order_recurring_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci"); } - + public function uninstall() { $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_checkout_integration_customer_token`"); $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order`"); $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order_recurring`"); } - + public function update() { if ($this->config->get('paypal_version') < '3.1.0') { $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_checkout_integration_customer_token`"); $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order`"); $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order_recurring`"); - + $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_checkout_integration_customer_token` (`customer_id` INT(11) NOT NULL, `payment_method` VARCHAR(20) NOT NULL, `vault_id` VARCHAR(50) NOT NULL, `vault_customer_id` VARCHAR(50) NOT NULL, `card_type` VARCHAR(40) NOT NULL, `card_nice_type` VARCHAR(40) NOT NULL, `card_last_digits` VARCHAR(4) NOT NULL, `card_expiry` VARCHAR(20) NOT NULL, `main_token_status` TINYINT(1) NOT NULL, PRIMARY KEY (`customer_id`, `payment_method`, `vault_id`), KEY `vault_customer_id` (`vault_customer_id`), KEY `main_token_status` (`main_token_status`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci"); $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order` (`order_id` INT(11) NOT NULL, `paypal_order_id` VARCHAR(20) NOT NULL, `transaction_id` VARCHAR(20) NOT NULL, `transaction_status` VARCHAR(20) NOT NULL, `payment_method` VARCHAR(20) NOT NULL, `vault_id` VARCHAR(50) NOT NULL, `vault_customer_id` VARCHAR(50) NOT NULL, `card_type` VARCHAR(40) NOT NULL, `card_nice_type` VARCHAR(40) NOT NULL, `card_last_digits` VARCHAR(4) NOT NULL, `card_expiry` VARCHAR(20) NOT NULL, `total` DECIMAL(15,2) NOT NULL, `currency_code` VARCHAR(3) NOT NULL, `environment` VARCHAR(20) NOT NULL, `tracking_number` VARCHAR(64) NOT NULL, `carrier_name` VARCHAR(64) NOT NULL, PRIMARY KEY (`order_id`), KEY `paypal_order_id` (`paypal_order_id`), KEY `transaction_id` (`transaction_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci"); $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order_recurring` (`paypal_order_recurring_id` INT(11) NOT NULL AUTO_INCREMENT, `order_id` INT(11) NOT NULL, `order_recurring_id` INT(11) NOT NULL, `date_added` DATETIME NOT NULL, `date_modified` DATETIME NOT NULL, `next_payment` DATETIME NOT NULL, `trial_end` DATETIME DEFAULT NULL, `subscription_end` DATETIME DEFAULT NULL, `currency_code` CHAR(3) NOT NULL, `total` DECIMAL(10, 2) NOT NULL, PRIMARY KEY (`paypal_order_recurring_id`), KEY (`order_id`), KEY (`order_recurring_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci"); diff --git a/upload/admin/view/stylesheet/paypal/paypal.css b/upload/admin/view/stylesheet/paypal/paypal.css index 9d101687..cdb8f595 100644 --- a/upload/admin/view/stylesheet/paypal/paypal.css +++ b/upload/admin/view/stylesheet/paypal/paypal.css @@ -228,6 +228,7 @@ background-size: contain; background-position: center; border: 1px solid #919697; + border-radius: 3px; -webkit-appearance: none; -moz-appearance: none; appearance: none; @@ -235,6 +236,10 @@ color-adjust: exact; cursor: pointer; } +.payment-paypal .panel-default .form-check-input-mini { + width: 16px; + height: 16px; +} .payment-paypal .panel-default .form-check-input[type=radio] { border-radius: 50%; } @@ -256,6 +261,10 @@ margin: 0px 0px; vertical-align: middle; } +.payment-paypal .panel-default .well { + border: 1px solid #919697; + border-radius: 3px; +} .payment-paypal .panel-default .hr { display: inline-block; width: 100%; diff --git a/upload/admin/view/template/extension/payment/paypal/button.tpl b/upload/admin/view/template/extension/payment/paypal/button.tpl index 29f51df8..ef945073 100644 --- a/upload/admin/view/template/extension/payment/paypal/button.tpl +++ b/upload/admin/view/template/extension/payment/paypal/button.tpl @@ -357,7 +357,7 @@ function updatePayPalButton(button_page_code, paypal_callback = '') { var button_enable_funding = []; var button_disable_funding = []; - $('.payment-paypal [id^=input_button_' + button_page_code + '_funding').each(function() { + $('.payment-paypal [id^=input_button_' + button_page_code + '_funding]').each(function() { if ($(this).val() == 1) { button_enable_funding.push($(this).attr('funding_code')); } diff --git a/upload/admin/view/template/extension/payment/paypal/order_status.tpl b/upload/admin/view/template/extension/payment/paypal/order_status.tpl index abad2f7b..71a725af 100644 --- a/upload/admin/view/template/extension/payment/paypal/order_status.tpl +++ b/upload/admin/view/template/extension/payment/paypal/order_status.tpl @@ -42,7 +42,7 @@
-
+
@@ -59,6 +59,21 @@
+
+
+ +
+ +
+ +
+ +
+
+
diff --git a/upload/catalog/controller/extension/payment/paypal.php b/upload/catalog/controller/extension/payment/paypal.php index 47f82901..254c1129 100644 --- a/upload/catalog/controller/extension/payment/paypal.php +++ b/upload/catalog/controller/extension/payment/paypal.php @@ -1,35 +1,35 @@ =')) { + if (version_compare(phpversion(), '7.1', '>=')) { ini_set('precision', 14); ini_set('serialize_precision', 14); } - - if (empty($this->config->get('paypal_version')) || (!empty($this->config->get('paypal_version')) && ($this->config->get('paypal_version') < '3.1.0'))) { + + if (empty($this->config->get('paypal_version')) || (!empty($this->config->get('paypal_version')) && ($this->config->get('paypal_version') < '3.1.4'))) { $this->update(); } } - + public function index() { $this->load->model('extension/payment/paypal'); - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret') && !$this->callback() && !$this->webhook() && !$this->cron() && $agree_status) { $this->load->language('extension/payment/paypal'); - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -39,91 +39,91 @@ public function index() { $data['vault_status'] = $setting['general']['vault_status']; $data['checkout_mode'] = $setting['general']['checkout_mode']; $data['transaction_method'] = $setting['general']['transaction_method']; - + $data['button_status'] = $setting['button']['checkout']['status']; $data['googlepay_button_status'] = $setting['googlepay_button']['checkout']['status']; $data['card_status'] = $setting['card']['status']; - - if ($setting['applepay_button']['checkout']['status'] && $this->isApple()) { + + if ($setting['applepay_button']['checkout']['status'] && !empty($this->session->data['paypal']['applepay'])) { $data['applepay_button_status'] = $setting['applepay_button']['checkout']['status']; } else { $data['applepay_button_status'] = false; } - + $data['logged'] = $this->customer->isLogged(); - + $data['text_loading'] = $this->language->get('text_loading'); - + $data['entry_card_number'] = $this->language->get('entry_card_number'); $data['entry_expiration_date'] = $this->language->get('entry_expiration_date'); $data['entry_cvv'] = $this->language->get('entry_cvv'); $data['entry_card_save'] = $this->language->get('entry_card_save'); - + $data['button_pay'] = $this->language->get('button_pay'); $data['button_confirm'] = $this->language->get('button_confirm'); - - require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $data['partner_id'], - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); - } + } return $this->load->view('extension/payment/paypal/paypal', $data); } - + return ''; } - + public function modal() { $this->load->language('extension/payment/paypal'); - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -132,95 +132,95 @@ public function modal() { $data['partner_attribution_id'] = $setting['partner'][$data['environment']]['partner_attribution_id']; $data['vault_status'] = $setting['general']['vault_status']; $data['transaction_method'] = $setting['general']['transaction_method']; - + $data['button_status'] = $setting['button']['checkout']['status']; $data['googlepay_button_status'] = $setting['googlepay_button']['checkout']['status']; $data['card_status'] = $setting['card']['status']; - - if ($setting['applepay_button']['checkout']['status'] && $this->isApple()) { + + if ($setting['applepay_button']['checkout']['status'] && !empty($this->session->data['paypal']['applepay'])) { $data['applepay_button_status'] = $setting['applepay_button']['checkout']['status']; } else { $data['applepay_button_status'] = false; } - + $data['text_paypal_title'] = $this->language->get('text_paypal_title'); $data['text_loading'] = $this->language->get('text_loading'); - + $data['entry_card_number'] = $this->language->get('entry_card_number'); $data['entry_expiration_date'] = $this->language->get('entry_expiration_date'); $data['entry_cvv'] = $this->language->get('entry_cvv'); - + $data['button_pay'] = $this->language->get('button_pay'); - - require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $data['partner_id'], - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); - } - + } + $data['error'] = $this->error; $this->response->setOutput($this->load->view('extension/payment/paypal/paypal_modal', $data)); } - + public function getData() { $this->load->model('extension/payment/paypal'); - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - - if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret') && $agree_status && !empty($this->request->post['page_code'])) { + + if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret') && $agree_status && !empty($this->request->post['page_code'])) { $this->load->language('extension/payment/paypal'); - + $this->load->model('localisation/country'); $this->load->model('checkout/order'); - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $data['page_code'] = $this->request->post['page_code']; $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); @@ -231,24 +231,28 @@ public function getData() { $data['partner_attribution_id'] = $setting['partner'][$data['environment']]['partner_attribution_id']; $data['vault_status'] = $setting['general']['vault_status']; $data['transaction_method'] = $setting['general']['transaction_method']; - + $country = $this->model_extension_payment_paypal->getCountryByCode($setting['general']['country_code']); - + $data['locale'] = preg_replace('/-(.+?)+/', '', $this->config->get('config_language')) . '_' . $country['iso_code_2']; - + $data['currency_code'] = $this->session->data['currency']; $data['currency_value'] = $this->currency->getValue($this->session->data['currency']); - + if (empty($setting['currency'][$data['currency_code']]['status'])) { $data['currency_code'] = $setting['general']['currency_code']; $data['currency_value'] = $setting['general']['currency_value']; } - + $data['decimal_place'] = $setting['currency'][$data['currency_code']]['decimal_place']; - - $data['components'] = []; - - if ($this->request->post['page_code'] == 'home') { + + if (!empty($this->request->post['applepay'])) { + $this->session->data['paypal']['applepay'] = true; + } + + $data['components'] = array(); + + 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'])) { $data['components'][] = 'messages'; $data['message_status'] = $setting['message']['home']['status']; @@ -261,34 +265,34 @@ public function getData() { $data['message_text_size'] = $setting['message']['home']['text_size']; $data['message_flex_color'] = $setting['message']['home']['flex_color']; $data['message_flex_ratio'] = $setting['message']['home']['flex_ratio']; - + $item_total = 0; - + foreach ($this->cart->getProducts() as $product) { $product_price = $this->tax->calculate($product['price'], $product['tax_class_id'], true); - + $item_total += $product_price * $product['quantity']; } - + if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $voucher) { $item_total += $voucher['amount']; } } - + $data['message_amount'] = number_format($item_total * $data['currency_value'], $data['decimal_place'], '.', ''); } } - + if (!empty($this->request->post['product'])) { $this->request->post['product'] = $this->unserialize($this->request->post['product']); } - + if (($this->request->post['page_code'] == 'product') && !empty($this->request->post['product']['product_id'])) { $product = $this->request->post['product']; $product_id = (int)$this->request->post['product']['product_id']; $product_price = 0; - + if (isset($product['quantity'])) { $quantity = (int)$product['quantity']; } else { @@ -298,18 +302,18 @@ public function getData() { if (isset($product['option'])) { $option = array_filter($product['option']); } else { - $option = []; + $option = array(); } - + $this->load->model('catalog/product'); $product_info = $this->model_catalog_product->getProduct($product_id); - if ($product_info && ($this->customer->isLogged() || !$this->config->get('config_customer_price'))) { + if ($product_info && ($this->customer->isLogged() || !$this->config->get('config_customer_price'))) { $option_price = 0; $product_options = $this->model_catalog_product->getProductOptions($product_id); - + foreach ($product_options as $product_option) { if (isset($option[$product_option['product_option_id']])) { if (($product_option['type'] == 'select') || ($product_option['type'] == 'radio')) { @@ -324,7 +328,7 @@ public function getData() { } } } - } + } } } elseif (($product_option['type'] == 'checkbox') && is_array($option[$product_option['product_option_id']])) { foreach ($product_option['product_option_value'] as $product_option_value) { @@ -338,19 +342,19 @@ public function getData() { } } } - } + } } } } } - + if ((float)$product_info['special']) { $product_price = $this->tax->calculate(($product_info['special'] + $option_price) * $quantity, $product_info['tax_class_id'], true); } else { $product_price = $this->tax->calculate(($product_info['price'] + $option_price) * $quantity, $product_info['tax_class_id'], true); } } - + if ($setting['button']['product']['status']) { $data['components'][] = 'buttons'; $data['button_status'] = $setting['button']['product']['status']; @@ -362,21 +366,21 @@ public function getData() { $data['button_color'] = $setting['button']['product']['color']; $data['button_shape'] = $setting['button']['product']['shape']; $data['button_label'] = $setting['button']['product']['label']; - - $data['button_enable_funding'] = []; - $data['button_disable_funding'] = []; - + + $data['button_enable_funding'] = array(); + $data['button_disable_funding'] = array(); + foreach ($setting['button_funding'] as $button_funding) { if ($setting['button']['product']['funding'][$button_funding['code']] == 1) { $data['button_enable_funding'][] = $button_funding['code']; - } - + } + if ($setting['button']['product']['funding'][$button_funding['code']] == 2) { $data['button_disable_funding'][] = $button_funding['code']; } } } - + if ($setting['googlepay_button']['product']['status']) { $data['components'][] = 'googlepay'; $data['googlepay_button_status'] = $setting['googlepay_button']['product']['status']; @@ -388,13 +392,13 @@ public function getData() { $data['googlepay_button_color'] = $setting['googlepay_button']['product']['color']; $data['googlepay_button_shape'] = $setting['googlepay_button']['product']['shape']; $data['googlepay_button_type'] = $setting['googlepay_button']['product']['type']; - + if ($product_price) { - $data['googlepay_amount'] = number_format($product_price * $data['currency_value'], $data['decimal_place'], '.', ''); + $data['googlepay_amount'] = number_format($product_price * $data['currency_value'], $data['decimal_place'], '.', ''); } } - - if ($setting['applepay_button']['product']['status'] && $this->isApple()) { + + if ($setting['applepay_button']['product']['status'] && !empty($this->session->data['paypal']['applepay'])) { $data['components'][] = 'applepay'; $data['applepay_button_status'] = $setting['applepay_button']['product']['status']; $data['applepay_button_insert_tag'] = html_entity_decode($setting['applepay_button']['product']['insert_tag']); @@ -405,12 +409,12 @@ public function getData() { $data['applepay_button_color'] = $setting['applepay_button']['product']['color']; $data['applepay_button_shape'] = $setting['applepay_button']['product']['shape']; $data['applepay_button_type'] = $setting['applepay_button']['product']['type']; - + if ($product_price) { - $data['applepay_amount'] = number_format($product_price * $data['currency_value'], $data['decimal_place'], '.', ''); + $data['applepay_amount'] = number_format($product_price * $data['currency_value'], $data['decimal_place'], '.', ''); } } - + if ($setting['message']['product']['status'] && !empty($setting['paylater_country'][$setting['general']['country_code']]) && ($data['currency_code'] == $setting['general']['currency_code'])) { $data['components'][] = 'messages'; $data['message_status'] = $setting['message']['product']['status']; @@ -425,11 +429,11 @@ public function getData() { $data['message_flex_ratio'] = $setting['message']['product']['flex_ratio']; if ($product_price) { - $data['message_amount'] = number_format($product_price * $data['currency_value'], $data['decimal_place'], '.', ''); + $data['message_amount'] = number_format($product_price * $data['currency_value'], $data['decimal_place'], '.', ''); } } } - + if (($this->request->post['page_code'] == 'cart') && ($this->cart->hasProducts() || !empty($this->session->data['vouchers']))) { if ($setting['button']['cart']['status']) { $data['components'][] = 'buttons'; @@ -442,21 +446,21 @@ public function getData() { $data['button_color'] = $setting['button']['cart']['color']; $data['button_shape'] = $setting['button']['cart']['shape']; $data['button_label'] = $setting['button']['cart']['label']; - - $data['button_enable_funding'] = []; - $data['button_disable_funding'] = []; - + + $data['button_enable_funding'] = array(); + $data['button_disable_funding'] = array(); + foreach ($setting['button_funding'] as $button_funding) { if ($setting['button']['cart']['funding'][$button_funding['code']] == 1) { $data['button_enable_funding'][] = $button_funding['code']; - } - + } + if ($setting['button']['cart']['funding'][$button_funding['code']] == 2) { $data['button_disable_funding'][] = $button_funding['code']; } } } - + if ($setting['googlepay_button']['cart']['status']) { $data['components'][] = 'googlepay'; $data['googlepay_button_status'] = $setting['googlepay_button']['cart']['status']; @@ -468,25 +472,25 @@ public function getData() { $data['googlepay_button_color'] = $setting['googlepay_button']['cart']['color']; $data['googlepay_button_shape'] = $setting['googlepay_button']['cart']['shape']; $data['googlepay_button_type'] = $setting['googlepay_button']['cart']['type']; - + $item_total = 0; - + foreach ($this->cart->getProducts() as $product) { $product_price = $this->tax->calculate($product['price'], $product['tax_class_id'], true); - + $item_total += $product_price * $product['quantity']; } - + if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $voucher) { $item_total += $voucher['amount']; } } - + $data['googlepay_amount'] = number_format($item_total * $data['currency_value'], $data['decimal_place'], '.', ''); } - - if ($setting['applepay_button']['cart']['status'] && $this->isApple()) { + + if ($setting['applepay_button']['cart']['status'] && !empty($this->session->data['paypal']['applepay'])) { $data['components'][] = 'applepay'; $data['applepay_button_status'] = $setting['applepay_button']['cart']['status']; $data['applepay_button_insert_tag'] = html_entity_decode($setting['applepay_button']['cart']['insert_tag']); @@ -497,21 +501,21 @@ public function getData() { $data['applepay_button_color'] = $setting['applepay_button']['cart']['color']; $data['applepay_button_shape'] = $setting['applepay_button']['cart']['shape']; $data['applepay_button_type'] = $setting['applepay_button']['cart']['type']; - + $item_total = 0; - + foreach ($this->cart->getProducts() as $product) { $product_price = $this->tax->calculate($product['price'], $product['tax_class_id'], true); - + $item_total += $product_price * $product['quantity']; } - + if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $voucher) { $item_total += $voucher['amount']; } } - + $data['applepay_amount'] = number_format($item_total * $data['currency_value'], $data['decimal_place'], '.', ''); } @@ -527,30 +531,30 @@ public function getData() { $data['message_text_size'] = $setting['message']['cart']['text_size']; $data['message_flex_color'] = $setting['message']['cart']['flex_color']; $data['message_flex_ratio'] = $setting['message']['cart']['flex_ratio']; - + $item_total = 0; - + foreach ($this->cart->getProducts() as $product) { $product_price = $this->tax->calculate($product['price'], $product['tax_class_id'], true); - + $item_total += $product_price * $product['quantity']; } - + if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $voucher) { $item_total += $voucher['amount']; } } - + $data['message_amount'] = number_format($item_total * $data['currency_value'], $data['decimal_place'], '.', ''); } } - + if (($this->request->post['page_code'] == 'checkout') && ($this->cart->hasProducts() || !empty($this->session->data['vouchers']))) { if (!empty($this->session->data['order_id'])) { $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); } - + if ($setting['button']['checkout']['status']) { $data['components'][] = 'buttons'; $data['components'][] = 'funding-eligibility'; @@ -561,25 +565,25 @@ public function getData() { $data['button_color'] = $setting['button']['checkout']['color']; $data['button_shape'] = $setting['button']['checkout']['shape']; $data['button_label'] = $setting['button']['checkout']['label']; - - $data['button_enable_funding'] = []; - $data['button_disable_funding'] = []; - + + $data['button_enable_funding'] = array(); + $data['button_disable_funding'] = array(); + foreach ($setting['button_funding'] as $button_funding) { if ($setting['button']['checkout']['funding'][$button_funding['code']] == 1) { $data['button_enable_funding'][] = $button_funding['code']; - } - + } + if ($setting['button']['checkout']['funding'][$button_funding['code']] == 2) { $data['button_disable_funding'][] = $button_funding['code']; } } - + if (isset($this->session->data['payment_method']['code']) && ($this->session->data['payment_method']['code'] == 'paypal_paylater')) { $data['button_funding_source'] = 'paylater'; } } - + if ($setting['googlepay_button']['checkout']['status']) { $data['components'][] = 'googlepay'; $data['googlepay_button_status'] = $setting['googlepay_button']['checkout']['status']; @@ -589,29 +593,29 @@ public function getData() { $data['googlepay_button_color'] = $setting['googlepay_button']['checkout']['color']; $data['googlepay_button_shape'] = $setting['googlepay_button']['checkout']['shape']; $data['googlepay_button_type'] = $setting['googlepay_button']['checkout']['type']; - + if (!empty($order_info)) { $data['googlepay_amount'] = number_format($order_info['total'] * $data['currency_value'], $data['decimal_place'], '.', ''); } else { $item_total = 0; - + foreach ($this->cart->getProducts() as $product) { $product_price = $this->tax->calculate($product['price'], $product['tax_class_id'], true); - + $item_total += $product_price * $product['quantity']; } - + if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $voucher) { $item_total += $voucher['amount']; } } - + $data['googlepay_amount'] = number_format($item_total * $data['currency_value'], $data['decimal_place'], '.', ''); } } - - if ($setting['applepay_button']['checkout']['status'] && $this->isApple()) { + + if ($setting['applepay_button']['checkout']['status'] && !empty($this->session->data['paypal']['applepay'])) { $data['components'][] = 'applepay'; $data['applepay_button_status'] = $setting['applepay_button']['checkout']['status']; $data['applepay_button_align'] = $setting['applepay_button']['checkout']['align']; @@ -620,50 +624,50 @@ public function getData() { $data['applepay_button_color'] = $setting['applepay_button']['checkout']['color']; $data['applepay_button_shape'] = $setting['applepay_button']['checkout']['shape']; $data['applepay_button_type'] = $setting['applepay_button']['checkout']['type']; - + if (!empty($order_info)) { $data['applepay_amount'] = number_format($order_info['total'] * $data['currency_value'], $data['decimal_place'], '.', ''); } else { $item_total = 0; - + foreach ($this->cart->getProducts() as $product) { $product_price = $this->tax->calculate($product['price'], $product['tax_class_id'], true); - + $item_total += $product_price * $product['quantity']; } - + if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $voucher) { $item_total += $voucher['amount']; } } - + $data['applepay_amount'] = number_format($item_total * $data['currency_value'], $data['decimal_place'], '.', ''); } } - - if ($setting['card']['status']) { + + if ($setting['card']['status']) { $data['components'][] = 'card-fields'; $data['card_status'] = $setting['card']['status']; $data['card_align'] = $setting['card']['align']; $data['card_size'] = $setting['card']['size']; $data['card_width'] = $setting['card_width'][$data['card_size']]; - - $data['card_customer_tokens'] = []; - + + $data['card_customer_tokens'] = array(); + 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'][] = [ - 'vault_id' => $card_customer_token['vault_id'], - 'card_type' => $card_customer_token['card_type'], + $data['card_customer_tokens'][] = array( + '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']) - ]; + ); } } } - + if ($setting['message']['checkout']['status'] && ($data['currency_code'] == $setting['general']['currency_code'])) { $data['components'][] = 'messages'; $data['message_status'] = $setting['message']['checkout']['status']; @@ -674,81 +678,81 @@ public function getData() { $data['message_text_size'] = $setting['message']['checkout']['text_size']; $data['message_flex_color'] = $setting['message']['checkout']['flex_color']; $data['message_flex_ratio'] = $setting['message']['checkout']['flex_ratio']; - + if (!empty($order_info)) { $data['message_amount'] = number_format($order_info['total'] * $data['currency_value'], $data['decimal_place'], '.', ''); } else { $item_total = 0; - + foreach ($this->cart->getProducts() as $product) { $product_price = $this->tax->calculate($product['price'], $product['tax_class_id'], true); - + $item_total += $product_price * $product['quantity']; } - + if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $voucher) { $item_total += $voucher['amount']; } } - + $data['message_amount'] = number_format($item_total * $data['currency_value'], $data['decimal_place'], '.', ''); } } } - - require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $data['partner_id'], - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + '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 = [ + + $token_info = array( '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'); - + if (!empty($paypal_customer_token['vault_customer_id'])) { $token_info['response_type'] = 'id_token'; $token_info['target_customer_id'] = $paypal_customer_token['vault_customer_id']; } } - + $result = $paypal->setAccessToken($token_info); - + if ($setting['general']['vault_status'] && !empty($result['id_token'])) { $data['id_token'] = $result['id_token']; } - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } @@ -756,45 +760,45 @@ public function getData() { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($data)); + $this->response->setOutput(json_encode($data)); } - + public function createOrder() { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + if (!empty($this->request->post['page_code']) && !empty($this->request->post['payment_type'])) { $page_code = $this->request->post['page_code']; $payment_type = $this->request->post['payment_type']; - + $payment_method = ''; - + if ($payment_type == 'button') { $payment_method = 'paypal'; } - + if ($payment_type == 'card') { $payment_method = 'card'; } - - $errors = []; - + + $errors = array(); + $data['paypal_order_id'] = ''; $data['url'] = ''; - + if (!empty($this->request->post['product'])) { $this->request->post['product'] = $this->unserialize($this->request->post['product']); } - + if (($page_code == 'product') && (!empty($this->request->post['product']['product_id']))) { $product = $this->request->post['product']; $product_id = (int)$product['product_id']; - + $this->load->model('catalog/product'); $product_info = $this->model_catalog_product->getProduct($product_id); @@ -809,7 +813,7 @@ public function createOrder() { if (isset($product['option'])) { $option = array_filter($product['option']); } else { - $option = []; + $option = array(); } $product_options = $this->model_catalog_product->getProductOptions($product_id); @@ -819,7 +823,7 @@ public function createOrder() { $errors[] = sprintf($this->language->get('error_required'), $product_option['name']); } } - + if (isset($product['recurring_id'])) { $recurring_id = $product['recurring_id']; } else { @@ -829,7 +833,7 @@ public function createOrder() { $recurrings = $this->model_catalog_product->getProfiles($product_info['product_id']); if ($recurrings) { - $recurring_ids = []; + $recurring_ids = array(); foreach ($recurrings as $recurring) { $recurring_ids[] = $recurring['recurring_id']; @@ -839,57 +843,57 @@ public function createOrder() { $errors[] = $this->language->get('error_recurring_required'); } } - - if (!$errors) { + + if (!$errors) { if (!$this->model_extension_payment_paypal->hasProductInCart($product_id, $option, $recurring_id)) { $this->cart->add($product_id, $quantity, $option, $recurring_id); } - + // Unset all shipping and payment methods unset($this->session->data['shipping_method']); unset($this->session->data['shipping_methods']); unset($this->session->data['payment_method']); unset($this->session->data['payment_methods']); - } + } } } - + if ($page_code == 'checkout') { $this->load->model('checkout/order'); - + $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - $shipping_info = []; + + $shipping_info = array(); if ($this->cart->hasShipping()) { $shipping_info['name']['full_name'] = $order_info['shipping_firstname']; - $shipping_info['name']['full_name'] .= ($order_info['shipping_lastname'] ? (' ' . $order_info['shipping_lastname']) : ''); + $shipping_info['name']['full_name'] .= ($order_info['shipping_lastname'] ? (' ' . $order_info['shipping_lastname']) : ''); $shipping_info['address']['address_line_1'] = $order_info['shipping_address_1']; - $shipping_info['address']['address_line_2'] = $order_info['shipping_address_2']; + $shipping_info['address']['address_line_2'] = $order_info['shipping_address_2']; $shipping_info['address']['admin_area_1'] = $order_info['shipping_zone']; $shipping_info['address']['admin_area_2'] = $order_info['shipping_city']; $shipping_info['address']['postal_code'] = $order_info['shipping_postcode']; - + if ($order_info['shipping_country_id']) { $this->load->model('localisation/country'); - + $country_info = $this->model_localisation_country->getCountry($order_info['shipping_country_id']); - + if ($country_info) { $shipping_info['address']['country_code'] = $country_info['iso_code_2']; } } } } - - if (!$errors) { + + if (!$errors) { $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $merchant_id = $this->config->get('paypal_merchant_id'); @@ -897,11 +901,11 @@ public function createOrder() { $partner_id = $setting['partner'][$environment]['partner_id']; $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; $vault_status = $setting['general']['vault_status']; - $transaction_method = $setting['general']['transaction_method']; - + $transaction_method = $setting['general']['transaction_method']; + $currency_code = $this->session->data['currency']; $currency_value = $this->currency->getValue($this->session->data['currency']); - + if ((($payment_type == 'button') || ($payment_type == 'googlepay_button') || ($payment_type == 'applepay_button')) && empty($setting['currency'][$currency_code]['status'])) { $currency_code = $setting['general']['currency_code']; $currency_value = $setting['general']['currency_value']; @@ -911,53 +915,53 @@ public function createOrder() { $currency_code = $setting['general']['card_currency_code']; $currency_value = $setting['general']['card_currency_value']; } - + $decimal_place = $setting['currency'][$currency_code]['decimal_place']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - - $item_info = []; - + + $item_info = array(); + $item_total = 0; $tax_total = 0; - + $this->load->model('tool/image'); - + foreach ($this->cart->getProducts() as $product) { $product_price = number_format($product['price'] * $currency_value, $decimal_place, '.', ''); - - $product_info = []; - + + $product_info = array(); + $product_info['name'] = $product['name']; $product_info['quantity'] = $product['quantity']; $product_info['sku'] = $product['model']; $product_info['url'] = $this->url->link('product/product', 'product_id=' . $product['product_id'], true); - - $product_info['unit_amount'] = [ + + $product_info['unit_amount'] = array( 'currency_code' => $currency_code, - 'value' => $product_price - ]; + 'value' => $product_price + ); $item_info[] = $product_info; - + $item_total += $product_price * $product['quantity']; - + if ($product['tax_class_id']) { $tax_rates = $this->tax->getRates($product['price'], $product['tax_class_id']); @@ -966,142 +970,142 @@ public function createOrder() { } } } - + if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $voucher) { - $voucher_info = []; - + $voucher_info = array(); + $voucher_info['name'] = $voucher['description']; $voucher_info['quantity'] = 1; - - $voucher_info['unit_amount'] = [ + + $voucher_info['unit_amount'] = array( 'currency_code' => $currency_code, - 'value' => $voucher['amount'] - ]; - + 'value' => $voucher['amount'] + ); + $item_info[] = $voucher_info; - + $item_total += $voucher['amount']; } } - + $item_total = number_format($item_total, $decimal_place, '.', ''); $tax_total = number_format($tax_total * $currency_value, $decimal_place, '.', ''); $order_total = number_format($item_total + $tax_total, $decimal_place, '.', ''); - - if ($page_code == 'checkout' && isset($order_info)) { + + if ($page_code == 'checkout') { $discount_total = 0; $handling_total = 0; $shipping_total = 0; - + if (isset($this->session->data['shipping_method'])) { $shipping_total = $this->tax->calculate($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id'], true); $shipping_total = number_format($shipping_total * $currency_value, $decimal_place, '.', ''); } - + $order_total = number_format($order_info['total'] * $currency_value, $decimal_place, '.', ''); - + $rebate = number_format($item_total + $tax_total + $shipping_total - $order_total, $decimal_place, '.', ''); - + if ($rebate > 0) { $discount_total = $rebate; } elseif ($rebate < 0) { $handling_total = -$rebate; } - } - - $amount_info = []; - + } + + $amount_info = array(); + $amount_info['currency_code'] = $currency_code; $amount_info['value'] = $order_total; - - $amount_info['breakdown']['item_total'] = [ + + $amount_info['breakdown']['item_total'] = array( 'currency_code' => $currency_code, - 'value' => $item_total - ]; - - $amount_info['breakdown']['tax_total'] = [ + 'value' => $item_total + ); + + $amount_info['breakdown']['tax_total'] = array( 'currency_code' => $currency_code, - 'value' => $tax_total - ]; - - if ($page_code == 'checkout' && isset($shipping_total) && isset($handling_total) && isset($discount_total) && isset($order_info) && isset($shipping_info)) { - $amount_info['breakdown']['shipping'] = [ + 'value' => $tax_total + ); + + if ($page_code == 'checkout') { + $amount_info['breakdown']['shipping'] = array( 'currency_code' => $currency_code, - 'value' => $shipping_total - ]; - - $amount_info['breakdown']['handling'] = [ + 'value' => $shipping_total + ); + + $amount_info['breakdown']['handling'] = array( 'currency_code' => $currency_code, - 'value' => $handling_total - ]; - - $amount_info['breakdown']['discount'] = [ + 'value' => $handling_total + ); + + $amount_info['breakdown']['discount'] = array( 'currency_code' => $currency_code, - 'value' => $discount_total - ]; + 'value' => $discount_total + ); } - - $paypal_order_info = []; - + + $paypal_order_info = array(); + $paypal_order_info['intent'] = strtoupper($transaction_method); $paypal_order_info['purchase_units'][0]['reference_id'] = 'default'; $paypal_order_info['purchase_units'][0]['items'] = $item_info; $paypal_order_info['purchase_units'][0]['amount'] = $amount_info; - - if ($page_code == 'checkout' && isset($order_info)) { + + if ($page_code == 'checkout') { $paypal_order_info['purchase_units'][0]['description'] = 'Your order ' . $order_info['order_id']; $paypal_order_info['purchase_units'][0]['invoice_id'] = $order_info['order_id'] . '_' . date('Ymd_His'); - - if ($this->cart->hasShipping() && isset($shipping_info)) { + + if ($this->cart->hasShipping()) { $paypal_order_info['purchase_units'][0]['shipping'] = $shipping_info; } } - - if ($this->cart->hasShipping()) { + + if ($this->cart->hasShipping()) { $shipping_preference = 'GET_FROM_FILE'; } else { $shipping_preference = 'NO_SHIPPING'; } - + $paypal_order_info['application_context']['shipping_preference'] = $shipping_preference; - + if ($setting['general']['vault_status'] && ($this->customer->isLogged() || $this->cart->hasRecurringProducts())) { if ($payment_method == 'paypal') { - $paypal_customer_token = []; - + $paypal_customer_token = array(); + 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'] = [ + $paypal_order_info['payment_source'][$payment_method]['attributes']['vault'] = array( 'permit_multiple_payment_tokens' => 'false', - 'store_in_vault' => 'ON_SUCCESS', - 'usage_type' => 'MERCHANT', - 'customer_type' => 'CONSUMER' - ]; + 'store_in_vault' => 'ON_SUCCESS', + 'usage_type' => 'MERCHANT', + 'customer_type' => 'CONSUMER' + ); } } - + if ($payment_method == 'card') { if (isset($this->request->post['index'])) { $card_token_index = $this->request->post['index']; - + $card_customer_tokens = $this->model_extension_payment_paypal->getPayPalCustomerTokens($this->customer->getId(), $payment_method); - + if (!empty($card_customer_tokens[$card_token_index]['vault_id'])) { - $paypal_order_info['payment_source'][$payment_method]['vault_id'] = $card_customer_tokens[$card_token_index]['vault_id']; + $paypal_order_info['payment_source'][$payment_method]['vault_id'] = $card_customer_tokens[$card_token_index]['vault_id']; $paypal_order_info['payment_source'][$payment_method]['stored_credential']['payment_initiator'] = 'CUSTOMER'; $paypal_order_info['payment_source'][$payment_method]['stored_credential']['payment_type'] = 'ONE_TIME'; $paypal_order_info['payment_source'][$payment_method]['stored_credential']['usage'] = 'SUBSEQUENT'; } } else { if (!empty($this->request->post['card_save']) || $this->cart->hasRecurringProducts()) { - $paypal_order_info['payment_source'][$payment_method]['attributes']['vault']['store_in_vault'] = 'ON_SUCCESS'; + $paypal_order_info['payment_source'][$payment_method]['attributes']['vault']['store_in_vault'] = 'ON_SUCCESS'; $paypal_order_info['payment_source'][$payment_method]['stored_credential']['payment_initiator'] = 'CUSTOMER'; $paypal_order_info['payment_source'][$payment_method]['stored_credential']['usage'] = 'FIRST'; - + if ($this->cart->hasRecurringProducts()) { $paypal_order_info['payment_source'][$payment_method]['stored_credential']['payment_type'] = 'UNSCHEDULED'; } else { @@ -1111,67 +1115,67 @@ public function createOrder() { } } } - + if ($payment_method) { $paypal_order_info['payment_source'][$payment_method]['attributes']['verification']['method'] = strtoupper($setting['card']['secure_method']); $paypal_order_info['payment_source'][$payment_method]['experience_context']['return_url'] = $this->url->link('extension/payment/paypal', 'callback_token=' . $setting['general']['callback_token'], true); $paypal_order_info['payment_source'][$payment_method]['experience_context']['cancel_url'] = $this->url->link('checkout/checkout', '', true); } - + $result = $paypal->createOrder($paypal_order_info); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } - + if (isset($result['id']) && isset($result['status']) && !$this->error) { $this->model_extension_payment_paypal->log($result, 'Create Order'); - + if ($result['status'] == 'VOIDED') { $this->error['warning'] = sprintf($this->language->get('error_order_voided'), $this->url->link('information/contact', '', true)); } - + if (($result['status'] == 'COMPLETED') && empty($paypal_order_info['payment_source']['card']['vault_id'])) { $this->error['warning'] = sprintf($this->language->get('error_order_completed'), $this->url->link('information/contact', '', true)); } - + if (($result['status'] == 'COMPLETED') && !empty($paypal_order_info['payment_source']['card']['vault_id'])) { $data['url'] = $this->url->link('checkout/success', '', true); } - + if (($result['status'] == 'PAYER_ACTION_REQUIRED') && !empty($paypal_order_info['payment_source']['card']['vault_id'])) { foreach ($result['links'] as $link) { if ($link['rel'] == 'payer-action') { $data['url'] = $link['href']; - + $this->session->data['paypal_order_id'] = $result['id']; $this->session->data['paypal_card_token_index'] = $this->request->post['index']; } } } - + if (!$this->error) { $data['paypal_order_id'] = $result['id']; } @@ -1180,36 +1184,36 @@ public function createOrder() { $this->error['warning'] = implode(' ', $errors); } } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function approveOrder() { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + if (!empty($this->request->post['page_code']) && !empty($this->request->post['payment_type'])) { $page_code = $this->request->post['page_code']; $payment_type = $this->request->post['payment_type']; - + if ($page_code != 'checkout') { if (isset($this->request->post['paypal_order_id'])) { $this->session->data['paypal_order_id'] = $this->request->post['paypal_order_id']; - } else { + } else { $data['url'] = $this->url->link('checkout/cart', '', true); - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + // check checkout can continue due to stock checks or vouchers if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { $data['url'] = $this->url->link('checkout/cart', '', true); - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } @@ -1217,19 +1221,19 @@ public function approveOrder() { // if user not logged in check that the guest checkout is allowed if (!$this->customer->isLogged() && (!$this->config->get('config_checkout_guest') || $this->config->get('config_customer_price') || $this->cart->hasDownload() || $this->cart->hasRecurringProducts())) { $data['url'] = $this->url->link('checkout/cart', '', true); - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } } - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $environment = $this->config->get('paypal_environment'); @@ -1237,65 +1241,65 @@ public function approveOrder() { $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; $vault_status = $setting['general']['vault_status']; $transaction_method = $setting['general']['transaction_method']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + if ($page_code != 'checkout') { $paypal_order_id = $this->session->data['paypal_order_id']; - + $paypal_order_info = $paypal->getOrder($paypal_order_id); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } - + if ($paypal_order_info && !$this->error) { $this->load->model('account/customer'); $this->load->model('account/address'); - + unset($this->session->data['shipping_method']); unset($this->session->data['shipping_methods']); unset($this->session->data['payment_method']); unset($this->session->data['payment_methods']); - + if ($this->customer->isLogged()) { $customer_info = $this->model_account_customer->getCustomer($this->customer->getId()); @@ -1309,18 +1313,18 @@ public function approveOrder() { } else { $this->session->data['guest']['customer_id'] = 0; $this->session->data['guest']['customer_group_id'] = $this->config->get('config_customer_group_id'); - $this->session->data['guest']['firstname'] = ($paypal_order_info['payer']['name']['given_name'] ?? ''); - $this->session->data['guest']['lastname'] = ($paypal_order_info['payer']['name']['surname'] ?? ''); - $this->session->data['guest']['email'] = ($paypal_order_info['payer']['email_address'] ?? ''); - $this->session->data['guest']['telephone'] = ($paypal_order_info['payer']['phone']['phone_number']['national_number'] ?? ''); - $this->session->data['guest']['custom_field'] = []; + $this->session->data['guest']['firstname'] = (isset($paypal_order_info['payer']['name']['given_name']) ? $paypal_order_info['payer']['name']['given_name'] : ''); + $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(); } - + if ($this->customer->isLogged() && $this->customer->getAddressId()) { $this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); } else { - $this->session->data['payment_address']['firstname'] = ($paypal_order_info['payer']['name']['given_name'] ?? ''); - $this->session->data['payment_address']['lastname'] = ($paypal_order_info['payer']['name']['surname'] ?? ''); + $this->session->data['payment_address']['firstname'] = (isset($paypal_order_info['payer']['name']['given_name']) ? $paypal_order_info['payer']['name']['given_name'] : ''); + $this->session->data['payment_address']['lastname'] = (isset($paypal_order_info['payer']['name']['surname']) ? $paypal_order_info['payer']['name']['surname'] : ''); $this->session->data['payment_address']['company'] = ''; $this->session->data['payment_address']['address_1'] = ''; $this->session->data['payment_address']['address_2'] = ''; @@ -1331,18 +1335,18 @@ 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'] = []; - + $this->session->data['payment_address']['custom_field'] = array(); + if (isset($paypal_order_info['payer']['address']['country_code'])) { $country_info = $this->model_extension_payment_paypal->getCountryByCode($paypal_order_info['payer']['address']['country_code']); - + if ($country_info) { $this->session->data['payment_address']['country'] = $country_info['name']; $this->session->data['payment_address']['country_id'] = $country_info['country_id']; } } } - + if ($this->cart->hasShipping()) { if ($this->customer->isLogged() && $this->customer->getAddressId()) { $this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); @@ -1353,32 +1357,32 @@ public function approveOrder() { unset($shipping_name[0]); $shipping_lastname = implode(' ', $shipping_name); } - - $this->session->data['shipping_address']['firstname'] = ($shipping_firstname ?? ''); - $this->session->data['shipping_address']['lastname'] = ($shipping_lastname ?? ''); + + $this->session->data['shipping_address']['firstname'] = (isset($shipping_firstname) ? $shipping_firstname : ''); + $this->session->data['shipping_address']['lastname'] = (isset($shipping_lastname) ? $shipping_lastname : ''); $this->session->data['shipping_address']['company'] = ''; - $this->session->data['shipping_address']['address_1'] = ($paypal_order_info['purchase_units'][0]['shipping']['address']['address_line_1'] ?? ''); - $this->session->data['shipping_address']['address_2'] = ($paypal_order_info['purchase_units'][0]['shipping']['address']['address_line_2'] ?? ''); - $this->session->data['shipping_address']['city'] = ($paypal_order_info['purchase_units'][0]['shipping']['address']['admin_area_2'] ?? ''); - $this->session->data['shipping_address']['postcode'] = ($paypal_order_info['purchase_units'][0]['shipping']['address']['postal_code'] ?? ''); + $this->session->data['shipping_address']['address_1'] = (isset($paypal_order_info['purchase_units'][0]['shipping']['address']['address_line_1']) ? $paypal_order_info['purchase_units'][0]['shipping']['address']['address_line_1'] : ''); + $this->session->data['shipping_address']['address_2'] = (isset($paypal_order_info['purchase_units'][0]['shipping']['address']['address_line_2']) ? $paypal_order_info['purchase_units'][0]['shipping']['address']['address_line_2'] : ''); + $this->session->data['shipping_address']['city'] = (isset($paypal_order_info['purchase_units'][0]['shipping']['address']['admin_area_2']) ? $paypal_order_info['purchase_units'][0]['shipping']['address']['admin_area_2'] : ''); + $this->session->data['shipping_address']['postcode'] = (isset($paypal_order_info['purchase_units'][0]['shipping']['address']['postal_code']) ? $paypal_order_info['purchase_units'][0]['shipping']['address']['postal_code'] : ''); $this->session->data['shipping_address']['country'] = ''; $this->session->data['shipping_address']['country_id'] = 0; $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'] = []; - + $this->session->data['shipping_address']['custom_field'] = array(); + 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']); - + if ($country_info) { $this->session->data['shipping_address']['country_id'] = $country_info['country_id']; $this->session->data['shipping_address']['country'] = $country_info['name']; $this->session->data['shipping_address']['address_format'] = $country_info['address_format']; - + if (isset($paypal_order_info['purchase_units'][0]['shipping']['address']['admin_area_1'])) { $zone_info = $this->model_extension_payment_paypal->getZoneByCode($country_info['country_id'], $paypal_order_info['purchase_units'][0]['shipping']['address']['admin_area_1']); - + if ($zone_info) { $this->session->data['shipping_address']['zone_id'] = $zone_info['zone_id']; $this->session->data['shipping_address']['zone'] = $zone_info['name']; @@ -1388,37 +1392,37 @@ public function approveOrder() { } } } - + if (($payment_type == 'googlepay_button') && !empty($this->request->post['payment_data'])) { $payment_data = json_decode(htmlspecialchars_decode($this->request->post['payment_data']), true); - + if (isset($payment_data['paymentMethodData']['info']['billingAddress']['name'])) { $payment_name = explode(' ', $payment_data['paymentMethodData']['info']['billingAddress']['name']); $payment_firstname = $payment_name[0]; unset($payment_name[0]); $payment_lastname = implode(' ', $payment_name); } - - $this->session->data['guest']['firstname'] = ($payment_firstname ?? ''); - $this->session->data['guest']['lastname'] = ($payment_lastname ?? ''); - $this->session->data['guest']['email'] = ($payment_data['email'] ?? ''); - $this->session->data['guest']['telephone'] = ($payment_data['paymentMethodData']['info']['billingAddress']['phoneNumber'] ?? ''); - - $this->session->data['payment_address']['firstname'] = ($shipping_firstname ?? ''); - $this->session->data['payment_address']['lastname'] = ($shipping_lastname ?? ''); - $this->session->data['payment_address']['address_1'] = ($payment_data['paymentMethodData']['info']['billingAddress']['address1'] ?? ''); - $this->session->data['payment_address']['city'] = ($payment_data['paymentMethodData']['info']['billingAddress']['locality'] ?? ''); - $this->session->data['payment_address']['postcode'] = ($payment_data['paymentMethodData']['info']['billingAddress']['postalCode'] ?? ''); - + + $this->session->data['guest']['firstname'] = (isset($payment_firstname) ? $payment_firstname : ''); + $this->session->data['guest']['lastname'] = (isset($payment_lastname) ? $payment_lastname : ''); + $this->session->data['guest']['email'] = (isset($payment_data['email']) ? $payment_data['email'] : ''); + $this->session->data['guest']['telephone'] = (isset($payment_data['paymentMethodData']['info']['billingAddress']['phoneNumber']) ? $payment_data['paymentMethodData']['info']['billingAddress']['phoneNumber'] : ''); + + $this->session->data['payment_address']['firstname'] = (isset($shipping_firstname) ? $shipping_firstname : ''); + $this->session->data['payment_address']['lastname'] = (isset($shipping_lastname) ? $shipping_lastname : ''); + $this->session->data['payment_address']['address_1'] = (isset($payment_data['paymentMethodData']['info']['billingAddress']['address1']) ? $payment_data['paymentMethodData']['info']['billingAddress']['address1'] : ''); + $this->session->data['payment_address']['city'] = (isset($payment_data['paymentMethodData']['info']['billingAddress']['locality']) ? $payment_data['paymentMethodData']['info']['billingAddress']['locality'] : ''); + $this->session->data['payment_address']['postcode'] = (isset($payment_data['paymentMethodData']['info']['billingAddress']['postalCode']) ? $payment_data['paymentMethodData']['info']['billingAddress']['postalCode'] : ''); + if (isset($payment_data['paymentMethodData']['info']['billingAddress']['countryCode'])) { $country_info = $this->model_extension_payment_paypal->getCountryByCode($payment_data['paymentMethodData']['info']['billingAddress']['countryCode']); - + if ($country_info) { $this->session->data['payment_address']['country'] = $country_info['name']; $this->session->data['payment_address']['country_id'] = $country_info['country_id']; } } - + if ($this->cart->hasShipping()) { if (isset($payment_data['shippingAddress']['name'])) { $shipping_name = explode(' ', $payment_data['shippingAddress']['name']); @@ -1426,16 +1430,16 @@ public function approveOrder() { unset($shipping_name[0]); $shipping_lastname = implode(' ', $shipping_name); } - - $this->session->data['shipping_address']['firstname'] = ($shipping_firstname ?? ''); - $this->session->data['shipping_address']['lastname'] = ($shipping_lastname ?? ''); - $this->session->data['shipping_address']['address_1'] = ($payment_data['shippingAddress']['address1'] ?? ''); - $this->session->data['shipping_address']['city'] = ($payment_data['shippingAddress']['locality'] ?? ''); - $this->session->data['shipping_address']['postcode'] = ($payment_data['shippingAddress']['postalCode'] ?? ''); - + + $this->session->data['shipping_address']['firstname'] = (isset($shipping_firstname) ? $shipping_firstname : ''); + $this->session->data['shipping_address']['lastname'] = (isset($shipping_lastname) ? $shipping_lastname : ''); + $this->session->data['shipping_address']['address_1'] = (isset($payment_data['shippingAddress']['address1']) ? $payment_data['shippingAddress']['address1'] : ''); + $this->session->data['shipping_address']['city'] = (isset($payment_data['shippingAddress']['locality']) ? $payment_data['shippingAddress']['locality'] : ''); + $this->session->data['shipping_address']['postcode'] = (isset($payment_data['shippingAddress']['postalCode']) ? $payment_data['shippingAddress']['postalCode'] : ''); + if (isset($payment_data['shippingAddress']['countryCode'])) { $country_info = $this->model_extension_payment_paypal->getCountryByCode($payment_data['shippingAddress']['countryCode']); - + if ($country_info) { $this->session->data['shipping_address']['country'] = $country_info['name']; $this->session->data['shipping_address']['country_id'] = $country_info['country_id']; @@ -1443,40 +1447,40 @@ public function approveOrder() { } } } - + if (($payment_type == 'applepay_button') && !empty($this->request->post['payment_data'])) { $payment_data = json_decode(htmlspecialchars_decode($this->request->post['payment_data']), true); - - $this->session->data['guest']['firstname'] = ($payment_data['billingContact']['givenName'] ?? ''); - $this->session->data['guest']['lastname'] = ($payment_data['billingContact']['familyName'] ?? ''); - $this->session->data['guest']['email'] = ($payment_data['shippingContact']['emailAddress'] ?? ''); - $this->session->data['guest']['telephone'] = ($payment_data['shippingContact']['phoneNumber'] ?? ''); - - $this->session->data['payment_address']['firstname'] = ($payment_data['billingContact']['givenName'] ?? ''); - $this->session->data['payment_address']['lastname'] = ($payment_data['billingContact']['familyName'] ?? ''); - $this->session->data['payment_address']['address_1'] = ($payment_data['billingContact']['addressLines'] ?? ''); - $this->session->data['payment_address']['city'] = ($payment_data['billingContact']['locality'] ?? ''); - $this->session->data['payment_address']['postcode'] = ($payment_data['billingContact']['postalCode'] ?? ''); - + + $this->session->data['guest']['firstname'] = (isset($payment_data['billingContact']['givenName']) ? $payment_data['billingContact']['givenName'] : ''); + $this->session->data['guest']['lastname'] = (isset($payment_data['billingContact']['familyName']) ? $payment_data['billingContact']['familyName'] : ''); + $this->session->data['guest']['email'] = (isset($payment_data['shippingContact']['emailAddress']) ? $payment_data['shippingContact']['emailAddress'] : ''); + $this->session->data['guest']['telephone'] = (isset($payment_data['shippingContact']['phoneNumber']) ? $payment_data['shippingContact']['phoneNumber'] : ''); + + $this->session->data['payment_address']['firstname'] = (isset($payment_data['billingContact']['givenName']) ? $payment_data['billingContact']['givenName'] : ''); + $this->session->data['payment_address']['lastname'] = (isset($payment_data['billingContact']['familyName']) ? $payment_data['billingContact']['familyName'] : ''); + $this->session->data['payment_address']['address_1'] = (isset($payment_data['billingContact']['addressLines']) ? implode(', ', $payment_data['billingContact']['addressLines']) : ''); + $this->session->data['payment_address']['city'] = (isset($payment_data['billingContact']['locality']) ? $payment_data['billingContact']['locality'] : ''); + $this->session->data['payment_address']['postcode'] = (isset($payment_data['billingContact']['postalCode']) ? $payment_data['billingContact']['postalCode'] : ''); + if (isset($payment_data['billingContact']['countryCode'])) { $country_info = $this->model_extension_payment_paypal->getCountryByCode($payment_data['billingContact']['countryCode']); - + if ($country_info) { $this->session->data['payment_address']['country'] = $country_info['name']; $this->session->data['payment_address']['country_id'] = $country_info['country_id']; } } - - if ($this->cart->hasShipping()) { - $this->session->data['shipping_address']['firstname'] = ($payment_data['shippingContact']['givenName'] ?? ''); - $this->session->data['shipping_address']['lastname'] = ($payment_data['shippingContact']['familyName'] ?? ''); - $this->session->data['shipping_address']['address_1'] = ($payment_data['shippingContact']['addressLines'] ?? ''); - $this->session->data['shipping_address']['city'] = ($payment_data['shippingContact']['locality'] ?? ''); - $this->session->data['shipping_address']['postcode'] = ($payment_data['shippingContact']['postalCode'] ?? ''); - + + if ($this->cart->hasShipping()) { + $this->session->data['shipping_address']['firstname'] = (isset($payment_data['shippingContact']['givenName']) ? $payment_data['shippingContact']['givenName'] : ''); + $this->session->data['shipping_address']['lastname'] = (isset($payment_data['shippingContact']['familyName']) ? $payment_data['shippingContact']['familyName'] : ''); + $this->session->data['shipping_address']['address_1'] = (isset($payment_data['shippingContact']['addressLines']) ? implode(', ', $payment_data['shippingContact']['addressLines']) : ''); + $this->session->data['shipping_address']['city'] = (isset($payment_data['shippingContact']['locality']) ? $payment_data['shippingContact']['locality'] : ''); + $this->session->data['shipping_address']['postcode'] = (isset($payment_data['shippingContact']['postalCode']) ? $payment_data['shippingContact']['postalCode'] : ''); + if (isset($payment_data['shippingContact']['countryCode'])) { $country_info = $this->model_extension_payment_paypal->getCountryByCode($payment_data['shippingContact']['countryCode']); - + if ($country_info) { $this->session->data['shipping_address']['country'] = $country_info['name']; $this->session->data['shipping_address']['country_id'] = $country_info['country_id']; @@ -1484,422 +1488,414 @@ public function approveOrder() { } } } - + if ($payment_type == 'button') { - $this->session->data['payment_method'] = [ + $this->session->data['payment_method'] = array( 'code' => 'paypal', 'title' => $this->language->get('text_paypal_title'), 'terms' => '', 'sort_order' => $this->config->get('paypal_sort_order') - ]; + ); } - + if ($payment_type == 'googlepay_button') { - $this->session->data['payment_method'] = [ + $this->session->data['payment_method'] = array( 'code' => 'paypal_googlepay', 'title' => $this->language->get('text_paypal_googlepay_title'), 'terms' => '', 'sort_order' => $this->config->get('paypal_sort_order') - ]; + ); } - + if ($payment_type == 'applepay_button') { - $this->session->data['payment_method'] = [ + $this->session->data['payment_method'] = array( 'code' => 'paypal_applepay', 'title' => $this->language->get('text_paypal_applepay_title'), 'terms' => '', 'sort_order' => $this->config->get('paypal_sort_order') - ]; + ); } - $data['url'] = $this->url->link('extension/payment/paypal/confirmOrder', '', true); + $data['url'] = $this->url->link('extension/payment/paypal/confirmOrder', '', true); } } else { - $paypal_order_info = $this->model_extension_payment_paypal->getPayPalOrder($this->session->data['order_id']); - - if (!$paypal_order_info) { - if (!empty($this->request->post['paypal_order_id'])) { - $paypal_order_id = $this->request->post['paypal_order_id']; - } - - if (($payment_type == 'card') && !empty($paypal_order_id)) { - $paypal_order_info = $paypal->getOrder($paypal_order_id); - - if ($paypal->hasErrors()) { - $error_messages = []; - - $errors = $paypal->getErrors(); - - foreach ($errors as $error) { - if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { - $error['message'] = $this->language->get('error_timeout'); - } - - if (isset($error['details'][0]['description'])) { - $error_messages[] = $error['details'][0]['description']; - } elseif (isset($error['message'])) { - $error_messages[] = $error['message']; - } - - $this->model_extension_payment_paypal->log($error, $error['message']); + if (!empty($this->request->post['paypal_order_id'])) { + $paypal_order_id = $this->request->post['paypal_order_id']; + } + + if (($payment_type == 'card') && !empty($paypal_order_id)) { + $paypal_order_info = $paypal->getOrder($paypal_order_id); + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); } - - $this->error['warning'] = implode(' ', $error_messages); + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); } - - if (isset($paypal_order_info['payment_source']['card']) && !$this->error) { - $this->model_extension_payment_paypal->log($paypal_order_info['payment_source']['card'], 'Card'); - - $liability_shift = ($paypal_order_info['payment_source']['card']['authentication_result']['liability_shift'] ?? ''); - $enrollment_status = ($paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['enrollment_status'] ?? ''); - $authentication_status = ($paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['authentication_status'] ?? ''); - - if ($enrollment_status == 'Y') { - if (($authentication_status == 'N') && !$setting['card']['secure_scenario']['failed_authentication']) { - $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['failed_authentication']['error']); - } - - if (($authentication_status == 'R') && !$setting['card']['secure_scenario']['rejected_authentication']) { - $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['rejected_authentication']['error']); - } - - if (($authentication_status == 'A') && !$setting['card']['secure_scenario']['attempted_authentication']) { - $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['attempted_authentication']['error']); - } - - if (($authentication_status == 'U') && !$setting['card']['secure_scenario']['unable_authentication']) { - $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['unable_authentication']['error']); - } - - if (($authentication_status == 'C') && !$setting['card']['secure_scenario']['challenge_authentication']) { - $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['challenge_authentication']['error']); - } + + $this->error['warning'] = implode(' ', $error_messages); + } + + if (isset($paypal_order_info['payment_source']['card']) && !$this->error) { + $this->model_extension_payment_paypal->log($paypal_order_info['payment_source']['card'], 'Card'); + + $liability_shift = (isset($paypal_order_info['payment_source']['card']['authentication_result']['liability_shift']) ? $paypal_order_info['payment_source']['card']['authentication_result']['liability_shift'] : ''); + $enrollment_status = (isset($paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['enrollment_status']) ? $paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['enrollment_status'] : ''); + $authentication_status = (isset($paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['authentication_status']) ? $paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['authentication_status'] : ''); + + if ($enrollment_status == 'Y') { + if (($authentication_status == 'N') && !$setting['card']['secure_scenario']['failed_authentication']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['failed_authentication']['error']); } - - if (($enrollment_status == 'N') && !$setting['card']['secure_scenario']['card_ineligible']) { - $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['card_ineligible']['error']); + + if (($authentication_status == 'R') && !$setting['card']['secure_scenario']['rejected_authentication']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['rejected_authentication']['error']); } - - if (($enrollment_status == 'U') && !$setting['card']['secure_scenario']['system_unavailable']) { - $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['system_unavailable']['error']); + + if (($authentication_status == 'A') && !$setting['card']['secure_scenario']['attempted_authentication']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['attempted_authentication']['error']); } - - if (($enrollment_status == 'B') && !$setting['card']['secure_scenario']['system_bypassed']) { - $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['system_bypassed']['error']); + + if (($authentication_status == 'U') && !$setting['card']['secure_scenario']['unable_authentication']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['unable_authentication']['error']); + } + + if (($authentication_status == 'C') && !$setting['card']['secure_scenario']['challenge_authentication']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['challenge_authentication']['error']); } } - - if (!empty($this->error['warning'])) { - $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); + + if (($enrollment_status == 'N') && !$setting['card']['secure_scenario']['card_ineligible']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['card_ineligible']['error']); + } + + if (($enrollment_status == 'U') && !$setting['card']['secure_scenario']['system_unavailable']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['system_unavailable']['error']); } + + if (($enrollment_status == 'B') && !$setting['card']['secure_scenario']['system_bypassed']) { + $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['system_bypassed']['error']); + } + } + + if (!empty($this->error['warning'])) { + $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } + } - if (!empty($paypal_order_id) && !$this->error) { - if ($transaction_method == 'authorize') { - $result = $paypal->setOrderAuthorize($paypal_order_id); - } else { - $result = $paypal->setOrderCapture($paypal_order_id); + if (!empty($paypal_order_id) && !$this->error) { + if ($transaction_method == 'authorize') { + $result = $paypal->setOrderAuthorize($paypal_order_id); + } else { + $result = $paypal->setOrderCapture($paypal_order_id); + } + + if ($paypal->hasErrors()) { + $error_messages = array(); + + $errors = $paypal->getErrors(); + + foreach ($errors as $error) { + if (isset($error['details'][0]['issue']) && ($error['details'][0]['issue'] == 'INSTRUMENT_DECLINED')) { + $data['restart'] = true; + } + + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { + $error['message'] = $this->language->get('error_timeout'); + } + + if (isset($error['details'][0]['description'])) { + $error_messages[] = $error['details'][0]['description']; + } elseif (isset($error['message'])) { + $error_messages[] = $error['message']; + } + + $this->model_extension_payment_paypal->log($error, $error['message']); } - - if ($paypal->hasErrors()) { - $error_messages = []; - - $errors = $paypal->getErrors(); - - foreach ($errors as $error) { - if (isset($error['details'][0]['issue']) && ($error['details'][0]['issue'] == 'INSTRUMENT_DECLINED')) { - $data['restart'] = true; + + $this->error['warning'] = implode(' ', $error_messages); + } + + if (!empty($this->error['warning'])) { + $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); + } + + if (!$this->error) { + $this->load->model('checkout/order'); + + $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); + + if ($transaction_method == 'authorize') { + $this->model_extension_payment_paypal->log($result, 'Authorize Order'); + + if (isset($result['purchase_units'][0]['payments']['authorizations'][0]['status']) && isset($result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status'])) { + $authorization_id = $result['purchase_units'][0]['payments']['authorizations'][0]['id']; + $authorization_status = $result['purchase_units'][0]['payments']['authorizations'][0]['status']; + $seller_protection_status = $result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status']; + $order_status_id = 0; + $transaction_status = ''; + $payment_method = ''; + $vault_id = ''; + $vault_customer_id = ''; + $card_type = (!empty($this->request->post['card_type']) ? $this->request->post['card_type'] : ''); + $card_nice_type = (!empty($this->request->post['card_nice_type']) ? $this->request->post['card_nice_type'] : ''); + $card_last_digits = ''; + $card_expiry = ''; + + if (!$this->cart->hasShipping()) { + $seller_protection_status = 'NOT_ELIGIBLE'; } - - if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { - $error['message'] = $this->language->get('error_timeout'); + + foreach ($result['payment_source'] as $payment_source_key => $payment_source) { + $payment_method = $payment_source_key; + $vault_id = (isset($payment_source['attributes']['vault']['id']) ? $payment_source['attributes']['vault']['id'] : ''); + $vault_customer_id = (isset($payment_source['attributes']['vault']['customer']['id']) ? $payment_source['attributes']['vault']['customer']['id'] : ''); + $card_last_digits = (isset($payment_source['last_digits']) ? $payment_source['last_digits'] : ''); + $card_expiry = (isset($payment_source['expiry']) ? $payment_source['expiry'] : ''); + + break; } - if (isset($error['details'][0]['description'])) { - $error_messages[] = $error['details'][0]['description']; - } elseif (isset($error['message'])) { - $error_messages[] = $error['message']; + if ($authorization_status == 'CREATED') { + $order_status_id = $setting['order_status']['pending']['id']; + $transaction_status = 'created'; } - $this->model_extension_payment_paypal->log($error, $error['message']); - } - - $this->error['warning'] = implode(' ', $error_messages); - } - - if (!empty($this->error['warning'])) { - $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); - } - - if (!$this->error) { - $this->load->model('checkout/order'); - - $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - - if ($transaction_method == 'authorize') { - $this->model_extension_payment_paypal->log($result, 'Authorize Order'); - - if (isset($result['purchase_units'][0]['payments']['authorizations'][0]['status']) && isset($result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status'])) { - $authorization_id = $result['purchase_units'][0]['payments']['authorizations'][0]['id']; - $authorization_status = $result['purchase_units'][0]['payments']['authorizations'][0]['status']; - $seller_protection_status = $result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status']; - $order_status_id = 0; - $transaction_status = ''; - $payment_method = ''; - $vault_id = ''; - $vault_customer_id = ''; - $card_type = (!empty($this->request->post['card_type']) ? $this->request->post['card_type'] : ''); - $card_nice_type = (!empty($this->request->post['card_nice_type']) ? $this->request->post['card_nice_type'] : ''); - $card_last_digits = ''; - $card_expiry = ''; - $paypal_order_data = []; - - if (!$this->cart->hasShipping()) { - $seller_protection_status = 'NOT_ELIGIBLE'; - } - - foreach ($result['payment_source'] as $payment_source_key => $payment_source) { - $payment_method = $payment_source_key; - $vault_id = ($payment_source['attributes']['vault']['id'] ?? ''); - $vault_customer_id = ($payment_source['attributes']['vault']['customer']['id'] ?? ''); - $card_last_digits = ($payment_source['last_digits'] ?? ''); - $card_expiry = ($payment_source['expiry'] ?? ''); - - break; - } - - if ($authorization_status == 'CREATED') { - $order_status_id = $setting['order_status']['pending']['id']; - $transaction_status = 'created'; - } - - if ($authorization_status == 'CAPTURED') { - $this->error['warning'] = sprintf($this->language->get('error_authorization_captured'), $this->url->link('information/contact', '', true)); - } - - if ($authorization_status == 'DENIED') { - $order_status_id = $setting['order_status']['denied']['id']; - $transaction_status = 'denied'; - - $this->error['warning'] = $this->language->get('error_authorization_denied'); - } - - if ($authorization_status == 'EXPIRED') { - $this->error['warning'] = sprintf($this->language->get('error_authorization_expired'), $this->url->link('information/contact', '', true)); - } - - if ($authorization_status == 'PENDING') { - $order_status_id = $setting['order_status']['pending']['id']; - $transaction_status = 'pending'; - } - - if (($authorization_status == 'CREATED') || ($authorization_status == 'DENIED') || ($authorization_status == 'PENDING')) { - $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); - - $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); - } - - if (($authorization_status == 'CREATED') || ($authorization_status == 'DENIED') || ($authorization_status == 'PENDING')) { - if ($payment_method == 'paypal') { - $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); - } - - if (!empty($paypal_customer_token['vault_id'])) { - $vault_id = $paypal_customer_token['vault_id']; - $vault_customer_id = $paypal_customer_token['vault_customer_id']; - } + if ($authorization_status == 'CAPTURED') { + $this->error['warning'] = sprintf($this->language->get('error_authorization_captured'), $this->url->link('information/contact', '', true)); + } + + if ($authorization_status == 'DENIED') { + $transaction_status = 'denied'; + + $this->error['warning'] = $this->language->get('error_authorization_denied'); + } + + if ($authorization_status == 'EXPIRED') { + $this->error['warning'] = sprintf($this->language->get('error_authorization_expired'), $this->url->link('information/contact', '', true)); + } + + if ($authorization_status == 'PENDING') { + $order_status_id = $setting['order_status']['pending']['id']; + $transaction_status = 'pending'; + } + + if (($authorization_status == 'CREATED') || ($authorization_status == 'DENIED') || ($authorization_status == 'PENDING')) { + if ($payment_method == 'paypal') { + $paypal_customer_token = array(); + + if ($setting['general']['vault_status'] && $this->customer->isLogged()) { + $paypal_customer_token = $this->model_extension_payment_paypal->getPayPalCustomerMainToken($this->customer->getId(), $payment_method); } - - $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); - - $paypal_order_data = [ - 'order_id' => $this->session->data['order_id'], - 'paypal_order_id' => $paypal_order_id, - 'transaction_id' => $authorization_id, - 'transaction_status' => $transaction_status, - 'payment_method' => $payment_method, - 'vault_id' => $vault_id, - 'vault_customer_id' => $vault_customer_id, - 'card_type' => $card_type, - 'card_nice_type' => $card_nice_type, - 'card_last_digits' => $card_last_digits, - 'card_expiry' => $card_expiry, - 'total' => $order_info['total'], - 'currency_code' => $order_info['currency_code'], - 'environment' => $environment - ]; - - $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); - - if ($vault_id && $this->customer->isLogged()) { - $customer_id = $this->customer->getId(); - - $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 = [ - 'customer_id' => $customer_id, - 'payment_method' => $payment_method, - 'vault_id' => $vault_id, - 'vault_customer_id' => $vault_customer_id, - 'card_type' => $card_type, - '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); - } - - $this->model_extension_payment_paypal->setPayPalCustomerMainToken($customer_id, $payment_method, $vault_id); + + if (!empty($paypal_customer_token['vault_id'])) { + $vault_id = $paypal_customer_token['vault_id']; + $vault_customer_id = $paypal_customer_token['vault_customer_id']; } } - - if (($authorization_status == 'CREATED') || ($authorization_status == 'PENDING')) { - $recurring_products = $this->cart->getRecurringProducts(); - - foreach ($recurring_products as $recurring_product) { - $this->model_extension_payment_paypal->recurringPayment($recurring_product, $order_info, $paypal_order_data); + + $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); + + $paypal_order_data = array( + 'order_id' => $this->session->data['order_id'], + 'paypal_order_id' => $paypal_order_id, + 'transaction_id' => $authorization_id, + 'transaction_status' => $transaction_status, + 'payment_method' => $payment_method, + 'vault_id' => $vault_id, + 'vault_customer_id' => $vault_customer_id, + 'card_type' => $card_type, + 'card_nice_type' => $card_nice_type, + 'card_last_digits' => $card_last_digits, + 'card_expiry' => $card_expiry, + 'total' => $order_info['total'], + 'currency_code' => $order_info['currency_code'], + 'environment' => $environment + ); + + $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); + + if ($vault_id && $this->customer->isLogged()) { + $customer_id = $this->customer->getId(); + + $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( + 'customer_id' => $customer_id, + 'payment_method' => $payment_method, + 'vault_id' => $vault_id, + 'vault_customer_id' => $vault_customer_id, + 'card_type' => $card_type, + '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); } - } - - if (($authorization_status == 'CREATED') || ($authorization_status == 'PARTIALLY_CAPTURED') || ($authorization_status == 'PARTIALLY_CREATED') || ($authorization_status == 'VOIDED') || ($authorization_status == 'PENDING')) { - $data['url'] = $this->url->link('checkout/success', '', true); + + $this->model_extension_payment_paypal->setPayPalCustomerMainToken($customer_id, $payment_method, $vault_id); } } - } else { - $this->model_extension_payment_paypal->log($result, 'Capture Order'); - - if (isset($result['purchase_units'][0]['payments']['captures'][0]['status']) && isset($result['purchase_units'][0]['payments']['captures'][0]['seller_protection']['status'])) { - $capture_id = $result['purchase_units'][0]['payments']['captures'][0]['id']; - $capture_status = $result['purchase_units'][0]['payments']['captures'][0]['status']; - $seller_protection_status = $result['purchase_units'][0]['payments']['captures'][0]['seller_protection']['status']; - $order_status_id = 0; - $transaction_status = ''; - $payment_method = ''; - $vault_id = ''; - $vault_customer_id = ''; - $card_type = (!empty($this->request->post['card_type']) ? $this->request->post['card_type'] : ''); - $card_nice_type = (!empty($this->request->post['card_nice_type']) ? $this->request->post['card_nice_type'] : ''); - $card_last_digits = ''; - $card_expiry = ''; - $paypal_order_data = []; - - if (!$this->cart->hasShipping()) { - $seller_protection_status = 'NOT_ELIGIBLE'; - } - - foreach ($result['payment_source'] as $payment_source_key => $payment_source) { - $payment_method = $payment_source_key; - $vault_id = ($payment_source['attributes']['vault']['id'] ?? ''); - $vault_customer_id = ($payment_source['attributes']['vault']['customer']['id'] ?? ''); - $card_last_digits = ($payment_source['last_digits'] ?? ''); - $card_expiry = ($payment_source['expiry'] ?? ''); - - break; - } - - if ($capture_status == 'COMPLETED') { - $order_status_id = $setting['order_status']['completed']['id']; - $transaction_status = 'completed'; - } - - if ($capture_status == 'DECLINED') { - $order_status_id = $setting['order_status']['denied']['id']; - $transaction_status = 'denied'; - - $this->error['warning'] = $this->language->get('error_capture_declined'); - } - - if ($capture_status == 'FAILED') { - $this->error['warning'] = sprintf($this->language->get('error_capture_failed'), $this->url->link('information/contact', '', true)); - } - - if ($capture_status == 'PENDING') { - $order_status_id = $setting['order_status']['pending']['id']; - $transaction_status = 'pending'; - } - - if (($capture_status == 'COMPLETED') || ($capture_status == 'DECLINED') || ($capture_status == 'PENDING')) { - $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); - - $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); - } - - if (($capture_status == 'COMPLETED') || ($capture_status == 'DECLINED') || ($capture_status == 'PENDING')) { - if ($payment_method == 'paypal') { - $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); - } - - if (!empty($paypal_customer_token['vault_id'])) { - $vault_id = $paypal_customer_token['vault_id']; - $vault_customer_id = $paypal_customer_token['vault_customer_id']; - } - } - - $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); - - $paypal_order_data = [ - 'order_id' => $this->session->data['order_id'], - 'paypal_order_id' => $paypal_order_id, - 'transaction_id' => $capture_id, - 'transaction_status' => $transaction_status, - 'payment_method' => $payment_method, - 'vault_id' => $vault_id, - 'vault_customer_id' => $vault_customer_id, - 'card_type' => $card_type, - 'card_nice_type' => $card_nice_type, - 'card_last_digits' => $card_last_digits, - 'card_expiry' => $card_expiry, - 'total' => $order_info['total'], - 'currency_code' => $order_info['currency_code'], - 'environment' => $environment - ]; - - $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); - - if ($vault_id && $this->customer->isLogged()) { - $customer_id = $this->customer->getId(); - - $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 = [ - 'customer_id' => $customer_id, - 'payment_method' => $payment_method, - 'vault_id' => $vault_id, - 'vault_customer_id' => $vault_customer_id, - 'card_type' => $card_type, - '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); - } - - $this->model_extension_payment_paypal->setPayPalCustomerMainToken($customer_id, $payment_method, $vault_id); - } - } - - if (($capture_status == 'COMPLETED') || ($capture_status == 'PENDING')) { - $recurring_products = $this->cart->getRecurringProducts(); - - foreach ($recurring_products as $recurring_product) { - $this->model_extension_payment_paypal->recurringPayment($recurring_product, $order_info, $paypal_order_data); + + if ($order_status_id) { + $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); + + $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); + } + + if (($authorization_status == 'CREATED') || ($authorization_status == 'PENDING')) { + $recurring_products = $this->cart->getRecurringProducts(); + + foreach ($recurring_products as $recurring_product) { + $this->model_extension_payment_paypal->recurringPayment($recurring_product, $order_info, $paypal_order_data); + } + } + + if (($authorization_status == 'CREATED') || ($authorization_status == 'PARTIALLY_CAPTURED') || ($authorization_status == 'PARTIALLY_CREATED') || ($authorization_status == 'PENDING')) { + $data['url'] = $this->url->link('checkout/success', '', true); + } + } + } else { + $this->model_extension_payment_paypal->log($result, 'Capture Order'); + + if (isset($result['purchase_units'][0]['payments']['captures'][0]['status']) && isset($result['purchase_units'][0]['payments']['captures'][0]['seller_protection']['status'])) { + $capture_id = $result['purchase_units'][0]['payments']['captures'][0]['id']; + $capture_status = $result['purchase_units'][0]['payments']['captures'][0]['status']; + $seller_protection_status = $result['purchase_units'][0]['payments']['captures'][0]['seller_protection']['status']; + $order_status_id = 0; + $transaction_status = ''; + $payment_method = ''; + $vault_id = ''; + $vault_customer_id = ''; + $card_type = (!empty($this->request->post['card_type']) ? $this->request->post['card_type'] : ''); + $card_nice_type = (!empty($this->request->post['card_nice_type']) ? $this->request->post['card_nice_type'] : ''); + $card_last_digits = ''; + $card_expiry = ''; + + if (!$this->cart->hasShipping()) { + $seller_protection_status = 'NOT_ELIGIBLE'; + } + + foreach ($result['payment_source'] as $payment_source_key => $payment_source) { + $payment_method = $payment_source_key; + $vault_id = (isset($payment_source['attributes']['vault']['id']) ? $payment_source['attributes']['vault']['id'] : ''); + $vault_customer_id = (isset($payment_source['attributes']['vault']['customer']['id']) ? $payment_source['attributes']['vault']['customer']['id'] : ''); + $card_last_digits = (isset($payment_source['last_digits']) ? $payment_source['last_digits'] : ''); + $card_expiry = (isset($payment_source['expiry']) ? $payment_source['expiry'] : ''); + + break; + } + + if ($capture_status == 'COMPLETED') { + $order_status_id = $setting['order_status']['completed']['id']; + $transaction_status = 'completed'; + } + + if ($capture_status == 'DECLINED') { + $transaction_status = 'denied'; + + $this->error['warning'] = $this->language->get('error_capture_declined'); + } + + if ($capture_status == 'FAILED') { + $this->error['warning'] = sprintf($this->language->get('error_capture_failed'), $this->url->link('information/contact', '', true)); + } + + if ($capture_status == 'PENDING') { + $order_status_id = $setting['order_status']['pending']['id']; + $transaction_status = 'pending'; + } + + if (($capture_status == 'COMPLETED') || ($capture_status == 'DECLINED') || ($capture_status == 'PENDING')) { + if ($payment_method == 'paypal') { + $paypal_customer_token = array(); + + if ($setting['general']['vault_status'] && $this->customer->isLogged()) { + $paypal_customer_token = $this->model_extension_payment_paypal->getPayPalCustomerMainToken($this->customer->getId(), $payment_method); + } + + if (!empty($paypal_customer_token['vault_id'])) { + $vault_id = $paypal_customer_token['vault_id']; + $vault_customer_id = $paypal_customer_token['vault_customer_id']; } } - - if (($capture_status == 'COMPLETED') || ($capture_status == 'PARTIALLY_REFUNDED') || ($capture_status == 'REFUNDED') || ($capture_status == 'PENDING')) { - $data['url'] = $this->url->link('checkout/success', '', true); + + $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); + + $paypal_order_data = array( + 'order_id' => $this->session->data['order_id'], + 'paypal_order_id' => $paypal_order_id, + 'transaction_id' => $capture_id, + 'transaction_status' => $transaction_status, + 'payment_method' => $payment_method, + 'vault_id' => $vault_id, + 'vault_customer_id' => $vault_customer_id, + 'card_type' => $card_type, + 'card_nice_type' => $card_nice_type, + 'card_last_digits' => $card_last_digits, + 'card_expiry' => $card_expiry, + 'total' => $order_info['total'], + 'currency_code' => $order_info['currency_code'], + 'environment' => $environment + ); + + $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); + + if ($vault_id && $this->customer->isLogged()) { + $customer_id = $this->customer->getId(); + + $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( + 'customer_id' => $customer_id, + 'payment_method' => $payment_method, + 'vault_id' => $vault_id, + 'vault_customer_id' => $vault_customer_id, + 'card_type' => $card_type, + '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); + } + + $this->model_extension_payment_paypal->setPayPalCustomerMainToken($customer_id, $payment_method, $vault_id); } } + + if ($order_status_id) { + $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); + + $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); + } + + if (($capture_status == 'COMPLETED') || ($capture_status == 'PENDING')) { + $recurring_products = $this->cart->getRecurringProducts(); + + foreach ($recurring_products as $recurring_product) { + $this->model_extension_payment_paypal->recurringPayment($recurring_product, $order_info, $paypal_order_data); + } + } + + if (($capture_status == 'COMPLETED') || ($capture_status == 'PENDING')) { + $data['url'] = $this->url->link('checkout/success', '', true); + } } } } @@ -1908,21 +1904,21 @@ public function approveOrder() { } $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); - $this->response->setOutput(json_encode($data)); + $this->response->setOutput(json_encode($data)); } - + public function confirmOrder() { $this->load->language('extension/payment/paypal'); $this->load->language('checkout/cart'); $this->load->model('tool/image'); - + if (!isset($this->session->data['paypal_order_id'])) { $this->response->redirect($this->url->link('checkout/cart', '', true)); } - + // Coupon if (isset($this->request->post['coupon']) && $this->validateCoupon()) { $this->session->data['coupon'] = $this->request->post['coupon']; @@ -1949,15 +1945,15 @@ public function confirmOrder() { $this->response->redirect($this->url->link('extension/payment/paypal/confirmOrder', '', true)); } - + $this->document->setTitle($this->language->get('text_paypal')); - + $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/moment.js'); $this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js'); $this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css'); - + $theme = $this->config->get('theme_' . $this->config->get('config_theme') . '_directory'); - + if (file_exists(DIR_TEMPLATE . $theme . '/stylesheet/paypal/paypal.css')) { $this->document->addStyle('catalog/view/theme/' . $theme . '/stylesheet/paypal/paypal.css'); } else { @@ -1965,7 +1961,7 @@ public function confirmOrder() { } $data['heading_title'] = $this->language->get('text_paypal'); - + $data['text_checkout_payment_address'] = $this->language->get('text_checkout_payment_address'); $data['text_checkout_shipping_address'] = $this->language->get('text_checkout_shipping_address'); $data['text_checkout_shipping_method'] = $this->language->get('text_checkout_shipping_method'); @@ -1977,14 +1973,14 @@ public function confirmOrder() { $data['text_select'] = $this->language->get('text_select'); $data['text_none'] = $this->language->get('text_none'); $data['text_loading'] = $this->language->get('text_loading'); - + $data['column_image'] = $this->language->get('column_image'); $data['column_name'] = $this->language->get('column_name'); $data['column_model'] = $this->language->get('column_model'); $data['column_quantity'] = $this->language->get('column_quantity'); $data['column_price'] = $this->language->get('column_price'); $data['column_total'] = $this->language->get('column_total'); - + $data['entry_email'] = $this->language->get('entry_email'); $data['entry_firstname'] = $this->language->get('entry_firstname'); $data['entry_lastname'] = $this->language->get('entry_lastname'); @@ -1996,26 +1992,26 @@ public function confirmOrder() { $data['entry_city'] = $this->language->get('entry_city'); $data['entry_country'] = $this->language->get('entry_country'); $data['entry_zone'] = $this->language->get('entry_zone'); - + $data['button_confirm'] = $this->language->get('button_confirm'); $data['button_shipping'] = $this->language->get('button_shipping'); - $data['breadcrumbs'] = []; + $data['breadcrumbs'] = array(); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', '', true) - ]; - - $data['breadcrumbs'][] = [ + ); + + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_cart'), 'href' => $this->url->link('checkout/cart', '', true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_paypal'), 'href' => $this->url->link('extension/payment/paypal/confirmOrder', '', true) - ]; + ); $points_total = 0; @@ -2024,7 +2020,7 @@ public function confirmOrder() { $points_total += $product['points']; } } - + if (isset($this->request->post['next'])) { $data['next'] = $this->request->post['next']; } else { @@ -2036,9 +2032,9 @@ public function confirmOrder() { if (!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) { $this->response->redirect($this->url->link('checkout/cart', '', true)); } - - $data['products'] = []; - + + $data['products'] = array(); + $products = $this->cart->getProducts(); foreach ($products as $product) { @@ -2060,7 +2056,7 @@ public function confirmOrder() { $image = ''; } - $option_data = []; + $option_data = array(); foreach ($product['option'] as $option) { if ($option['type'] != 'file') { @@ -2075,10 +2071,10 @@ public function confirmOrder() { } } - $option_data[] = [ + $option_data[] = array( 'name' => $option['name'], 'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) - ]; + ); } // Display prices @@ -2091,17 +2087,17 @@ public function confirmOrder() { $price = false; $total = false; } - + $recurring = ''; if ($product['recurring']) { - $frequencies = [ + $frequencies = array( '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']) . ' '; @@ -2114,46 +2110,46 @@ public function confirmOrder() { } } - $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) - ]; + $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) + ); } // Gift Voucher - $data['vouchers'] = []; + $data['vouchers'] = array(); if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $key => $voucher) { - $data['vouchers'][] = [ + $data['vouchers'][] = array( 'key' => $key, 'description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount'], $this->session->data['currency']), 'remove' => $this->url->link('checkout/cart', 'remove=' . $key, true) - ]; + ); } } - + $this->load->model('extension/extension'); - + if ($this->cart->hasShipping()) { $data['has_shipping'] = true; - - $data['shipping_address'] = $this->session->data['shipping_address'] ?? []; - + + $data['shipping_address'] = isset($this->session->data['shipping_address']) ? $this->session->data['shipping_address'] : array(); + if (!empty($data['shipping_address'])) { // Shipping Methods - $quote_data = []; + $quote_data = array(); $results = $this->model_extension_extension->getExtensions('shipping'); @@ -2165,18 +2161,18 @@ public function confirmOrder() { $quote = $this->{'model_extension_shipping_' . $result['code']}->getQuote($data['shipping_address']); if ($quote) { - $quote_data[$result['code']] = [ + $quote_data[$result['code']] = array( 'title' => $quote['title'], 'quote' => $quote['quote'], 'sort_order' => $quote['sort_order'], 'error' => $quote['error'] - ]; + ); } } } if (!empty($quote_data)) { - $sort_order = []; + $sort_order = array(); foreach ($quote_data as $key => $value) { $sort_order[$key] = $value['sort_order']; @@ -2199,38 +2195,38 @@ public function confirmOrder() { } else { unset($this->session->data['shipping_methods']); unset($this->session->data['shipping_method']); - + $data['error_no_shipping'] = $this->language->get('error_no_shipping'); } } else { unset($this->session->data['shipping_methods']); unset($this->session->data['shipping_method']); - + $data['error_no_shipping'] = $this->language->get('error_no_shipping'); } } } else { $data['has_shipping'] = false; } - - $data['guest'] = $this->session->data['guest'] ?? []; - $data['payment_address'] = $this->session->data['payment_address'] ?? []; - + + $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(); + // Totals - $totals = []; + $totals = array(); $taxes = $this->cart->getTaxes(); $total = 0; // Because __call can not keep var references so we put them into an array. - $total_data = [ + $total_data = array( 'totals' => &$totals, 'taxes' => &$taxes, 'total' => &$total - ]; + ); // Display prices if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { - $sort_order = []; + $sort_order = array(); $results = $this->model_extension_extension->getExtensions('total'); @@ -2249,7 +2245,7 @@ public function confirmOrder() { } } - $sort_order = []; + $sort_order = array(); foreach ($totals as $key => $value) { $sort_order[$key] = $value['sort_order']; @@ -2257,11 +2253,11 @@ public function confirmOrder() { array_multisort($sort_order, SORT_ASC, $totals); } - + /** * Payment methods */ - $method_data = []; + $method_data = array(); $results = $this->model_extension_extension->getExtensions('payment'); @@ -2277,51 +2273,51 @@ public function confirmOrder() { } } - $sort_order = []; + $sort_order = array(); foreach ($method_data as $key => $value) { $sort_order[$key] = $value['sort_order']; } array_multisort($sort_order, SORT_ASC, $method_data); - + $this->session->data['payment_methods'] = $method_data; $data['payment_methods'] = $method_data; if (!isset($method_data['paypal'])) { $this->session->data['error_warning'] = $this->language->get('error_unavailable'); - + $this->response->redirect($this->url->link('checkout/checkout', '', true)); } - + if (isset($this->session->data['payment_method']['code'])) { $data['payment_method_code'] = $this->session->data['payment_method']['code']; } else { $this->session->data['payment_method'] = $method_data['paypal']; - + $data['payment_method_code'] = $this->session->data['payment_method']['code']; } - + // Custom Fields $this->load->model('account/custom_field'); $data['custom_fields'] = $this->model_account_custom_field->getCustomFields(); // Totals - $totals = []; + $totals = array(); $taxes = $this->cart->getTaxes(); $total = 0; // Because __call can not keep var references so we put them into an array. - $total_data = [ + $total_data = array( 'totals' => &$totals, 'taxes' => &$taxes, 'total' => &$total - ]; + ); // Display prices if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { - $sort_order = []; + $sort_order = array(); $results = $this->model_extension_extension->getExtensions('total'); @@ -2340,7 +2336,7 @@ public function confirmOrder() { } } - $sort_order = []; + $sort_order = array(); foreach ($totals as $key => $value) { $sort_order[$key] = $value['sort_order']; @@ -2349,13 +2345,13 @@ public function confirmOrder() { array_multisort($sort_order, SORT_ASC, $totals); } - $data['totals'] = []; + $data['totals'] = array(); foreach ($totals as $total) { - $data['totals'][] = [ + $data['totals'][] = array( 'title' => $total['title'], 'text' => $this->currency->format($total['value'], $this->session->data['currency']), - ]; + ); } $data['action_confirm'] = $this->url->link('extension/payment/paypal/completeOrder', '', true); @@ -2393,12 +2389,12 @@ public function confirmOrder() { $this->response->setOutput($this->load->view('extension/payment/paypal/confirm', $data)); } - - public function completeOrder() { + + public function completeOrder() { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + // Validate if payment address has been set. if (empty($this->session->data['payment_address'])) { $this->response->redirect($this->url->link('checkout/checkout', '', true)); @@ -2408,7 +2404,7 @@ public function completeOrder() { if (!isset($this->session->data['payment_method'])) { $this->response->redirect($this->url->link('checkout/checkout', '', true)); } - + if ($this->cart->hasShipping()) { // Validate if shipping address has been set. if (empty($this->session->data['shipping_address'])) { @@ -2428,24 +2424,24 @@ public function completeOrder() { if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { $this->response->redirect($this->url->link('checkout/cart', '', true)); } + + if (isset($this->session->data['paypal_order_id'])) { + $order_data = array(); - if (isset($this->session->data['paypal_order_id'])) { - $order_data = []; - - $totals = []; + $totals = array(); $taxes = $this->cart->getTaxes(); $total = 0; // Because __call can not keep var references so we put them into an array. - $total_data = [ + $total_data = array( 'totals' => &$totals, 'taxes' => &$taxes, 'total' => &$total - ]; + ); $this->load->model('extension/extension'); - $sort_order = []; + $sort_order = array(); $results = $this->model_extension_extension->getExtensions('total'); @@ -2464,14 +2460,14 @@ public function completeOrder() { } } - $sort_order = []; + $sort_order = array(); foreach ($totals as $key => $value) { $sort_order[$key] = $value['sort_order']; } array_multisort($sort_order, SORT_ASC, $totals); - + $order_data['totals'] = $totals; $order_data['invoice_prefix'] = $this->config->get('config_invoice_prefix'); @@ -2487,20 +2483,20 @@ public function completeOrder() { $order_data['store_url'] = HTTP_SERVER; } } - + $order_data['customer_id'] = $this->session->data['guest']['customer_id']; $order_data['customer_group_id'] = $this->session->data['guest']['customer_group_id']; $order_data['firstname'] = $this->session->data['guest']['firstname']; $order_data['lastname'] = $this->session->data['guest']['lastname']; $order_data['telephone'] = $this->session->data['guest']['telephone']; $order_data['custom_field'] = $this->session->data['guest']['custom_field']; - + if ($this->session->data['guest']['email']) { $order_data['email'] = $this->session->data['guest']['email']; } else { $order_data['email'] = $this->config->get('config_email'); } - + $order_data['payment_firstname'] = $this->session->data['payment_address']['firstname']; $order_data['payment_lastname'] = $this->session->data['payment_address']['lastname']; $order_data['payment_company'] = $this->session->data['payment_address']['company']; @@ -2513,7 +2509,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'] = ($this->session->data['payment_address']['custom_field'] ?? []); + $order_data['payment_custom_field'] = (isset($this->session->data['payment_address']['custom_field']) ? $this->session->data['payment_address']['custom_field'] : array()); if (isset($this->session->data['payment_method']['title'])) { $order_data['payment_method'] = $this->session->data['payment_method']['title']; @@ -2525,7 +2521,7 @@ public function completeOrder() { $order_data['payment_code'] = $this->session->data['payment_method']['code']; } else { $order_data['payment_code'] = ''; - } + } if ($this->cart->hasShipping()) { $order_data['shipping_firstname'] = $this->session->data['shipping_address']['firstname']; @@ -2540,7 +2536,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'] = ($this->session->data['shipping_address']['custom_field'] ?? []); + $order_data['shipping_custom_field'] = (isset($this->session->data['shipping_address']['custom_field']) ? $this->session->data['shipping_address']['custom_field'] : array()); if (isset($this->session->data['shipping_method']['title'])) { $order_data['shipping_method'] = $this->session->data['shipping_method']['title']; @@ -2566,18 +2562,18 @@ public function completeOrder() { $order_data['shipping_country'] = ''; $order_data['shipping_country_id'] = 0; $order_data['shipping_address_format'] = ''; - $order_data['shipping_custom_field'] = []; + $order_data['shipping_custom_field'] = array(); $order_data['shipping_method'] = ''; $order_data['shipping_code'] = ''; } - $order_data['products'] = []; + $order_data['products'] = array(); foreach ($this->cart->getProducts() as $product) { - $option_data = []; + $option_data = array(); foreach ($product['option'] as $option) { - $option_data[] = [ + $option_data[] = array( 'product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'option_id' => $option['option_id'], @@ -2585,10 +2581,10 @@ public function completeOrder() { 'name' => $option['name'], 'value' => $option['value'], 'type' => $option['type'] - ]; + ); } - $order_data['products'][] = [ + $order_data['products'][] = array( 'product_id' => $product['product_id'], 'name' => $product['name'], 'model' => $product['model'], @@ -2600,15 +2596,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'] = []; + $order_data['vouchers'] = array(); if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $voucher) { - $order_data['vouchers'][] = [ + $order_data['vouchers'][] = array( 'description' => $voucher['description'], 'code' => token(10), 'to_name' => $voucher['to_name'], @@ -2618,11 +2614,11 @@ public function completeOrder() { 'voucher_theme_id' => $voucher['voucher_theme_id'], 'message' => $voucher['message'], 'amount' => $voucher['amount'] - ]; + ); } } - $order_data['comment'] = ($this->session->data['comment'] ?? ''); + $order_data['comment'] = (isset($this->session->data['comment']) ? $this->session->data['comment'] : ''); $order_data['total'] = $total_data['total']; if (isset($this->request->cookie['tracking'])) { @@ -2631,13 +2627,13 @@ public function completeOrder() { $sub_total = $this->cart->getSubTotal(); // Affiliate - $this->load->model('account/customer'); + $this->load->model('affiliate/affiliate'); - $affiliate_info = $this->model_account_customer->getAffiliateByTracking($this->request->cookie['tracking']); + $affiliate_info = $this->model_affiliate_affiliate->getAffiliateByCode($this->request->cookie['tracking']); if ($affiliate_info) { - $order_data['affiliate_id'] = $affiliate_info['customer_id']; - $order_data['commission'] = ($sub_total / 100) * $affiliate_info['commission']; + $order_data['affiliate_id'] = $affiliate_info['affiliate_id']; + $order_data['commission'] = ($subtotal / 100) * $affiliate_info['commission']; } else { $order_data['affiliate_id'] = 0; $order_data['commission'] = 0; @@ -2685,20 +2681,20 @@ public function completeOrder() { } else { $order_data['accept_language'] = ''; } - + $this->load->model('checkout/order'); $this->session->data['order_id'] = $this->model_checkout_order->addOrder($order_data); - + $order_data['order_id'] = $this->session->data['order_id']; - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $environment = $this->config->get('paypal_environment'); @@ -2706,145 +2702,145 @@ public function completeOrder() { $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; $vault_status = $setting['general']['vault_status']; $transaction_method = $setting['general']['transaction_method']; - + $currency_code = $this->session->data['currency']; $currency_value = $this->currency->getValue($this->session->data['currency']); - + if (empty($setting['currency'][$currency_code]['status'])) { $currency_code = $setting['general']['currency_code']; $currency_value = $setting['general']['currency_value']; } - + $decimal_place = $setting['currency'][$currency_code]['decimal_place']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $paypal_order_id = $this->session->data['paypal_order_id']; - + $paypal_order_info = $paypal->getOrder($paypal_order_id); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } - - $shipping_info_name = []; - $shipping_info_address = []; - + + $shipping_info_name = array(); + $shipping_info_address = array(); + if ($paypal_order_info && !$this->error) { - $shipping_info_name = ($paypal_order_info['purchase_units'][0]['shipping']['name'] ?? []); - $shipping_info_address = ($paypal_order_info['purchase_units'][0]['shipping']['address'] ?? []); + $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()); } - - $paypal_order_info = []; - - $paypal_order_info[] = [ - 'op' => 'add', - 'path' => '/purchase_units/@reference_id==\'default\'/description', + + $paypal_order_info = array(); + + $paypal_order_info[] = array( + 'op' => 'add', + 'path' => '/purchase_units/@reference_id==\'default\'/description', 'value' => 'Your order ' . $this->session->data['order_id'] - ]; - - $paypal_order_info[] = [ - 'op' => 'add', - 'path' => '/purchase_units/@reference_id==\'default\'/invoice_id', + ); + + $paypal_order_info[] = array( + 'op' => 'add', + 'path' => '/purchase_units/@reference_id==\'default\'/invoice_id', 'value' => $this->session->data['order_id'] . '_' . date('Ymd_His') - ]; - - $shipping_info = []; + ); + + $shipping_info = array(); if ($this->cart->hasShipping()) { - $shipping_info['name']['full_name'] = ($this->session->data['shipping_address']['firstname'] ?? ''); - $shipping_info['name']['full_name'] .= (isset($this->session->data['shipping_address']['lastname']) ? (' ' . $this->session->data['shipping_address']['lastname']) : ''); - $shipping_info['address']['address_line_1'] = ($this->session->data['shipping_address']['address_1'] ?? ''); - $shipping_info['address']['address_line_2'] = ($this->session->data['shipping_address']['address_2'] ?? ''); - $shipping_info['address']['admin_area_1'] = ($this->session->data['shipping_address']['zone'] ?? ''); - $shipping_info['address']['admin_area_2'] = ($this->session->data['shipping_address']['city'] ?? ''); - $shipping_info['address']['postal_code'] = ($this->session->data['shipping_address']['postcode'] ?? ''); - + $shipping_info['name']['full_name'] = (isset($this->session->data['shipping_address']['firstname']) ? $this->session->data['shipping_address']['firstname'] : ''); + $shipping_info['name']['full_name'] .= (isset($this->session->data['shipping_address']['lastname']) ? (' ' . $this->session->data['shipping_address']['lastname']) : ''); + $shipping_info['address']['address_line_1'] = (isset($this->session->data['shipping_address']['address_1']) ? $this->session->data['shipping_address']['address_1'] : ''); + $shipping_info['address']['address_line_2'] = (isset($this->session->data['shipping_address']['address_2']) ? $this->session->data['shipping_address']['address_2'] : ''); + $shipping_info['address']['admin_area_1'] = (isset($this->session->data['shipping_address']['zone']) ? $this->session->data['shipping_address']['zone'] : ''); + $shipping_info['address']['admin_area_2'] = (isset($this->session->data['shipping_address']['city']) ? $this->session->data['shipping_address']['city'] : ''); + $shipping_info['address']['postal_code'] = (isset($this->session->data['shipping_address']['postcode']) ? $this->session->data['shipping_address']['postcode'] : ''); + if (isset($this->session->data['shipping_address']['country_id'])) { $this->load->model('localisation/country'); - + $country_info = $this->model_localisation_country->getCountry($this->session->data['shipping_address']['country_id']); - + if ($country_info) { $shipping_info['address']['country_code'] = $country_info['iso_code_2']; } } - + if ($shipping_info_name) { - $paypal_order_info[] = [ - 'op' => 'replace', - 'path' => '/purchase_units/@reference_id==\'default\'/shipping/name', + $paypal_order_info[] = array( + 'op' => 'replace', + 'path' => '/purchase_units/@reference_id==\'default\'/shipping/name', 'value' => $shipping_info['name'] - ]; + ); } else { - $paypal_order_info[] = [ - 'op' => 'add', - 'path' => '/purchase_units/@reference_id==\'default\'/shipping/name', + $paypal_order_info[] = array( + 'op' => 'add', + 'path' => '/purchase_units/@reference_id==\'default\'/shipping/name', 'value' => $shipping_info['name'] - ]; + ); } - + if ($shipping_info_address) { - $paypal_order_info[] = [ - 'op' => 'replace', - 'path' => '/purchase_units/@reference_id==\'default\'/shipping/address', + $paypal_order_info[] = array( + 'op' => 'replace', + 'path' => '/purchase_units/@reference_id==\'default\'/shipping/address', 'value' => $shipping_info['address'] - ]; + ); } else { - $paypal_order_info[] = [ - 'op' => 'add', - 'path' => '/purchase_units/@reference_id==\'default\'/shipping/address', + $paypal_order_info[] = array( + 'op' => 'add', + 'path' => '/purchase_units/@reference_id==\'default\'/shipping/address', 'value' => $shipping_info['address'] - ]; + ); } } - + $item_total = 0; $tax_total = 0; - + foreach ($this->cart->getProducts() as $product) { $product_price = number_format($product['price'] * $currency_value, $decimal_place, '.', ''); - + $item_total += $product_price * $product['quantity']; - + if ($product['tax_class_id']) { $tax_rates = $this->tax->getRates($product['price'], $product['tax_class_id']); @@ -2853,144 +2849,144 @@ public function completeOrder() { } } } - + if (!empty($this->session->data['vouchers'])) { foreach ($this->session->data['vouchers'] as $voucher) { $item_total += $voucher['amount']; } } - + $item_total = number_format($item_total, $decimal_place, '.', ''); $tax_total = number_format($tax_total * $currency_value, $decimal_place, '.', ''); - + $discount_total = 0; $handling_total = 0; $shipping_total = 0; - + if (isset($this->session->data['shipping_method'])) { $shipping_total = $this->tax->calculate($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id'], true); $shipping_total = number_format($shipping_total * $currency_value, $decimal_place, '.', ''); } - + $order_total = number_format($order_data['total'] * $currency_value, $decimal_place, '.', ''); - + $rebate = number_format($item_total + $tax_total + $shipping_total - $order_total, $decimal_place, '.', ''); - + if ($rebate > 0) { $discount_total = $rebate; } elseif ($rebate < 0) { $handling_total = -$rebate; } - - $amount_info = []; - + + $amount_info = array(); + $amount_info['currency_code'] = $currency_code; $amount_info['value'] = $order_total; - - $amount_info['breakdown']['item_total'] = [ + + $amount_info['breakdown']['item_total'] = array( 'currency_code' => $currency_code, - 'value' => $item_total - ]; - - $amount_info['breakdown']['tax_total'] = [ + 'value' => $item_total + ); + + $amount_info['breakdown']['tax_total'] = array( 'currency_code' => $currency_code, - 'value' => $tax_total - ]; - - $amount_info['breakdown']['shipping'] = [ + 'value' => $tax_total + ); + + $amount_info['breakdown']['shipping'] = array( 'currency_code' => $currency_code, - 'value' => $shipping_total - ]; - - $amount_info['breakdown']['handling'] = [ + 'value' => $shipping_total + ); + + $amount_info['breakdown']['handling'] = array( 'currency_code' => $currency_code, - 'value' => $handling_total - ]; - - $amount_info['breakdown']['discount'] = [ + 'value' => $handling_total + ); + + $amount_info['breakdown']['discount'] = array( 'currency_code' => $currency_code, - 'value' => $discount_total - ]; - - $paypal_order_info[] = [ - 'op' => 'replace', - 'path' => '/purchase_units/@reference_id==\'default\'/amount', + 'value' => $discount_total + ); + + $paypal_order_info[] = array( + '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 = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } - - if ($paypal_order_id && !$this->error) { + + if ($paypal_order_id && !$this->error) { if ($transaction_method == 'authorize') { $result = $paypal->setOrderAuthorize($paypal_order_id); } else { $result = $paypal->setOrderCapture($paypal_order_id); } - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['details'][0]['issue']) && ($error['details'][0]['issue'] == 'INSTRUMENT_DECLINED')) { $data['restart'] = true; } - + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } - - if (!$this->error) { + + if (!$this->error) { if ($transaction_method == 'authorize') { $this->model_extension_payment_paypal->log($result, 'Authorize Order'); - + if (isset($result['purchase_units'][0]['payments']['authorizations'][0]['status']) && isset($result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status'])) { $authorization_id = $result['purchase_units'][0]['payments']['authorizations'][0]['id']; $authorization_status = $result['purchase_units'][0]['payments']['authorizations'][0]['status']; - $seller_protection_status = $result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status']; + $seller_protection_status = $result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status']; $order_status_id = 0; $transaction_status = ''; $payment_method = ''; @@ -3000,19 +2996,18 @@ public function completeOrder() { $card_nice_type = ''; $card_last_digits = ''; $card_expiry = ''; - $paypal_order_data = []; - + if (!$this->cart->hasShipping()) { $seller_protection_status = 'NOT_ELIGIBLE'; } - + foreach ($result['payment_source'] as $payment_source_key => $payment_source) { $payment_method = $payment_source_key; - $vault_id = ($payment_source['attributes']['vault']['id'] ?? ''); - $vault_customer_id = ($payment_source['attributes']['vault']['customer']['id'] ?? ''); - $card_last_digits = ($payment_source['last_digits'] ?? ''); - $card_expiry = ($payment_source['expiry'] ?? ''); - + $vault_id = (isset($payment_source['attributes']['vault']['id']) ? $payment_source['attributes']['vault']['id'] : ''); + $vault_customer_id = (isset($payment_source['attributes']['vault']['customer']['id']) ? $payment_source['attributes']['vault']['customer']['id'] : ''); + $card_last_digits = (isset($payment_source['last_digits']) ? $payment_source['last_digits'] : ''); + $card_expiry = (isset($payment_source['expiry']) ? $payment_source['expiry'] : ''); + break; } @@ -3024,103 +3019,102 @@ public function completeOrder() { if ($authorization_status == 'CAPTURED') { $this->error['warning'] = sprintf($this->language->get('error_authorization_captured'), $this->url->link('information/contact', '', true)); } - + if ($authorization_status == 'DENIED') { - $order_status_id = $setting['order_status']['denied']['id']; $transaction_status = 'denied'; - + $this->error['warning'] = $this->language->get('error_authorization_denied'); } - + if ($authorization_status == 'EXPIRED') { $this->error['warning'] = sprintf($this->language->get('error_authorization_expired'), $this->url->link('information/contact', '', true)); } - + if ($authorization_status == 'PENDING') { $order_status_id = $setting['order_status']['pending']['id']; $transaction_status = 'pending'; } - - if (($authorization_status == 'CREATED') || ($authorization_status == 'DENIED') || ($authorization_status == 'PENDING')) { - $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); - - $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); - } - + if (($authorization_status == 'CREATED') || ($authorization_status == 'DENIED') || ($authorization_status == 'PENDING')) { if ($payment_method == 'paypal') { - $paypal_customer_token = []; - + $paypal_customer_token = array(); + if ($setting['general']['vault_status'] && $this->customer->isLogged()) { $paypal_customer_token = $this->model_extension_payment_paypal->getPayPalCustomerMainToken($this->customer->getId(), $payment_method); } - + if (!empty($paypal_customer_token['vault_id'])) { $vault_id = $paypal_customer_token['vault_id']; $vault_customer_id = $paypal_customer_token['vault_customer_id']; } } - + $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); - - $paypal_order_data = [ - 'order_id' => $this->session->data['order_id'], - 'paypal_order_id' => $paypal_order_id, - 'transaction_id' => $authorization_id, + + $paypal_order_data = array( + 'order_id' => $this->session->data['order_id'], + 'paypal_order_id' => $paypal_order_id, + 'transaction_id' => $authorization_id, 'transaction_status' => $transaction_status, - 'payment_method' => $payment_method, - 'vault_id' => $vault_id, - 'vault_customer_id' => $vault_customer_id, - 'card_type' => $card_type, - 'card_nice_type' => $card_nice_type, - 'card_last_digits' => $card_last_digits, - 'card_expiry' => $card_expiry, - 'total' => $order_data['total'], - 'currency_code' => $order_data['currency_code'], - 'environment' => $environment - ]; + 'payment_method' => $payment_method, + 'vault_id' => $vault_id, + 'vault_customer_id' => $vault_customer_id, + 'card_type' => $card_type, + 'card_nice_type' => $card_nice_type, + 'card_last_digits' => $card_last_digits, + 'card_expiry' => $card_expiry, + 'total' => $order_data['total'], + 'currency_code' => $order_data['currency_code'], + 'environment' => $environment + ); $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); - + if ($vault_id && $this->customer->isLogged()) { $customer_id = $this->customer->getId(); - + $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 = [ - 'customer_id' => $customer_id, - 'payment_method' => $payment_method, - 'vault_id' => $vault_id, + $paypal_customer_token_data = array( + 'customer_id' => $customer_id, + 'payment_method' => $payment_method, + 'vault_id' => $vault_id, 'vault_customer_id' => $vault_customer_id, - 'card_type' => $card_type, - 'card_nice_type' => $card_nice_type, - 'card_last_digits' => $card_last_digits, - 'card_expiry' => $card_expiry, - ]; - + 'card_type' => $card_type, + '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); } - + $this->model_extension_payment_paypal->setPayPalCustomerMainToken($customer_id, $payment_method, $vault_id); } } - + + if ($order_status_id) { + $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); + + $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); + } + if (($authorization_status == 'CREATED') || ($authorization_status == 'PENDING')) { $recurring_products = $this->cart->getRecurringProducts(); - + foreach ($recurring_products as $recurring_product) { $this->model_extension_payment_paypal->recurringPayment($recurring_product, $order_data, $paypal_order_data); - } + } } - if (($authorization_status == 'CREATED') || ($authorization_status == 'PARTIALLY_CAPTURED') || ($authorization_status == 'PARTIALLY_CREATED') || ($authorization_status == 'VOIDED') || ($authorization_status == 'PENDING')) { + if (($authorization_status == 'CREATED') || ($authorization_status == 'PARTIALLY_CAPTURED') || ($authorization_status == 'PARTIALLY_CREATED') || ($authorization_status == 'PENDING')) { $this->response->redirect($this->url->link('checkout/success', '', true)); } } } else { $this->model_extension_payment_paypal->log($result, 'Capture Order'); - + if (isset($result['purchase_units'][0]['payments']['captures'][0]['status']) && isset($result['purchase_units'][0]['payments']['captures'][0]['seller_protection']['status'])) { $capture_id = $result['purchase_units'][0]['payments']['captures'][0]['id']; $capture_status = $result['purchase_units'][0]['payments']['captures'][0]['status']; @@ -3134,145 +3128,143 @@ public function completeOrder() { $card_nice_type = ''; $card_last_digits = ''; $card_expiry = ''; - $paypal_order_data = []; - + if (!$this->cart->hasShipping()) { $seller_protection_status = 'NOT_ELIGIBLE'; } - + foreach ($result['payment_source'] as $payment_source_key => $payment_source) { $payment_method = $payment_source_key; - $vault_id = ($payment_source['attributes']['vault']['id'] ?? ''); - $vault_customer_id = ($payment_source['attributes']['vault']['customer']['id'] ?? ''); - $card_last_digits = ($payment_source['last_digits'] ?? ''); - $card_expiry = ($payment_source['expiry'] ?? ''); - + $vault_id = (isset($payment_source['attributes']['vault']['id']) ? $payment_source['attributes']['vault']['id'] : ''); + $vault_customer_id = (isset($payment_source['attributes']['vault']['customer']['id']) ? $payment_source['attributes']['vault']['customer']['id'] : ''); + $card_last_digits = (isset($payment_source['last_digits']) ? $payment_source['last_digits'] : ''); + $card_expiry = (isset($payment_source['expiry']) ? $payment_source['expiry'] : ''); + break; } - + if ($capture_status == 'COMPLETED') { $order_status_id = $setting['order_status']['completed']['id']; $transaction_status = 'completed'; } - + if ($capture_status == 'DECLINED') { - $order_status_id = $setting['order_status']['denied']['id']; $transaction_status = 'denied'; - + $this->error['warning'] = $this->language->get('error_capture_declined'); } - + if ($capture_status == 'FAILED') { $this->error['warning'] = sprintf($this->language->get('error_capture_failed'), $this->url->link('information/contact', '', true)); } - + if ($capture_status == 'PENDING') { $order_status_id = $setting['order_status']['pending']['id']; $transaction_status = 'pending'; } - - if (($capture_status == 'COMPLETED') || ($capture_status == 'DECLINED') || ($capture_status == 'PENDING')) { - $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); - - $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); - } - + if (($capture_status == 'COMPLETED') || ($capture_status == 'DECLINED') || ($capture_status == 'PENDING')) { if ($payment_method == 'paypal') { - $paypal_customer_token = []; - + $paypal_customer_token = array(); + if ($setting['general']['vault_status'] && $this->customer->isLogged()) { $paypal_customer_token = $this->model_extension_payment_paypal->getPayPalCustomerMainToken($this->customer->getId(), $payment_method); } - + if (!empty($paypal_customer_token['vault_id'])) { $vault_id = $paypal_customer_token['vault_id']; $vault_customer_id = $paypal_customer_token['vault_customer_id']; } } - + $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); - - $paypal_order_data = [ - 'order_id' => $this->session->data['order_id'], - 'paypal_order_id' => $paypal_order_id, - 'transaction_id' => $capture_id, + + $paypal_order_data = array( + 'order_id' => $this->session->data['order_id'], + 'paypal_order_id' => $paypal_order_id, + 'transaction_id' => $capture_id, 'transaction_status' => $transaction_status, - 'payment_method' => $payment_method, - 'vault_id' => $vault_id, - 'vault_customer_id' => $vault_customer_id, - 'card_type' => $card_type, - 'card_nice_type' => $card_nice_type, - 'card_last_digits' => $card_last_digits, - 'card_expiry' => $card_expiry, - 'total' => $order_data['total'], - 'currency_code' => $order_data['currency_code'], - 'environment' => $environment - ]; + 'payment_method' => $payment_method, + 'vault_id' => $vault_id, + 'vault_customer_id' => $vault_customer_id, + 'card_type' => $card_type, + 'card_nice_type' => $card_nice_type, + 'card_last_digits' => $card_last_digits, + 'card_expiry' => $card_expiry, + 'total' => $order_data['total'], + 'currency_code' => $order_data['currency_code'], + 'environment' => $environment + ); $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); - + if ($vault_id && $this->customer->isLogged()) { $customer_id = $this->customer->getId(); - + $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 = [ - 'customer_id' => $customer_id, - 'payment_method' => $payment_method, - 'vault_id' => $vault_id, + $paypal_customer_token_data = array( + 'customer_id' => $customer_id, + 'payment_method' => $payment_method, + 'vault_id' => $vault_id, 'vault_customer_id' => $vault_customer_id, - 'card_type' => $card_type, - 'card_nice_type' => $card_nice_type, - 'card_last_digits' => $card_last_digits, - 'card_expiry' => $card_expiry, - ]; - + 'card_type' => $card_type, + '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); } - + $this->model_extension_payment_paypal->setPayPalCustomerMainToken($customer_id, $payment_method, $vault_id); } } - + + if ($order_status_id) { + $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); + + $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); + } + if (($capture_status == 'COMPLETED') || ($capture_status == 'PENDING')) { $recurring_products = $this->cart->getRecurringProducts(); - + foreach ($recurring_products as $recurring_product) { $this->model_extension_payment_paypal->recurringPayment($recurring_product, $order_data, $paypal_order_data); - } + } } - - if (($capture_status == 'COMPLETED') || ($capture_status == 'PARTIALLY_REFUNDED') || ($capture_status == 'REFUNDED') || ($capture_status == 'PENDING')) { + + if (($capture_status == 'COMPLETED') || ($capture_status == 'PENDING')) { $this->response->redirect($this->url->link('checkout/success', '', true)); } } } } } - + unset($this->session->data['paypal_order_id']); - - if ($this->error) { + + if ($this->error) { $this->session->data['error'] = $this->error['warning']; - + $this->response->redirect($this->url->link('checkout/checkout', '', true)); } - } - + } + $this->response->redirect($this->url->link('checkout/cart', '', true)); } - + public function paymentAddress() { $this->load->language('extension/payment/paypal'); - + $data['text_checkout_payment_address'] = $this->language->get('text_checkout_payment_address'); $data['text_your_details'] = $this->language->get('text_your_details'); $data['text_your_address'] = $this->language->get('text_your_address'); $data['text_select'] = $this->language->get('text_select'); $data['text_none'] = $this->language->get('text_none'); - + $data['entry_email'] = $this->language->get('entry_email'); $data['entry_firstname'] = $this->language->get('entry_firstname'); $data['entry_lastname'] = $this->language->get('entry_lastname'); @@ -3284,30 +3276,30 @@ public function paymentAddress() { $data['entry_city'] = $this->language->get('entry_city'); $data['entry_country'] = $this->language->get('entry_country'); $data['entry_zone'] = $this->language->get('entry_zone'); - + $data['button_confirm'] = $this->language->get('button_confirm'); - - $data['guest'] = $this->session->data['guest'] ?? []; - $data['payment_address'] = $this->session->data['payment_address'] ?? []; - + + $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(); + $this->load->model('localisation/country'); $data['countries'] = $this->model_localisation_country->getCountries(); - + $this->load->model('account/custom_field'); $data['custom_fields'] = $this->model_account_custom_field->getCustomFields(); - + $this->response->setOutput($this->load->view('extension/payment/paypal/payment_address', $data)); } - + public function shippingAddress() { $this->load->language('extension/payment/paypal'); - + $data['text_checkout_shipping_address'] = $this->language->get('text_checkout_shipping_address'); $data['text_select'] = $this->language->get('text_select'); $data['text_none'] = $this->language->get('text_none'); - + $data['entry_email'] = $this->language->get('entry_email'); $data['entry_firstname'] = $this->language->get('entry_firstname'); $data['entry_lastname'] = $this->language->get('entry_lastname'); @@ -3319,34 +3311,34 @@ public function shippingAddress() { $data['entry_city'] = $this->language->get('entry_city'); $data['entry_country'] = $this->language->get('entry_country'); $data['entry_zone'] = $this->language->get('entry_zone'); - + $data['button_confirm'] = $this->language->get('button_confirm'); - - $data['shipping_address'] = $this->session->data['shipping_address'] ?? []; - + + $data['shipping_address'] = isset($this->session->data['shipping_address']) ? $this->session->data['shipping_address'] : array(); + $this->load->model('localisation/country'); $data['countries'] = $this->model_localisation_country->getCountries(); - + $this->load->model('account/custom_field'); $data['custom_fields'] = $this->model_account_custom_field->getCustomFields(); - + $this->response->setOutput($this->load->view('extension/payment/paypal/shipping_address', $data)); } - + public function confirmShipping() { $this->validateShipping($this->request->post['shipping_method']); $this->response->redirect($this->url->link('extension/payment/paypal/confirmOrder', '', true)); } - + public function confirmPaymentAddress() { $this->load->language('extension/payment/paypal'); - + $data['url'] = ''; - - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validatePaymentAddress()) { + + if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validatePaymentAddress()) { $this->session->data['guest']['firstname'] = $this->request->post['firstname']; $this->session->data['guest']['lastname'] = $this->request->post['lastname']; $this->session->data['guest']['email'] = $this->request->post['email']; @@ -3355,7 +3347,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'] = []; + $this->session->data['guest']['custom_field'] = array(); } $this->session->data['payment_address']['firstname'] = $this->request->post['firstname']; @@ -3387,7 +3379,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'] = []; + $this->session->data['payment_address']['custom_field'] = array(); } $this->load->model('localisation/zone'); @@ -3401,20 +3393,20 @@ public function confirmPaymentAddress() { $this->session->data['payment_address']['zone'] = ''; $this->session->data['payment_address']['zone_code'] = ''; } - + $data['url'] = $this->url->link('extension/payment/paypal/confirmOrder', '', true); } $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function confirmShippingAddress() { $this->load->language('extension/payment/paypal'); - - if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateShippingAddress()) { + + if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateShippingAddress()) { $this->session->data['shipping_address']['firstname'] = $this->request->post['firstname']; $this->session->data['shipping_address']['lastname'] = $this->request->post['lastname']; $this->session->data['shipping_address']['company'] = $this->request->post['company']; @@ -3456,170 +3448,171 @@ 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'] = []; + $this->session->data['shipping_address']['custom_field'] = array(); } - + $data['url'] = $this->url->link('extension/payment/paypal/confirmOrder', '', true); } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function deleteCustomerToken() { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); if ($this->customer->isLogged() && isset($this->request->post['index'])) { $card_token_index = $this->request->post['index']; - + $card_customer_tokens = $this->model_extension_payment_paypal->getPayPalCustomerTokens($this->customer->getId(), 'card'); - + if (!empty($card_customer_tokens[$card_token_index]['vault_id'])) { $vault_id = $card_customer_tokens[$card_token_index]['vault_id']; - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $merchant_id = $this->config->get('paypal_merchant_id'); $environment = $this->config->get('paypal_environment'); $partner_id = $setting['partner'][$environment]['partner_id']; $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $result = $paypal->setAccessToken($token_info); - + $result = $paypal->deletePaymentToken($vault_id); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } - + + if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } - + if ($result && !$this->error) { $this->model_extension_payment_paypal->deletePayPalCustomerToken($this->customer->getId(), 'card', $vault_id); - + $data['success'] = true; } } } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function addOrderHistory() { if (!empty($this->request->get['order_history_token']) && !empty($this->request->post['order_id']) && !empty($this->request->post['order_status_id'])) { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + $order_id = $this->request->post['order_id']; $order_status_id = $this->request->post['order_status_id']; - + if (!empty($this->request->post['comment'])) { $comment = $this->request->post['comment']; } else { $comment = ''; } - + if (!empty($this->request->post['notify'])) { $notify = $this->request->post['notify']; } else { $notify = false; } - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - - if (hash_equals($setting['general']['order_history_token'], $this->request->get['order_history_token'])) { + + if (hash_equals($setting['general']['order_history_token'], $this->request->get['order_history_token'])) { $this->load->model('checkout/order'); $this->model_checkout_order->addOrderHistory($order_id, $order_status_id, $comment, $notify); - + $data['success'] = $this->language->get('success_order'); - } + } } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function callback() { $this->load->language('extension/payment/paypal'); - + $this->load->model('extension/payment/paypal'); - + if (!empty($this->request->get['callback_token'])) { $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + if (hash_equals($setting['general']['callback_token'], $this->request->get['callback_token']) && !empty($this->session->data['order_id']) && !empty($this->session->data['paypal_order_id']) && isset($this->session->data['paypal_card_token_index'])) { $order_id = $this->session->data['order_id']; $paypal_order_id = $this->session->data['paypal_order_id']; $card_token_index = $this->session->data['paypal_card_token_index']; - + $card_customer_tokens = $this->model_extension_payment_paypal->getPayPalCustomerTokens($this->customer->getId(), 'card'); if (!empty($card_customer_tokens[$card_token_index]['vault_id'])) { @@ -3629,7 +3622,7 @@ public function callback() { $card_nice_type = $card_customer_tokens[$card_token_index]['card_nice_type']; $card_last_digits = $card_customer_tokens[$card_token_index]['card_last_digits']; $card_expiry = $card_customer_tokens[$card_token_index]['card_expiry']; - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $environment = $this->config->get('paypal_environment'); @@ -3637,153 +3630,152 @@ public function callback() { $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; $vault_status = $setting['general']['vault_status']; $transaction_method = $setting['general']['transaction_method']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $paypal_order_info = $paypal->getOrder($paypal_order_id); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + if (isset($paypal_order_info['payment_source']['card']) && !$this->error) { $this->model_extension_payment_paypal->log($paypal_order_info['payment_source']['card'], 'Card'); - - $liability_shift = ($paypal_order_info['payment_source']['card']['authentication_result']['liability_shift'] ?? ''); - $enrollment_status = ($paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['enrollment_status'] ?? ''); - $authentication_status = ($paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['authentication_status'] ?? ''); - + + $liability_shift = (isset($paypal_order_info['payment_source']['card']['authentication_result']['liability_shift']) ? $paypal_order_info['payment_source']['card']['authentication_result']['liability_shift'] : ''); + $enrollment_status = (isset($paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['enrollment_status']) ? $paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['enrollment_status'] : ''); + $authentication_status = (isset($paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['authentication_status']) ? $paypal_order_info['payment_source']['card']['authentication_result']['three_d_secure']['authentication_status'] : ''); + if ($enrollment_status == 'Y') { if (($authentication_status == 'N') && !$setting['card']['secure_scenario']['failed_authentication']) { $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['failed_authentication']['error']); } - + if (($authentication_status == 'R') && !$setting['card']['secure_scenario']['rejected_authentication']) { $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['rejected_authentication']['error']); } - + if (($authentication_status == 'A') && !$setting['card']['secure_scenario']['attempted_authentication']) { $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['attempted_authentication']['error']); } - + if (($authentication_status == 'U') && !$setting['card']['secure_scenario']['unable_authentication']) { $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['unable_authentication']['error']); } - + if (($authentication_status == 'C') && !$setting['card']['secure_scenario']['challenge_authentication']) { $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['challenge_authentication']['error']); } } - + if (($enrollment_status == 'N') && !$setting['card']['secure_scenario']['card_ineligible']) { $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['card_ineligible']['error']); } - + if (($enrollment_status == 'U') && !$setting['card']['secure_scenario']['system_unavailable']) { $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['system_unavailable']['error']); } - + if (($enrollment_status == 'B') && !$setting['card']['secure_scenario']['system_bypassed']) { $this->error['warning'] = $this->language->get($setting['card_secure_scenario']['system_bypassed']['error']); } } - + if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } - - if (!$this->error) { + + if (!$this->error) { if ($transaction_method == 'authorize') { $result = $paypal->setOrderAuthorize($paypal_order_id); } else { $result = $paypal->setOrderCapture($paypal_order_id); } - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['details'][0]['issue']) && ($error['details'][0]['issue'] == 'INSTRUMENT_DECLINED')) { $data['restart'] = true; } - + if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } - + if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); } - - if (!$this->error) { + + if (!$this->error) { $this->load->model('checkout/order'); - + $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); - + if ($transaction_method == 'authorize') { $this->model_extension_payment_paypal->log($result, 'Authorize Order'); - + if (isset($result['purchase_units'][0]['payments']['authorizations'][0]['status']) && isset($result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status'])) { $authorization_id = $result['purchase_units'][0]['payments']['authorizations'][0]['id']; $authorization_status = $result['purchase_units'][0]['payments']['authorizations'][0]['status']; - $seller_protection_status = $result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status']; + $seller_protection_status = $result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status']; $order_status_id = 0; $transaction_status = ''; $payment_method = 'card'; - $paypal_order_data = []; - + if (!$this->cart->hasShipping()) { $seller_protection_status = 'NOT_ELIGIBLE'; } - + if ($authorization_status == 'CREATED') { $order_status_id = $setting['order_status']['pending']['id']; $transaction_status = 'created'; @@ -3792,186 +3784,183 @@ public function callback() { if ($authorization_status == 'CAPTURED') { $this->error['warning'] = sprintf($this->language->get('error_authorization_captured'), $this->url->link('information/contact', '', true)); } - + if ($authorization_status == 'DENIED') { - $order_status_id = $setting['order_status']['denied']['id']; $transaction_status = 'denied'; - + $this->error['warning'] = $this->language->get('error_authorization_denied'); } - + if ($authorization_status == 'EXPIRED') { $this->error['warning'] = sprintf($this->language->get('error_authorization_expired'), $this->url->link('information/contact', '', true)); } - + if ($authorization_status == 'PENDING') { $order_status_id = $setting['order_status']['pending']['id']; $transaction_status = 'pending'; } - - if (($authorization_status == 'CREATED') || ($authorization_status == 'DENIED') || ($authorization_status == 'PENDING')) { - $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); - - $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); - } - + if (($authorization_status == 'CREATED') || ($authorization_status == 'DENIED') || ($authorization_status == 'PENDING')) { $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); - - $paypal_order_data = [ - 'order_id' => $this->session->data['order_id'], - 'paypal_order_id' => $paypal_order_id, - 'transaction_id' => $authorization_id, + + $paypal_order_data = array( + 'order_id' => $this->session->data['order_id'], + 'paypal_order_id' => $paypal_order_id, + 'transaction_id' => $authorization_id, 'transaction_status' => $transaction_status, - 'payment_method' => $payment_method, - 'vault_id' => $vault_id, - 'vault_customer_id' => $vault_customer_id, - 'card_type' => $card_type, - 'card_nice_type' => $card_nice_type, - 'card_last_digits' => $card_last_digits, - 'card_expiry' => $card_expiry, - 'total' => $order_info['total'], - 'currency_code' => $order_info['currency_code'], - 'environment' => $environment - ]; + 'payment_method' => $payment_method, + 'vault_id' => $vault_id, + 'vault_customer_id' => $vault_customer_id, + 'card_type' => $card_type, + 'card_nice_type' => $card_nice_type, + 'card_last_digits' => $card_last_digits, + 'card_expiry' => $card_expiry, + 'total' => $order_info['total'], + 'currency_code' => $order_info['currency_code'], + 'environment' => $environment + ); $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); - + if ($vault_id && $this->customer->isLogged()) { $customer_id = $this->customer->getId(); - + $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 = [ - 'customer_id' => $customer_id, - 'payment_method' => $payment_method, - 'vault_id' => $vault_id, + $paypal_customer_token_data = array( + 'customer_id' => $customer_id, + 'payment_method' => $payment_method, + 'vault_id' => $vault_id, 'vault_customer_id' => $vault_customer_id, - 'card_type' => $card_type, - 'card_nice_type' => $card_nice_type, - 'card_last_digits' => $card_last_digits, - 'card_expiry' => $card_expiry - ]; - + 'card_type' => $card_type, + '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); } - + $this->model_extension_payment_paypal->setPayPalCustomerMainToken($customer_id, $payment_method, $vault_id); } } - + + if ($order_status_id) { + $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); + + $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); + } + if (($authorization_status == 'CREATED') || ($authorization_status == 'PENDING')) { $recurring_products = $this->cart->getRecurringProducts(); - + foreach ($recurring_products as $recurring_product) { $this->model_extension_payment_paypal->recurringPayment($recurring_product, $order_info, $paypal_order_data); - } + } } - - if (($authorization_status == 'CREATED') || ($authorization_status == 'PARTIALLY_CAPTURED') || ($authorization_status == 'PARTIALLY_CREATED') || ($authorization_status == 'VOIDED') || ($authorization_status == 'PENDING')) { + + if (($authorization_status == 'CREATED') || ($authorization_status == 'PARTIALLY_CAPTURED') || ($authorization_status == 'PARTIALLY_CREATED') || ($authorization_status == 'PENDING')) { $this->response->redirect($this->url->link('checkout/success', '', true)); } } } else { $this->model_extension_payment_paypal->log($result, 'Capture Order'); - + if (isset($result['purchase_units'][0]['payments']['captures'][0]['status']) && isset($result['purchase_units'][0]['payments']['captures'][0]['seller_protection']['status'])) { $capture_id = $result['purchase_units'][0]['payments']['captures'][0]['id']; $capture_status = $result['purchase_units'][0]['payments']['captures'][0]['status']; $seller_protection_status = $result['purchase_units'][0]['payments']['captures'][0]['seller_protection']['status']; - + $order_status_id = 0; $transaction_status = ''; $payment_method = 'card'; - $paypal_order_data = []; - + if (!$this->cart->hasShipping()) { $seller_protection_status = 'NOT_ELIGIBLE'; } - + if ($capture_status == 'COMPLETED') { $order_status_id = $setting['order_status']['completed']['id']; $transaction_status = 'completed'; } - + if ($capture_status == 'DECLINED') { - $order_status_id = $setting['order_status']['denied']['id']; $transaction_status = 'denied'; - + $this->error['warning'] = $this->language->get('error_capture_declined'); } - + if ($capture_status == 'FAILED') { $this->error['warning'] = sprintf($this->language->get('error_capture_failed'), $this->url->link('information/contact', '', true)); } - + if ($capture_status == 'PENDING') { $order_status_id = $setting['order_status']['pending']['id']; $transaction_status = 'pending'; } - - if (($capture_status == 'COMPLETED') || ($capture_status == 'DECLINED') || ($capture_status == 'PENDING')) { - $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); - - $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); - } - + if (($capture_status == 'COMPLETED') || ($capture_status == 'DECLINED') || ($capture_status == 'PENDING')) { $this->model_extension_payment_paypal->deletePayPalOrder($this->session->data['order_id']); - - $paypal_order_data = [ - 'order_id' => $this->session->data['order_id'], - 'paypal_order_id' => $paypal_order_id, - 'transaction_id' => $capture_id, + + $paypal_order_data = array( + 'order_id' => $this->session->data['order_id'], + 'paypal_order_id' => $paypal_order_id, + 'transaction_id' => $capture_id, 'transaction_status' => $transaction_status, - 'payment_method' => $payment_method, - 'vault_id' => $vault_id, - 'vault_customer_id' => $vault_customer_id, - 'card_type' => $card_type, - 'card_nice_type' => $card_nice_type, - 'card_last_digits' => $card_last_digits, - 'card_expiry' => $card_expiry, - 'total' => $order_info['total'], - 'currency_code' => $order_info['currency_code'], - 'environment' => $environment - ]; + 'payment_method' => $payment_method, + 'vault_id' => $vault_id, + 'vault_customer_id' => $vault_customer_id, + 'card_type' => $card_type, + 'card_nice_type' => $card_nice_type, + 'card_last_digits' => $card_last_digits, + 'card_expiry' => $card_expiry, + 'total' => $order_info['total'], + 'currency_code' => $order_info['currency_code'], + 'environment' => $environment + ); $this->model_extension_payment_paypal->addPayPalOrder($paypal_order_data); - + if ($vault_id && $this->customer->isLogged()) { $customer_id = $this->customer->getId(); - + $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 = [ - 'customer_id' => $customer_id, - 'payment_method' => $payment_method, - 'vault_id' => $vault_id, + $paypal_customer_token_data = array( + 'customer_id' => $customer_id, + 'payment_method' => $payment_method, + 'vault_id' => $vault_id, 'vault_customer_id' => $vault_customer_id, - 'card_type' => $card_type, - 'card_nice_type' => $card_nice_type, - 'card_last_digits' => $card_last_digits, - 'card_expiry' => $card_expiry - ]; - + 'card_type' => $card_type, + '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); } - + $this->model_extension_payment_paypal->setPayPalCustomerMainToken($customer_id, $payment_method, $vault_id); } } - + + if ($order_status_id) { + $message = sprintf($this->language->get('text_order_message'), $seller_protection_status); + + $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $order_status_id, $message); + } + if (($capture_status == 'COMPLETED') || ($capture_status == 'PENDING')) { $recurring_products = $this->cart->getRecurringProducts(); - + foreach ($recurring_products as $recurring_product) { $this->model_extension_payment_paypal->recurringPayment($recurring_product, $order_info, $paypal_order_data); - } + } } - - if (($capture_status == 'COMPLETED') || ($capture_status == 'PARTIALLY_REFUNDED') || ($capture_status == 'REFUNDED') || ($capture_status == 'PENDING')) { + + if (($capture_status == 'COMPLETED') || ($capture_status == 'PENDING')) { $this->response->redirect($this->url->link('checkout/success', '', true)); } } @@ -3979,72 +3968,72 @@ public function callback() { } } } - + $this->document->setTitle($this->language->get('text_failure_page_title')); + + $data['breadcrumbs'] = array(); - $data['breadcrumbs'] = []; - - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', '', true) - ]; - - $data['breadcrumbs'][] = [ + ); + + $data['breadcrumbs'][] = array( 'text' => $this->language->get('text_cart'), 'href' => $this->url->link('checkout/cart', '', true) - ]; + ); - $data['breadcrumbs'][] = [ + $data['breadcrumbs'][] = array( '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)); - + if (!empty($this->error['warning'])) { $data['text_message'] = $this->error['warning']; } - + $data['button_continue'] = $this->language->get('button_continue'); - + $data['continue'] = $this->url->link('common/home'); - + $data['column_left'] = $this->load->controller('common/column_left'); $data['column_right'] = $this->load->controller('common/column_right'); $data['content_top'] = $this->load->controller('common/content_top'); $data['content_bottom'] = $this->load->controller('common/content_bottom'); $data['footer'] = $this->load->controller('common/footer'); $data['header'] = $this->load->controller('common/header'); - + $this->response->setOutput($this->load->view('extension/payment/paypal/failure', $data)); - + return true; } } - + return false; } - + public function webhook() { if (!empty($this->request->get['webhook_token'])) { $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $webhook_info = json_decode(html_entity_decode(file_get_contents('php://input')), true); - - if (hash_equals($setting['general']['webhook_token'], $this->request->get['webhook_token']) && !empty($webhook_info['id']) && !empty($webhook_info['event_type'])) { + + if (hash_equals($setting['general']['webhook_token'], $this->request->get['webhook_token']) && !empty($webhook_info['id']) && !empty($webhook_info['event_type'])) { $this->load->model('extension/payment/paypal'); $this->load->model('checkout/order'); - + $this->model_extension_payment_paypal->log($webhook_info, 'Webhook'); - + $webhook_event_id = $webhook_info['id']; - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $environment = $this->config->get('paypal_environment'); @@ -4052,39 +4041,39 @@ public function webhook() { $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; $vault_status = $setting['general']['vault_status']; $transaction_method = $setting['general']['transaction_method']; - - require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $webhook_repeat = 1; - + while ($webhook_repeat) { $webhook_event = $paypal->getWebhookEvent($webhook_event_id); - $errors = []; - + $errors = array(); + $webhook_repeat = 0; - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $webhook_repeat = 1; @@ -4092,30 +4081,33 @@ public function webhook() { } } } - + if (isset($webhook_event['resource']['invoice_id']) && !$errors) { $invoice_id = explode('_', $webhook_event['resource']['invoice_id']); $order_id = reset($invoice_id); - + $order_info = $this->model_checkout_order->getOrder($order_id); - + $paypal_order_info = $this->model_extension_payment_paypal->getPayPalOrder($order_id); if ($order_info && $paypal_order_info) { $order_status_id = 0; $transaction_id = $paypal_order_info['transaction_id']; $transaction_status = $paypal_order_info['transaction_status']; - + if ($webhook_event['event_type'] == 'PAYMENT.AUTHORIZATION.CREATED') { $order_status_id = $setting['order_status']['pending']['id']; $transaction_status = 'created'; } - + if ($webhook_event['event_type'] == 'PAYMENT.AUTHORIZATION.VOIDED') { - $order_status_id = $setting['order_status']['voided']['id']; + if ($order_info['order_status_id'] != 0) { + $order_status_id = $setting['order_status']['voided']['id']; + } + $transaction_status = 'voided'; } - + if ($webhook_event['event_type'] == 'PAYMENT.CAPTURE.COMPLETED') { if (!empty($webhook_event['resource']['final_capture'])) { $order_status_id = $setting['order_status']['completed']['id']; @@ -4125,66 +4117,76 @@ public function webhook() { $transaction_status = 'partially_captured'; } } - + if ($webhook_event['event_type'] == 'PAYMENT.CAPTURE.DENIED') { - $order_status_id = $setting['order_status']['denied']['id']; + if ($order_info['order_status_id'] != 0) { + $order_status_id = $setting['order_status']['denied']['id']; + } + $transaction_status = 'denied'; } - + if ($webhook_event['event_type'] == 'PAYMENT.CAPTURE.PENDING') { $order_status_id = $setting['order_status']['pending']['id']; $transaction_status = 'pending'; } - + if ($webhook_event['event_type'] == 'PAYMENT.CAPTURE.REFUNDED') { $result = $paypal->getPaymentCapture($transaction_id); - + if (!empty($result['status'] == 'REFUNDED')) { - $order_status_id = $setting['order_status']['refunded']['id']; + if ($order_info['order_status_id'] != 0) { + $order_status_id = $setting['order_status']['refunded']['id']; + } + $transaction_status = 'refunded'; } elseif (!empty($result['status'] == 'PARTIALLY_REFUNDED')) { - $order_status_id = $setting['order_status']['partially_refunded']['id']; + if ($order_info['order_status_id'] != 0) { + $order_status_id = $setting['order_status']['partially_refunded']['id']; + } + $transaction_status = 'partially_refunded'; } } - + if ($webhook_event['event_type'] == 'PAYMENT.CAPTURE.REVERSED') { - $order_status_id = $setting['order_status']['reversed']['id']; + if ($order_info['order_status_id'] != 0) { + $order_status_id = $setting['order_status']['reversed']['id']; + } + $transaction_status = 'reversed'; } - + if ($webhook_event['event_type'] == 'CHECKOUT.ORDER.COMPLETED') { $order_status_id = $setting['order_status']['completed']['id']; } - - if ($order_status_id && ($order_info['order_status_id'] != $order_status_id)) { - $this->load->model('checkout/order'); - - $this->model_checkout_order->addOrderHistory($order_id, $order_status_id, '', true); - } - + if (isset($webhook_event['resource']['id']) && $transaction_status) { $transaction_id = $webhook_event['resource']['id']; - - $paypal_order_data = []; - + + $paypal_order_data = array(); + $paypal_order_data['order_id'] = $order_id; $paypal_order_data['transaction_status'] = $transaction_status; - + if (($transaction_status == 'created') && ($transaction_status == 'completed')) { $paypal_order_data['transaction_id'] = $transaction_id; } $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); } + + if ($order_status_id && ($order_info['order_status_id'] != $order_status_id) && !in_array($order_info['order_status_id'], $setting['final_order_status'])) { + $this->model_checkout_order->addOrderHistory($order_id, $order_status_id, '', true); + } } } - + if (($webhook_event['event_type'] == 'VAULT.PAYMENT-TOKEN.CREATED') && !empty($webhook_info['resource']['id']) && !empty($webhook_info['resource']['customer']['id']) && !empty($webhook_event['resource']['metadata']['order_id']) && !$errors) { $paypal_order_id = $webhook_event['resource']['metadata']['order_id']; - + $paypal_order_info = $this->model_extension_payment_paypal->getPayPalOrderByPayPalOrderId($paypal_order_id); - + if ($paypal_order_info) { $order_id = $paypal_order_info['order_id']; $payment_method = $paypal_order_info['payment_method']; @@ -4192,138 +4194,144 @@ public function webhook() { $vault_customer_id = $webhook_event['resource']['customer']['id']; $card_type = $paypal_order_info['card_type']; $card_nice_type = $paypal_order_info['card_nice_type']; - $card_last_digits = ($webhook_event['resource']['payment_source']['card']['last_digits'] ?? ''); - $card_expiry = ($webhook_event['resource']['payment_source']['card']['expiry'] ?? ''); - - $paypal_order_data = [ - 'order_id' => $order_id, - 'vault_id' => $vault_id, + $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( + 'order_id' => $order_id, + 'vault_id' => $vault_id, 'vault_customer_id' => $vault_customer_id, - 'card_last_digits' => $card_last_digits, - 'card_expiry' => $card_expiry - ]; - + 'card_last_digits' => $card_last_digits, + 'card_expiry' => $card_expiry + ); + $this->model_extension_payment_paypal->editPayPalOrder($paypal_order_data); - + $order_info = $this->model_checkout_order->getOrder($order_id); - + if ($vault_id && !empty($order_info['customer_id'])) { $customer_id = $order_info['customer_id']; - + $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 = [ - 'customer_id' => $customer_id, - 'payment_method' => $payment_method, - 'vault_id' => $vault_id, + $paypal_customer_token_data = array( + 'customer_id' => $customer_id, + 'payment_method' => $payment_method, + 'vault_id' => $vault_id, 'vault_customer_id' => $vault_customer_id, - 'card_type' => $card_type, - 'card_nice_type' => $card_nice_type, - 'card_last_digits' => $card_last_digits, - 'card_expiry' => $card_expiry - ]; - + 'card_type' => $card_type, + '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); } - + $this->model_extension_payment_paypal->setPayPalCustomerMainToken($customer_id, $payment_method, $vault_id); } } } - + header('HTTP/1.1 200 OK'); - + return true; } } - + return false; } - + public function cron() { if (!empty($this->request->get['cron_token'])) { $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + if (hash_equals($setting['general']['cron_token'], $this->request->get['cron_token'])) { $this->load->model('extension/payment/paypal'); - + $this->model_extension_payment_paypal->cronPayment(); - + return true; } } - + return false; } - + public function update() { $this->load->model('extension/payment/paypal'); - + $this->model_extension_payment_paypal->update(); } - - public function header_before($route, &$data) { + + public function content_top_before($route, &$data) { $this->load->model('extension/payment/paypal'); - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret') && $agree_status) { $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + + $currency_code = $this->session->data['currency']; + + if (empty($setting['currency'][$currency_code]['status'])) { + $currency_code = $setting['general']['currency_code']; + } + if (isset($this->request->get['route'])) { $route = $this->request->get['route']; } else { $route = 'common/home'; - } - - $params = []; - - if (($route == 'common/home') && $setting['message']['home']['status']) { + } + + $params = array(); + + if (($route == 'common/home') && ($setting['message']['home']['status'] && !empty($setting['paylater_country'][$setting['general']['country_code']]) && ($currency_code == $setting['general']['currency_code']))) { $params['page_code'] = 'home'; } - - if (($route == 'product/product') && ($setting['button']['product']['status'] || $setting['googlepay_button']['product']['status'] || $setting['applepay_button']['product']['status'] || $setting['message']['product']['status'])) { + + if (($route == 'product/product') && ($setting['button']['product']['status'] || $setting['googlepay_button']['product']['status'] || $setting['applepay_button']['product']['status'] || ($setting['message']['product']['status'] && !empty($setting['paylater_country'][$setting['general']['country_code']]) && ($currency_code == $setting['general']['currency_code'])))) { $params['page_code'] = 'product'; } - - if (($route == 'checkout/cart') && ($setting['button']['cart']['status'] || $setting['googlepay_button']['cart']['status'] || $setting['applepay_button']['cart']['status'] || $setting['message']['cart']['status'])) { + + if (($route == 'checkout/cart') && ($setting['button']['cart']['status'] || $setting['googlepay_button']['cart']['status'] || $setting['applepay_button']['cart']['status'] || ($setting['message']['cart']['status'] && !empty($setting['paylater_country'][$setting['general']['country_code']]) && ($currency_code == $setting['general']['currency_code'])))) { $params['page_code'] = 'cart'; } - - if (($route == $setting['general']['checkout_route']) && ($setting['button']['checkout']['status'] || $setting['googlepay_button']['checkout']['status'] || $setting['applepay_button']['checkout']['status'] || $setting['card']['status'] || $setting['message']['checkout']['status'])) { + + if (($route == $setting['general']['checkout_route']) && ($setting['button']['checkout']['status'] || $setting['googlepay_button']['checkout']['status'] || $setting['applepay_button']['checkout']['status'] || $setting['card']['status'] || ($setting['message']['checkout']['status'] && !empty($setting['paylater_country'][$setting['general']['country_code']]) && ($currency_code == $setting['general']['currency_code'])))) { $params['page_code'] = 'checkout'; } - + if ($params) { $theme = $this->config->get('theme_' . $this->config->get('config_theme') . '_directory'); - + if (file_exists(DIR_TEMPLATE . $theme . '/stylesheet/paypal/paypal.css')) { $this->document->addStyle('catalog/view/theme/' . $theme . '/stylesheet/paypal/paypal.css'); } else { $this->document->addStyle('catalog/view/theme/default/stylesheet/paypal/paypal.css'); } - + if (!empty($setting['googlepay_button'][$params['page_code']]['status'])) { $this->document->addScript('https://pay.google.com/gp/p/js/pay.js'); } - - if (!empty($setting['applepay_button'][$params['page_code']]['status']) && $this->isApple()) { + + if (!empty($setting['applepay_button'][$params['page_code']]['status'])) { $this->document->addScript('https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js'); } - - if ($params['page_code'] == 'checkout') { + + if ($params['page_code'] == 'checkout') { if ($setting['card']['status']) { if (file_exists(DIR_TEMPLATE . $theme . '/stylesheet/paypal/card.css')) { $this->document->addStyle('catalog/view/theme/' . $theme . '/stylesheet/paypal/card.css'); @@ -4332,59 +4340,59 @@ public function header_before($route, &$data) { } } } - + $this->document->addScript('catalog/view/javascript/paypal/paypal.js?' . http_build_query($params)); } - } + } } - + public function extension_get_extensions_after($route, $data, &$output) { if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret')) { $type = $data[0]; - - if ($type == 'payment') { + + if ($type == 'payment') { $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $currency_code = $this->session->data['currency']; - + if (!empty($setting['paylater_country'][$setting['general']['country_code']]) && ($currency_code == $setting['general']['currency_code']) && ($setting['button']['checkout']['funding']['paylater'] != 2)) { $this->config->set('paypal_paylater_status', 1); - - $output[] = [ + + $output[] = array( 'extension_id' => 0, - 'type' => 'payment', - 'code' => 'paypal_paylater' - ]; + 'type' => 'payment', + 'code' => 'paypal_paylater' + ); } - + if ($setting['googlepay_button']['checkout']['status']) { $this->config->set('paypal_googlepay_status', 1); - - $output[] = [ + + $output[] = array( 'extension_id' => 0, - 'type' => 'payment', - 'code' => 'paypal_googlepay' - ]; + 'type' => 'payment', + 'code' => 'paypal_googlepay' + ); } - - if ($setting['applepay_button']['checkout']['status'] && $this->isApple()) { + + if ($setting['applepay_button']['checkout']['status'] && !empty($this->session->data['paypal']['applepay'])) { $this->config->set('paypal_applepay_status', 1); - - $output[] = [ + + $output[] = array( 'extension_id' => 0, - 'type' => 'payment', - 'code' => 'paypal_applepay' - ]; + 'type' => 'payment', + 'code' => 'paypal_applepay' + ); } } - } + } } - + public function order_delete_order_before($route, $data) { $this->load->model('extension/payment/paypal'); @@ -4394,31 +4402,31 @@ public function order_delete_order_before($route, $data) { $this->model_extension_payment_paypal->deletePayPalOrder($order_id); $this->model_extension_payment_paypal->deletePayPalOrderRecurring($order_id); } - + private function validateShipping($code) { $this->load->language('checkout/cart'); $this->load->language('extension/payment/paypal'); if (empty($code)) { $this->session->data['error_warning'] = $this->language->get('error_shipping'); - + return false; } else { $shipping = explode('.', $code); if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) { $this->session->data['error_warning'] = $this->language->get('error_shipping'); - + return false; } else { $this->session->data['shipping_method'] = $this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]]; $this->session->data['success'] = $this->language->get('text_shipping_updated'); - + return true; } } } - + private function validatePaymentAddress() { if ((utf8_strlen(trim($this->request->post['firstname'])) < 1) || (utf8_strlen(trim($this->request->post['firstname'])) > 32)) { $this->error['firstname'] = $this->language->get('error_firstname'); @@ -4459,14 +4467,14 @@ private function validatePaymentAddress() { if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' || !is_numeric($this->request->post['zone_id'])) { $this->error['zone'] = $this->language->get('error_zone'); } - + // Customer Group if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) { $customer_group_id = $this->request->post['customer_group_id']; } else { $customer_group_id = $this->config->get('config_customer_group_id'); } - + // Custom field validation $this->load->model('account/custom_field'); @@ -4475,14 +4483,14 @@ 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, ['options' => ['regexp' => $custom_field['validation']]])) { - $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'])))) { + $this->error['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); + } } - + return !$this->error; } - + private function validateShippingAddress() { if ((utf8_strlen(trim($this->request->post['firstname'])) < 1) || (utf8_strlen(trim($this->request->post['firstname'])) > 32)) { $this->error['firstname'] = $this->language->get('error_firstname'); @@ -4515,32 +4523,32 @@ private function validateShippingAddress() { if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' || !is_numeric($this->request->post['zone_id'])) { $this->error['zone'] = $this->language->get('error_zone'); } - + // Customer Group if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) { $customer_group_id = $this->request->post['customer_group_id']; } else { $customer_group_id = $this->config->get('config_customer_group_id'); } - + // Custom field validation $this->load->model('account/custom_field'); $custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id); foreach ($custom_fields as $custom_field) { - if ($custom_field['location'] == 'address') { + 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, ['options' => ['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, array('options' => array('regexp' => $custom_field['validation'])))) { $this->error['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); } } } - + return !$this->error; } - + private function validateCoupon() { $this->load->model('extension/total/coupon'); @@ -4550,7 +4558,7 @@ private function validateCoupon() { return true; } else { $this->session->data['error_warning'] = $this->language->get('error_coupon'); - + return false; } } @@ -4564,7 +4572,7 @@ private function validateVoucher() { return true; } else { $this->session->data['error_warning'] = $this->language->get('error_voucher'); - + return false; } } @@ -4598,34 +4606,18 @@ private function validateReward() { return true; } else { $this->session->data['error_warning'] = $error; - + return false; } } - - private function isApple() { - if (!empty($this->request->server['HTTP_USER_AGENT'])) { - $user_agent = strtolower($this->request->server['HTTP_USER_AGENT']); - - $apple_agents = ['ipod', 'iphone', 'ipad', 'apple']; - - foreach ($apple_agents as $apple_agent) { - if (stripos($user_agent, $apple_agent)) { - return true; - } - } - } - - return false; - } - + private function unserialize($str) { - $data = []; - + $data = array(); + $str = str_replace('&', '&', $str); - + parse_str($str, $data); - + return $data; } -} +} \ No newline at end of file diff --git a/upload/catalog/controller/extension/payment/paypal_applepay.php b/upload/catalog/controller/extension/payment/paypal_applepay.php index 6820f4a8..e09c7f3d 100644 --- a/upload/catalog/controller/extension/payment/paypal_applepay.php +++ b/upload/catalog/controller/extension/payment/paypal_applepay.php @@ -1,22 +1,22 @@ load->model('extension/payment/paypal'); - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret') && $agree_status) { $this->load->language('extension/payment/paypal'); - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -25,79 +25,79 @@ public function index() { $data['partner_attribution_id'] = $setting['partner'][$data['environment']]['partner_attribution_id']; $data['checkout_mode'] = $setting['general']['checkout_mode']; $data['transaction_method'] = $setting['general']['transaction_method']; - + if ($setting['applepay_button']['checkout']['status']) { $data['applepay_button_status'] = $setting['applepay_button']['checkout']['status']; } - + $data['text_loading'] = $this->language->get('text_loading'); - + $data['button_confirm'] = $this->language->get('button_confirm'); - - require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $data['partner_id'], - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); - } + } - $data['error'] = $this->error; + $data['error'] = $this->error; return $this->load->view('extension/payment/paypal/paypal_applepay', $data); } - + return ''; } - + public function modal() { $this->load->language('extension/payment/paypal'); - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -105,61 +105,61 @@ public function modal() { $data['partner_id'] = $setting['partner'][$data['environment']]['partner_id']; $data['partner_attribution_id'] = $setting['partner'][$data['environment']]['partner_attribution_id']; $data['transaction_method'] = $setting['general']['transaction_method']; - + if ($setting['applepay_button']['checkout']['status']) { $data['applepay_button_status'] = $setting['applepay_button']['checkout']['status']; } - + $data['text_paypal_paylater_title'] = $this->language->get('text_paypal_paylater_title'); - - require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $data['partner_id'], - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); - } + } - $data['error'] = $this->error; + $data['error'] = $this->error; $this->response->setOutput($this->load->view('extension/payment/paypal/paypal_applepay_modal', $data)); } -} +} \ No newline at end of file diff --git a/upload/catalog/controller/extension/payment/paypal_googlepay.php b/upload/catalog/controller/extension/payment/paypal_googlepay.php index 37fa5e81..798db8f7 100644 --- a/upload/catalog/controller/extension/payment/paypal_googlepay.php +++ b/upload/catalog/controller/extension/payment/paypal_googlepay.php @@ -1,22 +1,22 @@ load->model('extension/payment/paypal'); - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret') && $agree_status) { $this->load->language('extension/payment/paypal'); - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -25,79 +25,79 @@ public function index() { $data['partner_attribution_id'] = $setting['partner'][$data['environment']]['partner_attribution_id']; $data['checkout_mode'] = $setting['general']['checkout_mode']; $data['transaction_method'] = $setting['general']['transaction_method']; - + if ($setting['googlepay_button']['checkout']['status']) { $data['googlepay_button_status'] = $setting['googlepay_button']['checkout']['status']; } - + $data['text_loading'] = $this->language->get('text_loading'); - + $data['button_confirm'] = $this->language->get('button_confirm'); - - require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $data['partner_id'], - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); - } + } - $data['error'] = $this->error; + $data['error'] = $this->error; return $this->load->view('extension/payment/paypal/paypal_googlepay', $data); } - + return ''; } - + public function modal() { $this->load->language('extension/payment/paypal'); - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -105,61 +105,61 @@ public function modal() { $data['partner_id'] = $setting['partner'][$data['environment']]['partner_id']; $data['partner_attribution_id'] = $setting['partner'][$data['environment']]['partner_attribution_id']; $data['transaction_method'] = $setting['general']['transaction_method']; - + if ($setting['googlepay_button']['checkout']['status']) { $data['googlepay_button_status'] = $setting['googlepay_button']['checkout']['status']; } - + $data['text_paypal_paylater_title'] = $this->language->get('text_paypal_paylater_title'); - - require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $data['partner_id'], - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); - } + } - $data['error'] = $this->error; + $data['error'] = $this->error; $this->response->setOutput($this->load->view('extension/payment/paypal/paypal_googlepay_modal', $data)); } -} +} \ No newline at end of file diff --git a/upload/catalog/controller/extension/payment/paypal_paylater.php b/upload/catalog/controller/extension/payment/paypal_paylater.php index 1e998ff2..a2927979 100644 --- a/upload/catalog/controller/extension/payment/paypal_paylater.php +++ b/upload/catalog/controller/extension/payment/paypal_paylater.php @@ -1,22 +1,22 @@ load->model('extension/payment/paypal'); - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret') && $agree_status) { $this->load->language('extension/payment/paypal'); - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -25,79 +25,79 @@ public function index() { $data['partner_attribution_id'] = $setting['partner'][$data['environment']]['partner_attribution_id']; $data['checkout_mode'] = $setting['general']['checkout_mode']; $data['transaction_method'] = $setting['general']['transaction_method']; - + if ($setting['button']['checkout']['status']) { $data['button_status'] = $setting['button']['checkout']['status']; } - + $data['text_loading'] = $this->language->get('text_loading'); - + $data['button_confirm'] = $this->language->get('button_confirm'); - - require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $data['partner_id'], - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); - } + } - $data['error'] = $this->error; + $data['error'] = $this->error; return $this->load->view('extension/payment/paypal/paypal_paylater', $data); } - + return ''; } - + public function modal() { $this->load->language('extension/payment/paypal'); - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $data['client_id'] = $this->config->get('paypal_client_id'); $data['secret'] = $this->config->get('paypal_secret'); $data['merchant_id'] = $this->config->get('paypal_merchant_id'); @@ -105,61 +105,61 @@ public function modal() { $data['partner_id'] = $setting['partner'][$data['environment']]['partner_id']; $data['partner_attribution_id'] = $setting['partner'][$data['environment']]['partner_attribution_id']; $data['transaction_method'] = $setting['general']['transaction_method']; - + if ($setting['button']['checkout']['status']) { $data['button_status'] = $setting['button']['checkout']['status']; } - + $data['text_paypal_paylater_title'] = $this->language->get('text_paypal_paylater_title'); - - require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $data['partner_id'], - 'client_id' => $data['client_id'], - 'secret' => $data['secret'], - 'environment' => $data['environment'], + + require_once DIR_SYSTEM .'library/paypal/paypal.php'; + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - + $data['client_token'] = $paypal->getClientToken(); - + if ($paypal->hasErrors()) { - $error_messages = []; - + $error_messages = array(); + $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + if (isset($error['details'][0]['description'])) { $error_messages[] = $error['details'][0]['description']; } elseif (isset($error['message'])) { $error_messages[] = $error['message']; } - + $this->model_extension_payment_paypal->log($error, $error['message']); } - + $this->error['warning'] = implode(' ', $error_messages); } if (!empty($this->error['warning'])) { $this->error['warning'] .= ' ' . sprintf($this->language->get('error_payment'), $this->url->link('information/contact', '', true)); - } + } - $data['error'] = $this->error; + $data['error'] = $this->error; $this->response->setOutput($this->load->view('extension/payment/paypal/paypal_paylater_modal', $data)); } -} +} \ No newline at end of file diff --git a/upload/catalog/controller/extension/recurring/paypal.php b/upload/catalog/controller/extension/recurring/paypal.php index 6f318aa4..b2b11f61 100644 --- a/upload/catalog/controller/extension/recurring/paypal.php +++ b/upload/catalog/controller/extension/recurring/paypal.php @@ -1,75 +1,75 @@ config->get('paypal_status') && !empty($this->request->get['order_recurring_id'])) { $this->load->language('extension/recurring/paypal'); - + $this->load->model('account/recurring'); - + $data['order_recurring_id'] = $this->request->get['order_recurring_id']; $order_recurring_info = $this->model_account_recurring->getOrderRecurring($data['order_recurring_id']); - + if ($order_recurring_info) { $data['button_enable_recurring'] = $this->language->get('button_enable_recurring'); $data['button_disable_recurring'] = $this->language->get('button_disable_recurring'); - + $data['recurring_status'] = $order_recurring_info['status']; - + $data['info_url'] = str_replace('&', '&', $this->url->link('extension/recurring/paypal/getRecurringInfo', 'order_recurring_id=' . $data['order_recurring_id'], true)); $data['enable_url'] = str_replace('&', '&', $this->url->link('extension/recurring/paypal/enableRecurring', '', true)); $data['disable_url'] = str_replace('&', '&', $this->url->link('extension/recurring/paypal/disableRecurring', '', true)); - + $content = $this->load->view('extension/recurring/paypal', $data); } } - + return $content; } - + public function getRecurringInfo() { $this->response->setOutput($this->index()); } - + public function enableRecurring() { if ($this->config->get('paypal_status') && !empty($this->request->post['order_recurring_id'])) { $this->load->language('extension/recurring/paypal'); - + $this->load->model('extension/payment/paypal'); - + $order_recurring_id = $this->request->post['order_recurring_id']; - + $this->model_extension_payment_paypal->editOrderRecurringStatus($order_recurring_id, 1); - - $data['success'] = $this->language->get('success_enable_recurring'); + + $data['success'] = $this->language->get('success_enable_recurring'); } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } - + public function disableRecurring() { if ($this->config->get('paypal_status') && !empty($this->request->post['order_recurring_id'])) { $this->load->language('extension/recurring/paypal'); - + $this->load->model('extension/payment/paypal'); - + $order_recurring_id = $this->request->post['order_recurring_id']; - + $this->model_extension_payment_paypal->editOrderRecurringStatus($order_recurring_id, 2); - - $data['success'] = $this->language->get('success_disable_recurring'); + + $data['success'] = $this->language->get('success_disable_recurring'); } - + $data['error'] = $this->error; - + $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($data)); } -} +} \ No newline at end of file diff --git a/upload/catalog/language/en-gb/extension/payment/paypal.php b/upload/catalog/language/en-gb/extension/payment/paypal.php index a6f886a4..15dd4582 100644 --- a/upload/catalog/language/en-gb/extension/payment/paypal.php +++ b/upload/catalog/language/en-gb/extension/payment/paypal.php @@ -106,4 +106,4 @@ $_['error_3ds_system_unavailable'] = 'We could not process the transaction with this card. An error occurred with the 3D Secure authentication system.'; $_['error_3ds_system_bypassed'] = 'We could not process the transaction with this card. 3D Secure was skipped as authentication system did not require a challenge.'; $_['error_payment'] = 'Please choose another payment method or contact us.'; -$_['error_timeout'] = 'Sorry, PayPal is currently busy. Please try again later!'; +$_['error_timeout'] = 'Sorry, PayPal is currently busy. Please try again later!'; \ No newline at end of file diff --git a/upload/catalog/language/en-gb/extension/recurring/paypal.php b/upload/catalog/language/en-gb/extension/recurring/paypal.php index 25eff516..56898d08 100644 --- a/upload/catalog/language/en-gb/extension/recurring/paypal.php +++ b/upload/catalog/language/en-gb/extension/recurring/paypal.php @@ -5,4 +5,4 @@ // Success $_['success_enable_recurring'] = 'Success: Recurring payment was enabled.'; -$_['success_disable_recurring'] = 'Success: Recurring payment was disabled.'; +$_['success_disable_recurring'] = 'Success: Recurring payment was disabled.'; \ No newline at end of file diff --git a/upload/catalog/model/extension/payment/paypal.php b/upload/catalog/model/extension/payment/paypal.php index 6e4f1e02..07fbe6a3 100644 --- a/upload/catalog/model/extension/payment/paypal.php +++ b/upload/catalog/model/extension/payment/paypal.php @@ -1,10 +1,11 @@ getAgreeStatus(); - + if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret') && $agree_status) { $this->load->language('extension/payment/paypal'); @@ -20,110 +21,110 @@ public function getMethod($address, $total) { $status = false; } - if ($status) { - $method_data = [ + if ($status) { + $method_data = array( 'code' => 'paypal', 'title' => $this->language->get('text_paypal_title'), 'terms' => '', 'sort_order' => $this->config->get('paypal_sort_order') - ]; + ); } } return $method_data; } - - public function hasProductInCart($product_id, $option = [], $recurring_id = 0) { + + public function hasProductInCart($product_id, $option = array(), $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']; } - + public function getCountryByCode($code) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country WHERE iso_code_2 = '" . $this->db->escape($code) . "' AND status = '1'"); - + return $query->row; } - + public function getZoneByCode($country_id, $code) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE country_id = '" . (int)$country_id . "' AND (code = '" . $this->db->escape($code) . "' OR name = '" . $this->db->escape($code) . "') AND status = '1'"); - + return $query->row; } - + public function addPayPalCustomerToken($data) { $sql = "INSERT INTO `" . DB_PREFIX . "paypal_checkout_integration_customer_token` SET"; - $implode = []; - + $implode = array(); + if (!empty($data['customer_id'])) { $implode[] = "`customer_id` = '" . (int)$data['customer_id'] . "'"; } - + if (!empty($data['payment_method'])) { $implode[] = "`payment_method` = '" . $this->db->escape($data['payment_method']) . "'"; - } + } if (!empty($data['vault_id'])) { $implode[] = "`vault_id` = '" . $this->db->escape($data['vault_id']) . "'"; } - + if (!empty($data['vault_customer_id'])) { $implode[] = "`vault_customer_id` = '" . $this->db->escape($data['vault_customer_id']) . "'"; } - + if (!empty($data['card_type'])) { $implode[] = "`card_type` = '" . $this->db->escape($data['card_type']) . "'"; } - + if (!empty($data['card_nice_type'])) { $implode[] = "`card_nice_type` = '" . $this->db->escape($data['card_nice_type']) . "'"; } - + if (!empty($data['card_last_digits'])) { $implode[] = "`card_last_digits` = '" . $this->db->escape($data['card_last_digits']) . "'"; } - + if (!empty($data['card_expiry'])) { $implode[] = "`card_expiry` = '" . $this->db->escape($data['card_expiry']) . "'"; } - + if ($implode) { $sql .= implode(", ", $implode); } - + $this->db->query($sql); } - + public function deletePayPalCustomerToken($customer_id, $payment_method, $vault_id) { $query = $this->db->query("DELETE FROM `" . DB_PREFIX . "paypal_checkout_integration_customer_token` WHERE `customer_id` = '" . (int)$customer_id . "' AND `payment_method` = '" . $this->db->escape($payment_method) . "' AND `vault_id` = '" . $this->db->escape($vault_id) . "'"); } - + public function setPayPalCustomerMainToken($customer_id, $payment_method, $vault_id) { $this->db->query("UPDATE `" . DB_PREFIX . "paypal_checkout_integration_customer_token` SET `main_token_status` = '0' WHERE `customer_id` = '" . (int)$customer_id . "' AND `payment_method` = '" . $this->db->escape($payment_method) . "'"); $this->db->query("UPDATE `" . DB_PREFIX . "paypal_checkout_integration_customer_token` SET `main_token_status` = '1' WHERE `customer_id` = '" . (int)$customer_id . "' AND `payment_method` = '" . $this->db->escape($payment_method) . "' AND `vault_id` = '" . $this->db->escape($vault_id) . "'"); } - + public function getPayPalCustomerMainToken($customer_id, $payment_method) { $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "paypal_checkout_integration_customer_token` WHERE `customer_id` = '" . (int)$customer_id . "' AND `payment_method` = '" . $this->db->escape($payment_method) . "' AND `main_token_status` = '1'"); - + if ($query->num_rows) { return $query->row; } else { - return []; + return array(); } } - + public function getPayPalCustomerToken($customer_id, $payment_method, $vault_id) { $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "paypal_checkout_integration_customer_token` WHERE `customer_id` = '" . (int)$customer_id . "' AND `payment_method` = '" . $this->db->escape($payment_method) . "' AND `vault_id` = '" . $this->db->escape($vault_id) . "'"); if ($query->num_rows) { return $query->row; } else { - return []; + return array(); } } - + public function getPayPalCustomerTokens($customer_id, $payment_method = '') { if ($payment_method) { $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "paypal_checkout_integration_customer_token` WHERE `customer_id` = '" . (int)$customer_id . "' AND `payment_method` = '" . $this->db->escape($payment_method) . "'"); @@ -134,184 +135,184 @@ public function getPayPalCustomerTokens($customer_id, $payment_method = '') { if ($query->num_rows) { return $query->rows; } else { - return []; + return array(); } } - + public function addPayPalOrder($data) { $sql = "INSERT INTO `" . DB_PREFIX . "paypal_checkout_integration_order` SET"; - $implode = []; - + $implode = array(); + if (!empty($data['order_id'])) { $implode[] = "`order_id` = '" . (int)$data['order_id'] . "'"; } - + if (!empty($data['paypal_order_id'])) { $implode[] = "`paypal_order_id` = '" . $this->db->escape($data['paypal_order_id']) . "'"; } - + if (!empty($data['transaction_id'])) { $implode[] = "`transaction_id` = '" . $this->db->escape($data['transaction_id']) . "'"; } - + if (!empty($data['transaction_status'])) { $implode[] = "`transaction_status` = '" . $this->db->escape($data['transaction_status']) . "'"; } - + if (!empty($data['payment_method'])) { $implode[] = "`payment_method` = '" . $this->db->escape($data['payment_method']) . "'"; } - + if (!empty($data['vault_id'])) { $implode[] = "`vault_id` = '" . $this->db->escape($data['vault_id']) . "'"; } - + if (!empty($data['vault_customer_id'])) { $implode[] = "`vault_customer_id` = '" . $this->db->escape($data['vault_customer_id']) . "'"; } - + if (!empty($data['card_type'])) { $implode[] = "`card_type` = '" . $this->db->escape($data['card_type']) . "'"; } - + if (!empty($data['card_nice_type'])) { $implode[] = "`card_nice_type` = '" . $this->db->escape($data['card_nice_type']) . "'"; } - + if (!empty($data['card_last_digits'])) { $implode[] = "`card_last_digits` = '" . $this->db->escape($data['card_last_digits']) . "'"; } - + if (!empty($data['card_expiry'])) { $implode[] = "`card_expiry` = '" . $this->db->escape($data['card_expiry']) . "'"; } - + if (!empty($data['total'])) { $implode[] = "`total` = '" . (float)$data['total'] . "'"; } - + if (!empty($data['currency_code'])) { $implode[] = "`currency_code` = '" . $this->db->escape($data['currency_code']) . "'"; } - + if (!empty($data['environment'])) { $implode[] = "`environment` = '" . $this->db->escape($data['environment']) . "'"; } - + if (isset($data['tracking_number'])) { $implode[] = "`tracking_number` = '" . $this->db->escape($data['tracking_number']) . "'"; } - + if (isset($data['carrier_name'])) { $implode[] = "`carrier_name` = '" . $this->db->escape($data['carrier_name']) . "'"; } - + if ($implode) { $sql .= implode(", ", $implode); } - + $this->db->query($sql); } - + public function editPayPalOrder($data) { $sql = "UPDATE `" . DB_PREFIX . "paypal_checkout_integration_order` SET"; - $implode = []; - + $implode = array(); + if (!empty($data['paypal_order_id'])) { $implode[] = "`paypal_order_id` = '" . $this->db->escape($data['paypal_order_id']) . "'"; } - + if (!empty($data['transaction_id'])) { $implode[] = "`transaction_id` = '" . $this->db->escape($data['transaction_id']) . "'"; } - + if (!empty($data['transaction_status'])) { $implode[] = "`transaction_status` = '" . $this->db->escape($data['transaction_status']) . "'"; } - + if (!empty($data['payment_method'])) { $implode[] = "`payment_method` = '" . $this->db->escape($data['payment_method']) . "'"; } - + if (!empty($data['vault_id'])) { $implode[] = "`vault_id` = '" . $this->db->escape($data['vault_id']) . "'"; } - + if (!empty($data['vault_customer_id'])) { $implode[] = "`vault_customer_id` = '" . $this->db->escape($data['vault_customer_id']) . "'"; } - + if (!empty($data['card_type'])) { $implode[] = "`card_type` = '" . $this->db->escape($data['card_type']) . "'"; } - + if (!empty($data['card_nice_type'])) { $implode[] = "`card_nice_type` = '" . $this->db->escape($data['card_nice_type']) . "'"; } - + if (!empty($data['card_last_digits'])) { $implode[] = "`card_last_digits` = '" . $this->db->escape($data['card_last_digits']) . "'"; } - + if (!empty($data['card_expiry'])) { $implode[] = "`card_expiry` = '" . $this->db->escape($data['card_expiry']) . "'"; } - + if (!empty($data['total'])) { $implode[] = "`total` = '" . (float)$data['total'] . "'"; } - + if (!empty($data['currency_code'])) { $implode[] = "`currency_code` = '" . $this->db->escape($data['currency_code']) . "'"; } - + if (!empty($data['environment'])) { $implode[] = "`environment` = '" . $this->db->escape($data['environment']) . "'"; } - + if (isset($data['tracking_number'])) { $implode[] = "`tracking_number` = '" . $this->db->escape($data['tracking_number']) . "'"; } - + if (isset($data['carrier_name'])) { $implode[] = "`carrier_name` = '" . $this->db->escape($data['carrier_name']) . "'"; } - + if ($implode) { $sql .= implode(", ", $implode); } $sql .= " WHERE `order_id` = '" . (int)$data['order_id'] . "'"; - + $this->db->query($sql); } - + public function deletePayPalOrder($order_id) { $query = $this->db->query("DELETE FROM `" . DB_PREFIX . "paypal_checkout_integration_order` WHERE `order_id` = '" . (int)$order_id . "'"); } - + public function getPayPalOrder($order_id) { $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "paypal_checkout_integration_order` WHERE `order_id` = '" . (int)$order_id . "'"); - + if ($query->num_rows) { return $query->row; } else { - return []; + return array(); } } - + public function getPayPalOrderByPayPalOrderId($paypal_order_id) { $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "paypal_checkout_integration_order` WHERE `paypal_order_id` = '" . $this->db->escape($paypal_order_id) . "'"); - + if ($query->num_rows) { return $query->row; } else { - return []; + return array(); } } - + public function addPayPalOrderRecurring($data) { $this->db->query("INSERT INTO `" . DB_PREFIX . "paypal_checkout_integration_order_recurring` SET `order_recurring_id` = '" . (int)$data['order_recurring_id'] . "', `order_id` = '" . (int)$data['order_id'] . "', `date_added` = NOW(), `date_modified` = NOW(), `next_payment` = NOW(), `trial_end` = '" . $data['trial_end'] . "', `subscription_end` = '" . $data['subscription_end'] . "', `currency_code` = '" . $this->db->escape($data['currency_code']) . "', `total` = '" . $this->currency->format($data['amount'], $data['currency_code'], false, false) . "'"); } @@ -319,75 +320,75 @@ public function addPayPalOrderRecurring($data) { public function editPayPalOrderRecurringNextPayment($order_recurring_id, $next_payment) { $this->db->query("UPDATE `" . DB_PREFIX . "paypal_checkout_integration_order_recurring` SET `next_payment` = '" . $next_payment . "', `date_modified` = NOW() WHERE `order_recurring_id` = '" . (int)$order_recurring_id . "'"); } - + public function deletePayPalOrderRecurring($order_id) { $query = $this->db->query("DELETE FROM `" . DB_PREFIX . "paypal_checkout_integration_order_recurring` WHERE `order_id` = '" . (int)$order_id . "'"); } public function getPayPalOrderRecurring($order_recurring_id) { $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "paypal_checkout_integration_order_recurring` WHERE `order_recurring_id` = '" . (int)$order_recurring_id . "'"); - + return $query->row; } - + public function addOrderRecurring($order_id, $description, $data, $reference) { $this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring` SET `order_id` = '" . (int)$order_id . "', `date_added` = NOW(), `status` = '1', `product_id` = '" . (int)$data['product_id'] . "', `product_name` = '" . $this->db->escape($data['name']) . "', `product_quantity` = '" . $this->db->escape($data['quantity']) . "', `recurring_id` = '" . (int)$data['recurring']['recurring_id'] . "', `recurring_name` = '" . $this->db->escape($data['name']) . "', `recurring_description` = '" . $this->db->escape($description) . "', `recurring_frequency` = '" . $this->db->escape($data['recurring']['frequency']) . "', `recurring_cycle` = '" . (int)$data['recurring']['cycle'] . "', `recurring_duration` = '" . (int)$data['recurring']['duration'] . "', `recurring_price` = '" . (float)$data['recurring']['price'] . "', `trial` = '" . (int)$data['recurring']['trial'] . "', `trial_frequency` = '" . $this->db->escape($data['recurring']['trial_frequency']) . "', `trial_cycle` = '" . (int)$data['recurring']['trial_cycle'] . "', `trial_duration` = '" . (int)$data['recurring']['trial_duration'] . "', `trial_price` = '" . (float)$data['recurring']['trial_price'] . "', `reference` = '" . $this->db->escape($reference) . "'"); return $this->db->getLastId(); } - + public function editOrderRecurringStatus($order_recurring_id, $status) { $this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `status` = '" . (int)$status . "' WHERE `order_recurring_id` = '" . (int)$order_recurring_id . "'"); } - + public function deleteOrderRecurring($order_id) { $query = $this->db->query("SELECT order_recurring_id FROM `" . DB_PREFIX . "order_recurring` WHERE order_id = '" . (int)$order_id . "'"); foreach ($query->rows as $order_recurring) { $this->deleteOrderRecurringTransaction($order_recurring['order_recurring_id']); } - + $query = $this->db->query("DELETE FROM `" . DB_PREFIX . "order_recurring` WHERE `order_id` = '" . (int)$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 = []; + + $order_recurring_data = array(); foreach ($query->rows as $order_recurring) { $order_recurring_data[] = $this->getOrderRecurring($order_recurring['order_recurring_id']); } - + return $order_recurring_data; } public function getOrderRecurring($order_recurring_id) { $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_recurring` WHERE `order_recurring_id` = '" . (int)$order_recurring_id . "'"); - + return $query->row; } public function addOrderRecurringTransaction($data) { $this->db->query("INSERT INTO `" . DB_PREFIX . "order_recurring_transaction` SET `order_recurring_id` = '" . (int)$data['order_recurring_id'] . "', `reference` = '" . $this->db->escape($data['reference']) . "', `type` = '" . (int)$data['type'] . "', `amount` = '" . (float)$data['amount'] . "', `date_added` = NOW()"); } - + public function deleteOrderRecurringTransaction($order_recurring_id) { $query = $this->db->query("DELETE FROM `" . DB_PREFIX . "order_recurring_transaction` WHERE `order_recurring_id` = '" . (int)$order_recurring_id . "'"); } - - public function recurringPayment($product_data, $order_data, $paypal_order_data) { + + public function recurringPayment($product_data, $order_data, $paypal_order_data) { $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $transaction_method = $setting['general']['transaction_method']; - + $recurring_name = $product_data['recurring']['name']; - + if ($product_data['recurring']['trial'] == 1) { $price = $product_data['recurring']['trial_price']; $trial_amt = $this->currency->format($this->tax->calculate($product_data['recurring']['trial_price'], $product_data['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'], false, false) * $product_data['quantity'] . ' ' . $this->session->data['currency']; @@ -396,7 +397,7 @@ public function recurringPayment($product_data, $order_data, $paypal_order_data) $price = $product_data['recurring']['price']; $trial_text = ''; } - + $recurring_amt = $this->currency->format($this->tax->calculate($product_data['recurring']['price'], $product_data['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'], false, false) * $product_data['quantity'] . ' ' . $this->session->data['currency']; $recurring_description = $trial_text . sprintf($this->language->get('text_recurring'), $recurring_amt, $product_data['recurring']['cycle'], $product_data['recurring']['frequency']); @@ -405,9 +406,9 @@ public function recurringPayment($product_data, $order_data, $paypal_order_data) } $order_recurring_id = $this->addOrderRecurring($order_data['order_id'], $recurring_description, $product_data, $paypal_order_data['transaction_id']); - + $this->editOrderRecurringStatus($order_recurring_id, 1); - + if (!empty($paypal_order_data['vault_id'])) { $next_payment = new DateTime('now'); $trial_end = new DateTime('now'); @@ -420,7 +421,7 @@ public function recurringPayment($product_data, $order_data, $paypal_order_data) $next_payment = $this->calculateSchedule($product_data['recurring']['trial_frequency'], $next_payment, $product_data['recurring']['trial_cycle']); $trial_end = new DateTime('0000-00-00'); } - + if (date_format($trial_end, 'Y-m-d H:i:s') > date_format($subscription_end, 'Y-m-d H:i:s') && $product_data['recurring']['duration'] != 0) { $subscription_end = new DateTime(date_format($trial_end, 'Y-m-d H:i:s')); $subscription_end = $this->calculateSchedule($product_data['recurring']['frequency'], $subscription_end, $product_data['recurring']['cycle'] * $product_data['recurring']['duration']); @@ -433,14 +434,14 @@ public function recurringPayment($product_data, $order_data, $paypal_order_data) $next_payment = $this->calculateSchedule($product_data['recurring']['frequency'], $next_payment, $product_data['recurring']['cycle']); $subscription_end = new DateTime('0000-00-00'); } - + $result = $this->createPayment($order_data, $paypal_order_data, $price, $order_recurring_id, $recurring_name); $transaction_status = ''; $transaction_id = ''; $currency_code = ''; $amount = ''; - + if ($transaction_method == 'authorize') { if (isset($result['purchase_units'][0]['payments']['authorizations'][0]['status']) && isset($result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status'])) { $transaction_id = $result['purchase_units'][0]['payments']['authorizations'][0]['id']; @@ -456,58 +457,58 @@ public function recurringPayment($product_data, $order_data, $paypal_order_data) $amount = $result['purchase_units'][0]['payments']['captures'][0]['amount']['value']; } } - - if ($transaction_id && $transaction_status && $currency_code && $amount) { - $paypal_order_recurring_data = [ + + if ($transaction_id && $transaction_status && $currency_code && $amount) { + $paypal_order_recurring_data = array( '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 - ]; - + '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 = [ + $order_recurring_transaction_data = array( 'order_recurring_id' => $order_recurring_id, - 'reference' => $transaction_id, - 'type' => '1', - 'amount' => $amount - ]; - + '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 = [ + $order_recurring_transaction_data = array( 'order_recurring_id' => $order_recurring_id, - 'reference' => $transaction_id, - 'type' => '4', - 'amount' => $amount - ]; - + 'reference' => $transaction_id, + 'type' => '4', + 'amount' => $amount + ); + $this->addOrderRecurringTransaction($order_recurring_transaction_data); } } } } - + public function cronPayment() { $this->load->model('checkout/order'); - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $transaction_method = $setting['general']['transaction_method']; - + $order_recurrings = $this->getOrderRecurrings(); - + foreach ($order_recurrings as $order_recurring) { if ($order_recurring['status'] == 1) { $paypal_order_recurring = $this->getPayPalOrderRecurring($order_recurring['order_recurring_id']); @@ -520,9 +521,9 @@ public function cronPayment() { $subscription_end = new DateTime($paypal_order_recurring['subscription_end']); $order_info = $this->model_checkout_order->getOrder($order_recurring['order_id']); - + $paypal_order_info = $this->getPayPalOrder($order_recurring['order_id']); - + if (!empty($paypal_order_info['vault_id'])) { if ((date_format($today, 'Y-m-d H:i:s') > date_format($next_payment, 'Y-m-d H:i:s')) && (date_format($trial_end, 'Y-m-d H:i:s') > date_format($today, 'Y-m-d H:i:s') || date_format($trial_end, 'Y-m-d H:i:s') == date_format($unlimited, 'Y-m-d H:i:s'))) { $price = $this->currency->format($order_recurring['trial_price'], $order_info['currency_code'], false, false); @@ -539,12 +540,12 @@ public function cronPayment() { } $result = $this->createPayment($order_info, $paypal_order_info, $price, $order_recurring['order_recurring_id'], $order_recurring['recurring_name']); - + $transaction_status = ''; $transaction_id = ''; $currency_code = ''; $amount = ''; - + if ($transaction_method == 'authorize') { if (isset($result['purchase_units'][0]['payments']['authorizations'][0]['status']) && isset($result['purchase_units'][0]['payments']['authorizations'][0]['seller_protection']['status'])) { $transaction_id = $result['purchase_units'][0]['payments']['authorizations'][0]['id']; @@ -560,27 +561,27 @@ public function cronPayment() { $amount = $result['purchase_units'][0]['payments']['captures'][0]['amount']['value']; } } - + if ($transaction_id && $transaction_status && $currency_code && $amount) { if (($transaction_status == 'CREATED') || ($transaction_status == 'COMPLETED') || ($transaction_status == 'PENDING')) { - $order_recurring_transaction_data = [ + $order_recurring_transaction_data = array( 'order_recurring_id' => $order_recurring['order_recurring_id'], - 'reference' => $transaction_id, - 'type' => '1', - 'amount' => $amount - ]; - + '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 = [ + $order_recurring_transaction_data = array( 'order_recurring_id' => $order_recurring['order_recurring_id'], - 'reference' => $transaction_id, - 'type' => '4', - 'amount' => $amount - ]; - + 'reference' => $transaction_id, + 'type' => '4', + 'amount' => $amount + ); + $this->addOrderRecurringTransaction($order_recurring_transaction_data); } } @@ -589,124 +590,124 @@ public function cronPayment() { } } } - + public function createPayment($order_data, $paypal_order_data, $price, $order_recurring_id, $recurring_name) { $this->load->language('extension/payment/paypal'); - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + $client_id = $this->config->get('paypal_client_id'); $secret = $this->config->get('paypal_secret'); $merchant_id = $this->config->get('paypal_merchant_id'); $environment = $this->config->get('paypal_environment'); $partner_id = $setting['partner'][$environment]['partner_id']; $partner_attribution_id = $setting['partner'][$environment]['partner_attribution_id']; - $transaction_method = $setting['general']['transaction_method']; - + $transaction_method = $setting['general']['transaction_method']; + $currency_code = $order_data['currency_code']; - $currency_value = $this->currency->getValue($currency_code); + $currency_value = $this->currency->getValue($currency_code); $decimal_place = $setting['currency'][$currency_code]['decimal_place']; - + require_once DIR_SYSTEM . 'library/paypal/paypal.php'; - - $paypal_info = [ - 'partner_id' => $partner_id, - 'client_id' => $client_id, - 'secret' => $secret, - 'environment' => $environment, + + $paypal_info = array( + '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 = [ + + $token_info = array( 'grant_type' => 'client_credentials' - ]; - + ); + $paypal->setAccessToken($token_info); - - $item_info = []; - + + $item_info = array(); + $item_total = 0; - + $product_price = number_format($price * $currency_value, $decimal_place, '.', ''); - - $item_info[] = [ - 'name' => $recurring_name, - 'quantity' => 1, - 'unit_amount' => [ + + $item_info[] = array( + 'name' => $recurring_name, + 'quantity' => 1, + 'unit_amount' => array( 'currency_code' => $currency_code, - 'value' => $product_price - ] - ]; - + '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 = []; - + + $amount_info = array(); + $amount_info['currency_code'] = $currency_code; $amount_info['value'] = $order_total; - - $amount_info['breakdown']['item_total'] = [ + + $amount_info['breakdown']['item_total'] = array( 'currency_code' => $currency_code, - 'value' => $item_total - ]; - - $paypal_order_info = []; - + 'value' => $item_total + ); + + $paypal_order_info = array(); + $paypal_order_info['intent'] = strtoupper($transaction_method); $paypal_order_info['purchase_units'][0]['reference_id'] = 'default'; $paypal_order_info['purchase_units'][0]['items'] = $item_info; $paypal_order_info['purchase_units'][0]['amount'] = $amount_info; - + $paypal_order_info['purchase_units'][0]['description'] = 'Subscription to order ' . $order_data['order_id']; - + $shipping_preference = 'NO_SHIPPING'; - + $paypal_order_info['application_context']['shipping_preference'] = $shipping_preference; - + $paypal_order_info['payment_source'][$paypal_order_data['payment_method']]['vault_id'] = $paypal_order_data['vault_id']; - + if ($paypal_order_data['payment_method'] == 'card') { $paypal_order_info['payment_source'][$paypal_order_data['payment_method']]['stored_credential']['payment_initiator'] = 'MERCHANT'; $paypal_order_info['payment_source'][$paypal_order_data['payment_method']]['stored_credential']['payment_type'] = 'UNSCHEDULED'; $paypal_order_info['payment_source'][$paypal_order_data['payment_method']]['stored_credential']['usage'] = 'SUBSEQUENT'; $paypal_order_info['payment_source'][$paypal_order_data['payment_method']]['stored_credential']['previous_transaction_reference'] = $paypal_order_data['transaction_id']; } - + $result = $paypal->createOrder($paypal_order_info); - - $errors = []; - + + $errors = array(); + if ($paypal->hasErrors()) { $errors = $paypal->getErrors(); - + foreach ($errors as $error) { if (isset($error['name']) && ($error['name'] == 'CURLE_OPERATION_TIMEOUTED')) { $error['message'] = $this->language->get('error_timeout'); } - + $this->log($error, $error['message']); } } - + if (isset($result['id']) && isset($result['status']) && !$errors) { $this->log($result, 'Create Recurring Payment'); - + return $result; } - + return false; } - + public function calculateSchedule($frequency, $next_payment, $cycle) { if ($frequency == 'semi_month') { $day = date_format($next_payment, 'd'); @@ -722,8 +723,8 @@ public function calculateSchedule($frequency, $next_payment, $cycle) { $minus_even = $cycle / 2; if ($day == 1) { - $odd--; - $plus_even--; + $odd = $odd - 1; + $plus_even = $plus_even - 1; $day = 16; } @@ -743,89 +744,90 @@ public function calculateSchedule($frequency, $next_payment, $cycle) { } else { $next_payment->modify('+' . $cycle . ' ' . $frequency); } - + return $next_payment; } - + public function getAgreeStatus() { $agree_status = true; - + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country WHERE status = '1' AND (iso_code_2 = 'CU' OR iso_code_2 = 'IR' OR iso_code_2 = 'SY' OR iso_code_2 = 'KP')"); - + if ($query->rows) { $agree_status = false; } - + $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE country_id = '220' AND status = '1' AND (`code` = '43' OR `code` = '14' OR `code` = '09')"); - + if ($query->rows) { $agree_status = false; } - + return $agree_status; } - + public function log($data, $title = '') { $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + if ($setting['general']['debug']) { $log = new Log('paypal.log'); $log->write('PayPal debug (' . $title . '): ' . json_encode($data)); } } - + public function update() { if ($this->config->get('paypal_version') < '3.1.0') { $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_checkout_integration_customer_token`"); $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order`"); $this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order_recurring`"); - + $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_checkout_integration_customer_token` (`customer_id` INT(11) NOT NULL, `payment_method` VARCHAR(20) NOT NULL, `vault_id` VARCHAR(50) NOT NULL, `vault_customer_id` VARCHAR(50) NOT NULL, `card_type` VARCHAR(40) NOT NULL, `card_nice_type` VARCHAR(40) NOT NULL, `card_last_digits` VARCHAR(4) NOT NULL, `card_expiry` VARCHAR(20) NOT NULL, `main_token_status` TINYINT(1) NOT NULL, PRIMARY KEY (`customer_id`, `payment_method`, `vault_id`), KEY `vault_customer_id` (`vault_customer_id`), KEY `main_token_status` (`main_token_status`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci"); $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order` (`order_id` INT(11) NOT NULL, `paypal_order_id` VARCHAR(20) NOT NULL, `transaction_id` VARCHAR(20) NOT NULL, `transaction_status` VARCHAR(20) NOT NULL, `payment_method` VARCHAR(20) NOT NULL, `vault_id` VARCHAR(50) NOT NULL, `vault_customer_id` VARCHAR(50) NOT NULL, `card_type` VARCHAR(40) NOT NULL, `card_nice_type` VARCHAR(40) NOT NULL, `card_last_digits` VARCHAR(4) NOT NULL, `card_expiry` VARCHAR(20) NOT NULL, `total` DECIMAL(15,2) NOT NULL, `currency_code` VARCHAR(3) NOT NULL, `environment` VARCHAR(20) NOT NULL, `tracking_number` VARCHAR(64) NOT NULL, `carrier_name` VARCHAR(64) NOT NULL, PRIMARY KEY (`order_id`), KEY `paypal_order_id` (`paypal_order_id`), KEY `transaction_id` (`transaction_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci"); $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "paypal_checkout_integration_order_recurring` (`paypal_order_recurring_id` INT(11) NOT NULL AUTO_INCREMENT, `order_id` INT(11) NOT NULL, `order_recurring_id` INT(11) NOT NULL, `date_added` DATETIME NOT NULL, `date_modified` DATETIME NOT NULL, `next_payment` DATETIME NOT NULL, `trial_end` DATETIME DEFAULT NULL, `subscription_end` DATETIME DEFAULT NULL, `currency_code` CHAR(3) NOT NULL, `total` DECIMAL(10, 2) NOT NULL, PRIMARY KEY (`paypal_order_recurring_id`), KEY (`order_id`), KEY (`order_recurring_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci"); } - + $this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = 'paypal_order_info'"); $this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = 'paypal_header'"); + $this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = 'paypal_content_top'"); $this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = 'paypal_extension_get_extensions'"); $this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = 'paypal_order_delete_order'"); $this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = 'paypal_customer_delete_customer'"); - + $this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'paypal_order_info', `trigger` = 'admin/view/sale/order_info/before', `action` = 'extension/payment/paypal/order_info_before', `status` = '1'"); - $this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'paypal_header', `trigger` = 'catalog/controller/common/header/before', `action` = 'extension/payment/paypal/header_before', `status` = '1'"); + $this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'paypal_content_top', `trigger` = 'catalog/controller/common/content_top/before', `action` = 'extension/payment/paypal/content_top_before', `status` = '1'"); $this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'paypal_extension_get_extensions', `trigger` = 'catalog/model/extension/extension/getExtensions/after', `action` = 'extension/payment/paypal/extension_get_extensions_after', `status` = '1'"); $this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'paypal_order_delete_order', `trigger` = 'catalog/model/checkout/order/deleteOrder/before', `action` = 'extension/payment/paypal/order_delete_order_before', `status` = '1'"); $this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = 'paypal_customer_delete_customer', `trigger` = 'admin/model/customer/customer/deleteCustomer/before', `action` = 'extension/payment/paypal/customer_delete_customer_before', `status` = '1'"); - + if ($this->config->get('paypal_version') < '3.1.0') { - $setting = []; - + $setting = array(); + $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "setting` WHERE store_id = '0' AND `key` = 'paypal_setting'"); - + if ($query->row) { $setting[$query->row['key']] = json_decode($query->row['value'], true); } - + $setting['paypal_setting']['general']['order_history_token'] = sha1(uniqid(mt_rand(), 1)); - + $this->db->query("UPDATE " . DB_PREFIX . "setting SET `value` = '" . $this->db->escape(json_encode($setting)) . "', serialized = '1' WHERE `key` = '" . $this->db->escape('paypal_setting') . "' AND store_id = '0'"); } - + $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $this->db->query("DELETE FROM `" . DB_PREFIX . "setting` WHERE store_id = '0' AND `code` = 'paypal_version'"); $this->db->query("INSERT INTO " . DB_PREFIX . "setting SET store_id = '0', `code` = 'paypal_version', `key` = 'paypal_version', `value` = '" . $this->db->escape($config_setting['version']) . "'"); } - + public function recurringPayments() { /* * Used by the checkout to state the module @@ -833,4 +835,4 @@ public function recurringPayments() { */ return true; } -} +} \ No newline at end of file diff --git a/upload/catalog/model/extension/payment/paypal_applepay.php b/upload/catalog/model/extension/payment/paypal_applepay.php index ff6665ed..2da4bcb0 100644 --- a/upload/catalog/model/extension/payment/paypal_applepay.php +++ b/upload/catalog/model/extension/payment/paypal_applepay.php @@ -1,12 +1,13 @@ load->model('extension/payment/paypal'); - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret') && $agree_status) { $this->load->language('extension/payment/paypal'); @@ -22,16 +23,16 @@ public function getMethod($address, $total) { $status = false; } - if ($status) { - $method_data = [ + if ($status) { + $method_data = array( 'code' => 'paypal_applepay', 'title' => $this->language->get('text_paypal_applepay_title'), 'terms' => '', 'sort_order' => $this->config->get('paypal_sort_order') - ]; + ); } } return $method_data; } -} +} \ No newline at end of file diff --git a/upload/catalog/model/extension/payment/paypal_googlepay.php b/upload/catalog/model/extension/payment/paypal_googlepay.php index 1d1730ff..effee570 100644 --- a/upload/catalog/model/extension/payment/paypal_googlepay.php +++ b/upload/catalog/model/extension/payment/paypal_googlepay.php @@ -1,12 +1,13 @@ load->model('extension/payment/paypal'); - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret') && $agree_status) { $this->load->language('extension/payment/paypal'); @@ -23,15 +24,15 @@ public function getMethod($address, $total) { } if ($status) { - $method_data = [ + $method_data = array( 'code' => 'paypal_googlepay', 'title' => $this->language->get('text_paypal_googlepay_title'), 'terms' => '', 'sort_order' => $this->config->get('paypal_sort_order') - ]; + ); } } return $method_data; } -} +} \ No newline at end of file diff --git a/upload/catalog/model/extension/payment/paypal_paylater.php b/upload/catalog/model/extension/payment/paypal_paylater.php index a539bd26..4bc7abb8 100644 --- a/upload/catalog/model/extension/payment/paypal_paylater.php +++ b/upload/catalog/model/extension/payment/paypal_paylater.php @@ -1,12 +1,13 @@ load->model('extension/payment/paypal'); - + $agree_status = $this->model_extension_payment_paypal->getAgreeStatus(); - + if ($this->config->get('paypal_status') && $this->config->get('paypal_client_id') && $this->config->get('paypal_secret') && $agree_status) { $this->load->language('extension/payment/paypal'); @@ -25,26 +26,26 @@ public function getMethod($address, $total) { if ($status) { $_config = new Config(); $_config->load('paypal'); - + $config_setting = $_config->get('paypal_setting'); - + $setting = array_replace_recursive((array)$config_setting, (array)$this->config->get('paypal_setting')); - + if ($setting['message']['checkout']['status'] && ($this->session->data['currency'] == $setting['general']['currency_code'])) { $message = $this->load->view('extension/payment/paypal/message'); } else { $message = ''; } - - $method_data = [ + + $method_data = array( 'code' => 'paypal_paylater', 'title' => $this->language->get('text_paypal_paylater_title') . $message, 'terms' => '', 'sort_order' => $this->config->get('paypal_sort_order') - ]; + ); } } return $method_data; } -} +} \ No newline at end of file diff --git a/upload/catalog/view/javascript/paypal/paypal.js b/upload/catalog/view/javascript/paypal/paypal.js index eabfa718..1737fcce 100644 --- a/upload/catalog/view/javascript/paypal/paypal.js +++ b/upload/catalog/view/javascript/paypal/paypal.js @@ -30,7 +30,24 @@ var PayPalAPI = (function () { return params; }; - var updatePayPalData = function() { + var requestPayPalData = async function(url, data) { + return new Promise((resolve, reject) => { + $.ajax({ + method: 'post', + url: url, + data: data, + dataType: 'json', + success: function(data) { + resolve(data); + }, + error: function(xhr, ajaxOptions, thrownError) { + console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); + } + }); + }); + }; + + var updatePayPalData = async function() { var params = []; var script_file = document.getElementsByTagName('script'); @@ -44,25 +61,19 @@ var PayPalAPI = (function () { paypal_data = params; + if (window.ApplePaySession && window.ApplePaySession?.supportsVersion(4) && ApplePaySession.canMakePayments()) { + paypal_data['applepay'] = true; + } + if (paypal_data['page_code'] == 'product') { paypal_data['product'] = $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea').serialize(); } - $.ajax({ - method: 'post', - url: 'index.php?route=extension/payment/paypal/getData', - data: paypal_data, - dataType: 'json', - async: false, - success: function(json) { - paypal_data = json; + var json = await requestPayPalData('index.php?route=extension/payment/paypal/getData', paypal_data); + + paypal_data = json; - showPayPalAlert(json); - }, - error: function(xhr, ajaxOptions, thrownError) { - console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); - } - }); + showPayPalAlert(json); }; var readyPayPalSDK = function() { @@ -125,8 +136,7 @@ var PayPalAPI = (function () { src_data['merchant-id'] = paypal_data['merchant_id']; src_data['currency'] = paypal_data['currency_code']; src_data['intent'] = paypal_data['transaction_method']; - src_data['locale'] = paypal_data['locale']; - + if (paypal_data['button_enable_funding'] && paypal_data['button_enable_funding'].length) { src_data['enable-funding'] = paypal_data['button_enable_funding'].join(','); } @@ -198,7 +208,7 @@ var PayPalAPI = (function () { label: paypal_data['button_label'], tagline: 'false' }, - createOrder: function() { + createOrder: async function() { paypal_order_id = false; product_data = false; @@ -206,42 +216,22 @@ var PayPalAPI = (function () { product_data = $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea').serialize(); } - $.ajax({ - method: 'post', - url: 'index.php?route=extension/payment/paypal/createOrder', - data: {'page_code': paypal_data['page_code'], 'payment_type': 'button', 'product': product_data}, - dataType: 'json', - async: false, - success: function(json) { - showPayPalAlert(json); - - paypal_order_id = json['paypal_order_id']; - }, - error: function(xhr, ajaxOptions, thrownError) { - console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); - } - }); - + var json = await requestPayPalData('index.php?route=extension/payment/paypal/createOrder', {'page_code': paypal_data['page_code'], 'payment_type': 'button', 'product': product_data}); + + showPayPalAlert(json); + + paypal_order_id = json['paypal_order_id']; + return paypal_order_id; }, - onApprove: function(data) { - $.ajax({ - method: 'post', - url: 'index.php?route=extension/payment/paypal/approveOrder', - data: {'page_code': paypal_data['page_code'], 'payment_type': 'button', 'paypal_order_id': data.orderID}, - dataType: 'json', - async: false, - success: function(json) { - showPayPalAlert(json); + onApprove: async function(data) { + var json = await requestPayPalData('index.php?route=extension/payment/paypal/approveOrder', {'page_code': paypal_data['page_code'], 'payment_type': 'button', 'paypal_order_id': data.orderID}); + + showPayPalAlert(json); - if (json['url']) { - location = json['url']; - } - }, - error: function(xhr, ajaxOptions, thrownError) { - console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); - } - }); + if (json['url']) { + location = json['url']; + } } }; @@ -300,71 +290,50 @@ var PayPalAPI = (function () { $('#paypal_card_tokens_container').append(html); }); - $('#paypal_card_tokens_container').delegate('.card-token-button', 'click', function(event) { + $('#paypal_card_tokens_container').delegate('.card-token-button', 'click', async function(event) { event.preventDefault(); if (!$('#paypal_card_tokens_container').hasClass('disabled')) { var paypal_card_token = $(this).parents('.paypal-card-token'); var card_token_index = $(this).attr('index'); - paypal_order_id = false; - - $.ajax({ - method: 'post', - url: 'index.php?route=extension/payment/paypal/createOrder', - data: {'page_code': paypal_data['page_code'], 'payment_type': 'card', 'index': card_token_index}, - dataType: 'json', - beforeSend: function() { - paypal_card_token.addClass('paypal-spinner'); - $('#paypal_card_tokens_container').addClass('disabled'); - }, - success: function(json) { - showPayPalAlert(json); + paypal_card_token.addClass('paypal-spinner'); + $('#paypal_card_tokens_container').addClass('disabled'); + + var json = await requestPayPalData('index.php?route=extension/payment/paypal/createOrder', {'page_code': paypal_data['page_code'], 'payment_type': 'card', 'index': card_token_index}); - if (json['url']) { - location = json['url']; - } else { - paypal_card_token.removeClass('paypal-spinner'); - $('#paypal_card_tokens_container').removeClass('disabled'); - } - }, - error: function(xhr, ajaxOptions, thrownError) { - console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); - } - }); + showPayPalAlert(json); + + if (json['url']) { + location = json['url']; + } else { + paypal_card_token.removeClass('paypal-spinner'); + $('#paypal_card_tokens_container').removeClass('disabled'); + } } }); - $('#paypal_card_tokens_container').delegate('.card-token-delete-button', 'click', function(event) { + $('#paypal_card_tokens_container').delegate('.card-token-delete-button', 'click', async function(event) { event.preventDefault(); if (!$('#paypal_card_tokens_container').hasClass('disabled')) { var paypal_card_token = $(this).parents('.paypal-card-token'); var card_token_index = $(this).attr('index'); - $.ajax({ - method: 'post', - url: 'index.php?route=extension/payment/paypal/deleteCustomerToken', - data: {'index': card_token_index}, - dataType: 'json', - beforeSend: function() { - paypal_card_token.addClass('paypal-spinner'); - $('#paypal_card_tokens_container').addClass('disabled'); - }, - success: function(json) { - showPayPalAlert(json); + paypal_card_token.addClass('paypal-spinner'); + $('#paypal_card_tokens_container').addClass('disabled'); + + var json = await requestPayPalData('index.php?route=extension/payment/paypal/deleteCustomerToken', {'index': card_token_index}); + + showPayPalAlert(json); - if (json['success']) { - paypal_card_token.remove(); - } else { - paypal_card_token.removeClass('paypal-spinner'); - $('#paypal_card_tokens_container').removeClass('disabled'); - } - }, - error: function(xhr, ajaxOptions, thrownError) { - console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); - } - }); + if (json['success']) { + paypal_card_token.remove(); + } else { + paypal_card_token.removeClass('paypal-spinner'); + } + + $('#paypal_card_tokens_container').removeClass('disabled'); } }); } @@ -390,54 +359,34 @@ var PayPalAPI = (function () { 'padding': '0.75rem 0.75rem', } }, - createOrder: function() { + createOrder: async function() { paypal_order_id = false; var card_save = ($('#paypal_card_form #paypal_card_save:checked').length ? $('#paypal_card_form #paypal_card_save:checked').val() : 0); - $.ajax({ - method: 'post', - url: 'index.php?route=extension/payment/paypal/createOrder', - data: {'page_code': paypal_data['page_code'], 'payment_type': 'card', 'card_save': card_save}, - dataType: 'json', - async: false, - success: function(json) { - showPayPalAlert(json); + var json = await requestPayPalData('index.php?route=extension/payment/paypal/createOrder', {'page_code': paypal_data['page_code'], 'payment_type': 'card', 'card_save': card_save}); + + showPayPalAlert(json); - paypal_order_id = json['paypal_order_id']; - }, - error: function(xhr, ajaxOptions, thrownError) { - console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); - } - }); - + paypal_order_id = json['paypal_order_id']; + return paypal_order_id; }, - onApprove: function(data) { + onApprove: async function(data) { var card_save = ($('#paypal_card_form #paypal_card_save:checked').length ? $('#paypal_card_form #paypal_card_save:checked').val() : 0); var card_type = $('#paypal_card_form').attr('card_type'); var card_nice_type = $('#paypal_card_form').attr('card_nice_type'); - $.ajax({ - method: 'post', - url: 'index.php?route=extension/payment/paypal/approveOrder', - data: {'page_code': paypal_data['page_code'], 'payment_type': 'card', 'card_save': card_save, 'card_type': card_type, 'card_nice_type': card_nice_type, 'paypal_order_id': data.orderID}, - dataType: 'json', - async: false, - success: function(json) { - showPayPalAlert(json); + var json = await requestPayPalData('index.php?route=extension/payment/paypal/approveOrder', {'page_code': paypal_data['page_code'], 'payment_type': 'card', 'card_save': card_save, 'card_type': card_type, 'card_nice_type': card_nice_type, 'paypal_order_id': data.orderID}); + + showPayPalAlert(json); - if (json['url']) { - location = json['url']; - } else { - $('#paypal_card_container').removeClass('paypal-spinner'); - $('#paypal_card_button').prop('disabled', false).button('reset'); - } - }, - error: function(xhr, ajaxOptions, thrownError) { - console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); - } - }); + if (json['url']) { + location = json['url']; + } else { + $('#paypal_card_container').removeClass('paypal-spinner'); + $('#paypal_card_button').prop('disabled', false).button('reset'); + } }, inputEvents: { onChange: function(data) { @@ -551,8 +500,8 @@ var PayPalAPI = (function () { if (paypal_data['page_code'] == 'product') { $('[name^="option"], [name="quantity"]').on('change', function(event) { - setTimeout(function() { - updatePayPalData(); + setTimeout(async function() { + await updatePayPalData(); if (paypal_message) { paypal_message.setAttribute('data-pp-amount', paypal_data['message_amount']); @@ -583,21 +532,11 @@ var PayPalAPI = (function () { product_data = $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea').serialize(); } - $.ajax({ - method: 'post', - url: 'index.php?route=extension/payment/paypal/createOrder', - data: {'page_code': paypal_data['page_code'], 'payment_type': 'googlepay_button', 'product': product_data}, - dataType: 'json', - async: false, - success: function(json) { - showPayPalAlert(json); + var json = await requestPayPalData('index.php?route=extension/payment/paypal/createOrder', {'page_code': paypal_data['page_code'], 'payment_type': 'googlepay_button', 'product': product_data}); + + showPayPalAlert(json); - paypal_order_id = json['paypal_order_id']; - }, - error: function(xhr, ajaxOptions, thrownError) { - console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); - } - }); + paypal_order_id = json['paypal_order_id']; paymentData.paymentMethodData.info.billingAddress.phoneNumber = paymentData.paymentMethodData.info.billingAddress.phoneNumber.replace('+', ''); @@ -610,46 +549,26 @@ var PayPalAPI = (function () { console.log('Confirm Payment Completed Payer Action Required'); PayPalSDK.Googlepay().initiatePayerAction({orderId: paypal_order_id}).then(async () => { - $.ajax({ - method: 'post', - url: 'index.php?route=extension/payment/paypal/approveOrder', - data: {'page_code': paypal_data['page_code'], 'payment_type': 'googlepay_button', 'paypal_order_id': paypal_order_id, 'payment_data': JSON.stringify(paymentData)}, - dataType: 'json', - async: false, - success: function(json) { - showPayPalAlert(json); + var json = await requestPayPalData('index.php?route=extension/payment/paypal/approveOrder', {'page_code': paypal_data['page_code'], 'payment_type': 'googlepay_button', 'paypal_order_id': paypal_order_id, 'payment_data': JSON.stringify(paymentData)}); + + showPayPalAlert(json); - if (json['url']) { - location = json['url']; - } - }, - error: function(xhr, ajaxOptions, thrownError) { - console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); - } - }); + if (json['url']) { + location = json['url']; + } }); resolve({transactionState: 'SUCCESS'}); } else if (confirmOrderResponse.status === 'APPROVED') { console.log('Confirm Payment Approved'); - $.ajax({ - method: 'post', - url: 'index.php?route=extension/payment/paypal/approveOrder', - data: {'page_code': paypal_data['page_code'], 'payment_type': 'googlepay_button', 'paypal_order_id': paypal_order_id, 'payment_data': JSON.stringify(paymentData)}, - dataType: 'json', - async: false, - success: function(json) { - showPayPalAlert(json); + var json = await requestPayPalData('index.php?route=extension/payment/paypal/approveOrder', {'page_code': paypal_data['page_code'], 'payment_type': 'googlepay_button', 'paypal_order_id': paypal_order_id, 'payment_data': JSON.stringify(paymentData)}); + + showPayPalAlert(json); - if (json['url']) { - location = json['url']; - } - }, - error: function(xhr, ajaxOptions, thrownError) { - console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); - } - }); + if (json['url']) { + location = json['url']; + } resolve({transactionState: 'SUCCESS'}); } else { @@ -870,21 +789,11 @@ var PayPalAPI = (function () { product_data = $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea').serialize(); } - $.ajax({ - method: 'post', - url: 'index.php?route=extension/payment/paypal/createOrder', - data: {'page_code': paypal_data['page_code'], 'payment_type': 'applepay_button', 'product': product_data}, - dataType: 'json', - async: false, - success: function(json) { - showPayPalAlert(json); + var json = await requestPayPalData('index.php?route=extension/payment/paypal/createOrder', {'page_code': paypal_data['page_code'], 'payment_type': 'applepay_button', 'product': product_data}); + + showPayPalAlert(json); - paypal_order_id = json['paypal_order_id']; - }, - error: function(xhr, ajaxOptions, thrownError) { - console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); - } - }); + paypal_order_id = json['paypal_order_id']; event.payment.shippingContact.phoneNumber = event.payment.shippingContact.phoneNumber.replace('+', ''); @@ -895,23 +804,13 @@ var PayPalAPI = (function () { shippingContact: event.payment.shippingContact }); - $.ajax({ - method: 'post', - url: 'index.php?route=extension/payment/paypal/approveOrder', - data: {'page_code': paypal_data['page_code'], 'payment_type': 'applepay_button', 'paypal_order_id': paypal_order_id, 'payment_data': JSON.stringify(event.payment)}, - dataType: 'json', - async: false, - success: function(json) { - showPayPalAlert(json); + var json = await requestPayPalData('index.php?route=extension/payment/paypal/approveOrder', {'page_code': paypal_data['page_code'], 'payment_type': 'applepay_button', 'paypal_order_id': paypal_order_id, 'payment_data': JSON.stringify(event.payment)}); + + showPayPalAlert(json); - if (json['url']) { - location = json['url']; - } - }, - error: function(xhr, ajaxOptions, thrownError) { - console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); - } - }); + if (json['url']) { + location = json['url']; + } session.completePayment({ status: window.ApplePaySession.STATUS_SUCCESS @@ -936,8 +835,8 @@ var PayPalAPI = (function () { $('#applepay_button_container').removeClass('paypal-spinner'); }; - var init = function(callback = '') { - updatePayPalData(); + var init = async function(callback = '') { + await updatePayPalData(); paypal_callback = callback; diff --git a/upload/system/config/paypal.php b/upload/system/config/paypal.php index a9d5f2e4..1dcb8f27 100644 --- a/upload/system/config/paypal.php +++ b/upload/system/config/paypal.php @@ -1,1085 +1,1087 @@ - '3.1.2', - 'partner' => [ - 'production' => [ - 'partner_id' => 'TY2Q25KP2PX9L', - 'client_id' => 'AbjxI4a9fMnew8UOMoDFVwSh7h1aeOBaXpd2wcccAnuqecijKIylRnNguGRWDrEPrTYraBQApf_-O3_4', + '3.1.6', + 'partner' => array( + 'production' => array( + 'partner_id' => 'TY2Q25KP2PX9L', + 'client_id' => 'AbjxI4a9fMnew8UOMoDFVwSh7h1aeOBaXpd2wcccAnuqecijKIylRnNguGRWDrEPrTYraBQApf_-O3_4', 'partner_attribution_id' => 'OPENCARTLIMITED_Cart_OpenCartPCP' - ], - 'sandbox' => [ - 'partner_id' => 'EJNHWRJJNB38L', - 'client_id' => 'AfeIgIr-fIcEucsVXvdq21Ufu0wAALWhgJdVF4ItUK1IZFA9I4JIRdfyJ9vWrd9oi0B6mBGtJYDrlYsG', + ), + 'sandbox' => array( + 'partner_id' => 'EJNHWRJJNB38L', + 'client_id' => 'AfeIgIr-fIcEucsVXvdq21Ufu0wAALWhgJdVF4ItUK1IZFA9I4JIRdfyJ9vWrd9oi0B6mBGtJYDrlYsG', 'partner_attribution_id' => 'OPENCARTLIMITED_Cart_OpenCartPCP' - ] - ], - 'general' => [ - 'debug' => false, - 'vault_status' => false, - 'checkout_mode' => 'multi_button', - 'checkout_route' => 'checkout/checkout', - 'transaction_method' => 'capture', + ) + ), + 'general' => array( + 'debug' => false, + 'vault_status' => false, + 'checkout_mode' => 'multi_button', + 'checkout_route' => 'checkout/checkout', + 'transaction_method' => 'capture', 'sale_analytics_range' => 'month', - 'country_code' => 'US', - 'currency_code' => 'USD', - 'currency_value' => '1', - 'card_currency_code' => 'USD', - 'card_currency_value' => '1', - 'order_history_token' => '', - 'callback_token' => '', - 'webhook_token' => '', - 'cron_token' => '' - ], - 'button' => [ - 'checkout' => [ + 'country_code' => 'US', + 'currency_code' => 'USD', + 'currency_value' => '1', + 'card_currency_code' => 'USD', + 'card_currency_value' => '1', + 'order_history_token' => '', + 'callback_token' => '', + 'webhook_token' => '', + 'cron_token' => '' + ), + 'button' => array( + 'checkout' => array( 'page_code' => 'checkout', 'page_name' => 'text_checkout', - 'status' => true, - 'align' => 'right', - 'size' => 'large', - 'color' => 'gold', - 'shape' => 'rect', - 'label' => 'paypal', - 'funding' => [ - 'paylater' => 1, - 'card' => 0, - 'bancontact' => 0, - 'blik' => 0, - 'eps' => 0, - 'giropay' => 0, - 'ideal' => 0, + 'status' => true, + 'align' => 'right', + 'size' => 'large', + 'color' => 'gold', + 'shape' => 'rect', + 'label' => 'paypal', + 'funding' => array( + 'paylater' => 1, + 'card' => 0, + 'bancontact' => 0, + 'blik' => 0, + 'eps' => 0, + 'giropay' => 0, + 'ideal' => 0, 'mercadopago' => 0, - 'mybank' => 0, - 'p24' => 0, - 'sepa' => 0, - 'venmo' => 0 - ] - ], - 'cart' => [ - 'page_code' => 'cart', - 'page_name' => 'text_cart', - 'status' => true, - 'insert_tag' => '#content', + 'mybank' => 0, + 'p24' => 0, + 'sepa' => 0, + 'venmo' => 0 + ) + ), + 'cart' => array( + 'page_code' => 'cart', + 'page_name' => 'text_cart', + 'status' => true, + 'insert_tag' => '#content', 'insert_type' => 'append', - 'align' => 'right', - 'size' => 'large', - 'color' => 'gold', - 'shape' => 'rect', - 'label' => 'paypal', - 'funding' => [ - 'paylater' => 1, - 'card' => 2, - 'bancontact' => 2, - 'blik' => 2, - 'eps' => 2, - 'giropay' => 2, - 'ideal' => 2, + 'align' => 'right', + 'size' => 'large', + 'color' => 'gold', + 'shape' => 'rect', + 'label' => 'paypal', + 'funding' => array( + 'paylater' => 1, + 'card' => 2, + 'bancontact' => 2, + 'blik' => 2, + 'eps' => 2, + 'giropay' => 2, + 'ideal' => 2, 'mercadopago' => 2, - 'mybank' => 2, - 'p24' => 2, - 'sepa' => 2, - 'venmo' => 2 - ] - ], - 'product' => [ - 'page_code' => 'product', - 'page_name' => 'text_product', - 'status' => true, - 'insert_tag' => '#content #product #button-cart', + 'mybank' => 2, + 'p24' => 2, + 'sepa' => 2, + 'venmo' => 2 + ) + ), + 'product' => array( + 'page_code' => 'product', + 'page_name' => 'text_product', + 'status' => true, + 'insert_tag' => '#content #product #button-cart', 'insert_type' => 'after', - 'align' => 'center', - 'size' => 'responsive', - 'color' => 'gold', - 'shape' => 'rect', - 'label' => 'paypal', - 'funding' => [ - 'paylater' => 1, - 'card' => 2, - 'bancontact' => 2, - 'blik' => 2, - 'eps' => 2, - 'giropay' => 2, - 'ideal' => 2, + 'align' => 'center', + 'size' => 'responsive', + 'color' => 'gold', + 'shape' => 'rect', + 'label' => 'paypal', + 'funding' => array( + 'paylater' => 1, + 'card' => 2, + 'bancontact' => 2, + 'blik' => 2, + 'eps' => 2, + 'giropay' => 2, + 'ideal' => 2, 'mercadopago' => 2, - 'mybank' => 2, - 'p24' => 2, - 'sepa' => 2, - 'venmo' => 2 - ] - ] - ], - 'googlepay_button' => [ - 'checkout' => [ + 'mybank' => 2, + 'p24' => 2, + 'sepa' => 2, + 'venmo' => 2 + ) + ) + ), + 'googlepay_button' => array( + 'checkout' => array( 'page_code' => 'checkout', 'page_name' => 'text_checkout', - 'status' => false, - 'align' => 'right', - 'size' => 'large', - 'color' => 'black', - 'shape' => 'rect', - 'type' => 'buy' - ], - 'cart' => [ - 'page_code' => 'cart', - 'page_name' => 'text_cart', - 'status' => false, - 'insert_tag' => '#content', + 'status' => false, + 'align' => 'right', + 'size' => 'large', + 'color' => 'black', + 'shape' => 'rect', + 'type' => 'buy' + ), + 'cart' => array( + 'page_code' => 'cart', + 'page_name' => 'text_cart', + 'status' => false, + 'insert_tag' => '#content', 'insert_type' => 'append', - 'align' => 'right', - 'size' => 'large', - 'color' => 'black', - 'shape' => 'rect', - 'type' => 'buy' - ], - 'product' => [ - 'page_code' => 'product', - 'page_name' => 'text_product', - 'status' => false, - 'insert_tag' => '#content #product #button-cart', + 'align' => 'right', + 'size' => 'large', + 'color' => 'black', + 'shape' => 'rect', + 'type' => 'buy' + ), + 'product' => array( + 'page_code' => 'product', + 'page_name' => 'text_product', + 'status' => false, + 'insert_tag' => '#content #product #button-cart', 'insert_type' => 'after', - 'align' => 'center', - 'size' => 'responsive', - 'color' => 'black', - 'shape' => 'rect', - 'type' => 'buy' - ] - ], - 'applepay_button' => [ - 'checkout' => [ + 'align' => 'center', + 'size' => 'responsive', + 'color' => 'black', + 'shape' => 'rect', + 'type' => 'buy' + ) + ), + 'applepay_button' => array( + 'checkout' => array( 'page_code' => 'checkout', 'page_name' => 'text_checkout', - 'status' => false, - 'align' => 'right', - 'size' => 'large', - 'color' => 'black', - 'shape' => 'rect', - 'type' => 'buy', - ], - 'cart' => [ - 'page_code' => 'cart', - 'page_name' => 'text_cart', - 'status' => false, - 'insert_tag' => '#content', + 'status' => false, + 'align' => 'right', + 'size' => 'large', + 'color' => 'black', + 'shape' => 'rect', + 'type' => 'buy', + ), + 'cart' => array( + 'page_code' => 'cart', + 'page_name' => 'text_cart', + 'status' => false, + 'insert_tag' => '#content', 'insert_type' => 'append', - 'align' => 'right', - 'size' => 'large', - 'color' => 'black', - 'shape' => 'rect', - 'type' => 'buy', - ], - 'product' => [ - 'page_code' => 'product', - 'page_name' => 'text_product', - 'status' => false, - 'insert_tag' => '#content #product #button-cart', + 'align' => 'right', + 'size' => 'large', + 'color' => 'black', + 'shape' => 'rect', + 'type' => 'buy', + ), + 'product' => array( + 'page_code' => 'product', + 'page_name' => 'text_product', + 'status' => false, + 'insert_tag' => '#content #product #button-cart', 'insert_type' => 'after', - 'align' => 'center', - 'size' => 'responsive', - 'color' => 'black', - 'shape' => 'rect', - 'type' => 'buy', - ] - ], - 'card' => [ - 'status' => true, - 'align' => 'right', - 'size' => 'large', - 'secure_method' => 'sca_when_required', - 'secure_scenario' => [ - 'failed_authentication' => 0, - 'rejected_authentication' => 0, + 'align' => 'center', + 'size' => 'responsive', + 'color' => 'black', + 'shape' => 'rect', + 'type' => 'buy', + ) + ), + 'card' => array( + 'status' => true, + 'align' => 'right', + 'size' => 'large', + 'secure_method' => 'sca_when_required', + 'secure_scenario' => array( + 'failed_authentication' => 0, + 'rejected_authentication' => 0, 'attempted_authentication' => 1, - 'unable_authentication' => 0, + 'unable_authentication' => 0, 'challenge_authentication' => 0, - 'card_ineligible' => 1, - 'system_unavailable' => 0, - 'system_bypassed' => 1 - ] - ], - 'message' => [ - 'checkout' => [ - 'page_code' => 'checkout', - 'page_name' => 'text_checkout', - 'status' => true, - 'layout' => 'text', + 'card_ineligible' => 1, + 'system_unavailable' => 0, + 'system_bypassed' => 1 + ) + ), + 'message' => array( + 'checkout' => array( + 'page_code' => 'checkout', + 'page_name' => 'text_checkout', + 'status' => true, + 'layout' => 'text', 'logo_position' => 'left', - 'logo_type' => 'primary', - 'text_color' => 'black', - 'text_size' => '12', - 'flex_color' => 'blue', - 'flex_ratio' => '8x1' - ], - 'cart' => [ - 'page_code' => 'cart', - 'page_name' => 'text_cart', - 'status' => true, - 'insert_tag' => '#content form', - 'insert_type' => 'after', - 'layout' => 'text', - 'logo_type' => 'primary', + 'logo_type' => 'primary', + 'text_color' => 'black', + 'text_size' => '12', + 'flex_color' => 'blue', + 'flex_ratio' => '8x1' + ), + 'cart' => array( + 'page_code' => 'cart', + 'page_name' => 'text_cart', + 'status' => true, + 'insert_tag' => '#content form', + 'insert_type' => 'after', + 'layout' => 'text', + 'logo_type' => 'primary', 'logo_position' => 'left', - 'text_color' => 'black', - 'text_size' => '12', - 'flex_color' => 'blue', - 'flex_ratio' => '8x1' - ], - 'product' => [ - 'page_code' => 'product', - 'page_name' => 'text_product', - 'status' => true, - 'insert_tag' => '#content #product', - 'insert_type' => 'before', - 'layout' => 'text', - 'logo_type' => 'primary', + 'text_color' => 'black', + 'text_size' => '12', + 'flex_color' => 'blue', + 'flex_ratio' => '8x1' + ), + 'product' => array( + 'page_code' => 'product', + 'page_name' => 'text_product', + 'status' => true, + 'insert_tag' => '#content #product', + 'insert_type' => 'before', + 'layout' => 'text', + 'logo_type' => 'primary', 'logo_position' => 'left', - 'text_color' => 'black', - 'text_size' => '12', - 'flex_color' => 'blue', - 'flex_ratio' => '8x1' - ], - 'home' => [ - 'page_code' => 'home', - 'page_name' => 'text_home', - 'status' => true, - 'insert_tag' => '#common-home', - 'insert_type' => 'prepend', - 'layout' => 'flex', - 'logo_type' => 'primary', + 'text_color' => 'black', + 'text_size' => '12', + 'flex_color' => 'blue', + 'flex_ratio' => '8x1' + ), + 'home' => array( + 'page_code' => 'home', + 'page_name' => 'text_home', + 'status' => true, + 'insert_tag' => '.common-home #content', + 'insert_type' => 'prepend', + 'layout' => 'flex', + 'logo_type' => 'primary', 'logo_position' => 'left', - 'text_color' => 'black', - 'text_size' => '12', - 'flex_color' => 'blue', - 'flex_ratio' => '20x1' - ] - ], - 'order_status' => [ - 'completed' => [ + 'text_color' => 'black', + 'text_size' => '12', + 'flex_color' => 'blue', + 'flex_ratio' => '20x1' + ) + ), + 'order_status' => array( + 'completed' => array( 'code' => 'completed', 'name' => 'text_completed_status', - 'id' => 5 - ], - 'denied' => [ + 'id' => 5 + ), + 'denied' => array( 'code' => 'denied', 'name' => 'text_denied_status', - 'id' => 8 - ], - 'failed' => [ + 'id' => 8 + ), + 'failed' => array( 'code' => 'failed', 'name' => 'text_failed_status', - 'id' => 10 - ], - 'pending' => [ + 'id' => 10 + ), + 'pending' => array( 'code' => 'pending', 'name' => 'text_pending_status', - 'id' => 1 - ], - 'partially_captured' => [ + 'id' => 1 + ), + 'partially_captured' => array( 'code' => 'partially_captured', 'name' => 'text_partially_captured_status', - 'id' => 1 - ], - 'partially_refunded' => [ + 'id' => 1 + ), + 'partially_refunded' => array( 'code' => 'partially_refunded', 'name' => 'text_partially_refunded_status', - 'id' => 11 - ], - 'refunded' => [ + 'id' => 11 + ), + 'refunded' => array( 'code' => 'refunded', 'name' => 'text_refunded_status', - 'id' => 11 - ], - 'reversed' => [ + 'id' => 11 + ), + 'reversed' => array( 'code' => 'reversed', 'name' => 'text_reversed_status', - 'id' => 12 - ], - 'voided' => [ + 'id' => 12 + ), + 'voided' => array( 'code' => 'voided', 'name' => 'text_voided_status', - 'id' => 16 - ], - 'shipped' => [ + 'id' => 16 + ), + 'shipped' => array( 'code' => 'shipped', 'name' => 'text_shipped_status', - 'id' => 3 - ] - ], - 'contact' => [ - 'oid' => '00D300000000LaY', - 'retURL' => 'https://www.opencart.com/', + 'id' => 3 + ) + ), + 'final_order_status' => array(), + 'contact' => array( + 'oid' => '00D300000000LaY', + 'retURL' => 'https://www.opencart.com/', 'Vendor_Partner_ID_VPID_MAM__c' => '0018000000LjXtY', - 'Campaign_ID__c' => '7012E000001XNG7', - 'lead_source' => 'Partner', - 'recordType' => '0122E000000Qq4v', - 'company' => '', - 'first_name' => '', - 'last_name' => '', - 'email' => '', - 'url' => '', - 'phone' => '', - 'country' => '', - '00N30000000gJEZ' => '', - '00N2E00000II4xQ' => '', - '00N2E00000II4xP' => false, - '00N2E00000II4xO' => '', - '00N80000004IGsC' => '' - ], - 'sale_analytics_range' => [ - 'day' => [ + 'Campaign_ID__c' => '7012E000001XNG7', + 'lead_source' => 'Partner', + 'recordType' => '0122E000000Qq4v', + 'company' => '', + 'first_name' => '', + 'last_name' => '', + 'email' => '', + 'url' => '', + 'phone' => '', + 'country' => '', + '00N30000000gJEZ' => '', + '00N2E00000II4xQ' => '', + '00N2E00000II4xP' => false, + '00N2E00000II4xO' => '', + '00N80000004IGsC' => '' + ), + 'sale_analytics_range' => array( + 'day' => array( 'code' => 'day', 'name' => 'text_day' - ], - 'week' => [ + ), + 'week' => array( 'code' => 'week', 'name' => 'text_week' - ], - 'month' => [ + ), + 'month' => array( 'code' => 'month', 'name' => 'text_month' - ], - 'year' => [ + ), + 'year' => array( 'code' => 'year', 'name' => 'text_year' - ] - ], - 'checkout_mode' => [ - 'multi_button' => [ + ) + ), + 'checkout_mode' => array( + 'multi_button' => array( 'code' => 'multi_button', 'name' => 'text_multi_button' - ], - 'one_button' => [ + ), + 'one_button' => array( 'code' => 'one_button', 'name' => 'text_one_button' - ] - ], - 'transaction_method' => [ - 'authorize' => [ + ) + ), + 'transaction_method' => array( + 'authorize' => array( 'code' => 'authorize', 'name' => 'text_authorization' - ], - 'capture' => [ + ), + 'capture' => array( 'code' => 'capture', 'name' => 'text_sale' - ] - ], - 'paylater_country' => [ - 'US' => [ + ) + ), + 'paylater_country' => array( + 'US' => array( 'code' => 'US' - ], - 'GB' => [ + ), + 'GB' => array( 'code' => 'GB' - ], - 'FR' => [ + ), + 'FR' => array( 'code' => 'FR' - ], - 'DE' => [ + ), + 'DE' => array( 'code' => 'DE' - ], - 'IT' => [ + ), + 'IT' => array( 'code' => 'IT' - ], - 'ES' => [ + ), + 'ES' => array( 'code' => 'ES' - ], - 'AU' => [ + ), + 'AU' => array( 'code' => 'AU' - ] - ], - 'currency' => [ - 'AUD' => [ - 'code' => 'AUD', - 'name' => 'text_currency_aud', + ) + ), + 'currency' => array( + 'AUD' => array( + 'code' => 'AUD', + 'name' => 'text_currency_aud', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ], - 'BRL' => [ - 'code' => 'BRL', - 'name' => 'text_currency_brl', + 'status' => true, + 'card_status' => true + ), + 'BRL' => array( + 'code' => 'BRL', + 'name' => 'text_currency_brl', 'decimal_place' => 2, - 'status' => true, - 'card_status' => false - ], - 'CAD' => [ - 'code' => 'CAD', - 'name' => 'text_currency_cad', + 'status' => true, + 'card_status' => false + ), + 'CAD' => array( + 'code' => 'CAD', + 'name' => 'text_currency_cad', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ], - 'CZK' => [ - 'code' => 'CZK', - 'name' => 'text_currency_czk', + 'status' => true, + 'card_status' => true + ), + 'CZK' => array( + 'code' => 'CZK', + 'name' => 'text_currency_czk', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ], - 'DKK' => [ - 'code' => 'DKK', - 'name' => 'text_currency_dkk', + 'status' => true, + 'card_status' => true + ), + 'DKK' => array( + 'code' => 'DKK', + 'name' => 'text_currency_dkk', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ], - 'EUR' => [ - 'code' => 'EUR', - 'name' => 'text_currency_eur', + 'status' => true, + 'card_status' => true + ), + 'EUR' => array( + 'code' => 'EUR', + 'name' => 'text_currency_eur', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ], - 'HKD' => [ - 'code' => 'HKD', - 'name' => 'text_currency_hkd', + 'status' => true, + 'card_status' => true + ), + 'HKD' => array( + 'code' => 'HKD', + 'name' => 'text_currency_hkd', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ], - 'HUF' => [ - 'code' => 'HUF', - 'name' => 'text_currency_huf', + 'status' => true, + 'card_status' => true + ), + 'HUF' => array( + 'code' => 'HUF', + 'name' => 'text_currency_huf', 'decimal_place' => 0, - 'status' => true, - 'card_status' => true - ], - 'INR' => [ - 'code' => 'INR', - 'name' => 'text_currency_inr', + 'status' => true, + 'card_status' => true + ), + 'INR' => array( + 'code' => 'INR', + 'name' => 'text_currency_inr', 'decimal_place' => 2, - 'status' => true, - 'card_status' => false - ], - 'ILS' => [ - 'code' => 'ILS', - 'name' => 'text_currency_ils', + 'status' => true, + 'card_status' => false + ), + 'ILS' => array( + 'code' => 'ILS', + 'name' => 'text_currency_ils', 'decimal_place' => 2, - 'status' => true, - 'card_status' => false - ], - 'JPY' => [ - 'code' => 'JPY', - 'name' => 'text_currency_jpy', + 'status' => true, + 'card_status' => false + ), + 'JPY' => array( + 'code' => 'JPY', + 'name' => 'text_currency_jpy', 'decimal_place' => 0, - 'status' => true, - 'card_status' => true - ], - 'MYR' => [ - 'code' => 'MYR', - 'name' => 'text_currency_myr', + 'status' => true, + 'card_status' => true + ), + 'MYR' => array( + 'code' => 'MYR', + 'name' => 'text_currency_myr', 'decimal_place' => 2, - 'status' => true, - 'card_status' => false - ], - 'MXN' => [ - 'code' => 'MXN', - 'name' => 'text_currency_mxn', + 'status' => true, + 'card_status' => false + ), + 'MXN' => array( + 'code' => 'MXN', + 'name' => 'text_currency_mxn', 'decimal_place' => 2, - 'status' => true, - 'card_status' => false - ], - 'TWD' => [ - 'code' => 'TWD', - 'name' => 'text_currency_twd', + 'status' => true, + 'card_status' => false + ), + 'TWD' => array( + 'code' => 'TWD', + 'name' => 'text_currency_twd', 'decimal_place' => 0, - 'status' => true, - 'card_status' => false - ], - 'NZD' => [ - 'code' => 'NZD', - 'name' => 'text_currency_nzd', + 'status' => true, + 'card_status' => false + ), + 'NZD' => array( + 'code' => 'NZD', + 'name' => 'text_currency_nzd', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ], - 'NOK' => [ - 'code' => 'NOK', - 'name' => 'text_currency_nok', + 'status' => true, + 'card_status' => true + ), + 'NOK' => array( + 'code' => 'NOK', + 'name' => 'text_currency_nok', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ], - 'PHP' => [ - 'code' => 'PHP', - 'name' => 'text_currency_php', + 'status' => true, + 'card_status' => true + ), + 'PHP' => array( + 'code' => 'PHP', + 'name' => 'text_currency_php', 'decimal_place' => 2, - 'status' => true, - 'card_status' => false - ], - 'PLN' => [ - 'code' => 'PLN', - 'name' => 'text_currency_pln', + 'status' => true, + 'card_status' => false + ), + 'PLN' => array( + 'code' => 'PLN', + 'name' => 'text_currency_pln', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ], - 'GBP' => [ - 'code' => 'GBP', - 'name' => 'text_currency_gbp', + 'status' => true, + 'card_status' => true + ), + 'GBP' => array( + 'code' => 'GBP', + 'name' => 'text_currency_gbp', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ], - 'RUB' => [ - 'code' => 'RUB', - 'name' => 'text_currency_rub', + 'status' => true, + 'card_status' => true + ), + 'RUB' => array( + 'code' => 'RUB', + 'name' => 'text_currency_rub', 'decimal_place' => 2, - 'status' => true, - 'card_status' => false - ], - 'SGD' => [ - 'code' => 'SGD', - 'name' => 'text_currency_sgd', + 'status' => true, + 'card_status' => false + ), + 'SGD' => array( + 'code' => 'SGD', + 'name' => 'text_currency_sgd', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ], - 'SEK' => [ - 'code' => 'SEK', - 'name' => 'text_currency_sek', + 'status' => true, + 'card_status' => true + ), + 'SEK' => array( + 'code' => 'SEK', + 'name' => 'text_currency_sek', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ], - 'CHF' => [ - 'code' => 'CHF', - 'name' => 'text_currency_chf', + 'status' => true, + 'card_status' => true + ), + 'CHF' => array( + 'code' => 'CHF', + 'name' => 'text_currency_chf', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ], - 'THB' => [ - 'code' => 'THB', - 'name' => 'text_currency_thb', + 'status' => true, + 'card_status' => true + ), + 'THB' => array( + 'code' => 'THB', + 'name' => 'text_currency_thb', 'decimal_place' => 2, - 'status' => true, - 'card_status' => false - ], - 'USD' => [ - 'code' => 'USD', - 'name' => 'text_currency_usd', + 'status' => true, + 'card_status' => false + ), + 'USD' => array( + 'code' => 'USD', + 'name' => 'text_currency_usd', 'decimal_place' => 2, - 'status' => true, - 'card_status' => true - ] - ], - 'button_insert_type' => [ - 'into_begin' => [ - 'code' => 'prepend', - 'name' => 'text_insert_prepend' - ], - 'into_end' => [ - 'code' => 'append', - 'name' => 'text_insert_append' - ], - 'before' => [ - 'code' => 'before', - 'name' => 'text_insert_before' - ], - 'after' => [ - 'code' => 'after', - 'name' => 'text_insert_after' - ] - ], - 'button_align' => [ - 'left' => [ + 'status' => true, + 'card_status' => true + ) + ), + 'button_insert_type' => array( + 'into_begin' => array( + 'code' => 'prepend', + 'name' => 'text_insert_prepend' + ), + 'into_end' => array( + 'code' => 'append', + 'name' => 'text_insert_append' + ), + 'before' => array( + 'code' => 'before', + 'name' => 'text_insert_before' + ), + 'after' => array( + 'code' => 'after', + 'name' => 'text_insert_after' + ) + ), + 'button_align' => array( + 'left' => array( 'code' => 'left', 'name' => 'text_align_left' - ], - 'center' => [ + ), + 'center' => array( 'code' => 'center', 'name' => 'text_align_center' - ], - 'right' => [ + ), + 'right' => array( 'code' => 'right', 'name' => 'text_align_right' - ] - ], - 'button_size' => [ - 'small' => [ + ) + ), + 'button_size' => array( + 'small' => array( 'code' => 'small', 'name' => 'text_small' - ], - 'medium' => [ + ), + 'medium' => array( 'code' => 'medium', 'name' => 'text_medium' - ], - 'large' => [ + ), + 'large' => array( 'code' => 'large', 'name' => 'text_large' - ], - 'responsive' => [ + ), + 'responsive' => array( 'code' => 'responsive', 'name' => 'text_responsive' - ] - ], - 'button_color' => [ - 'gold' => [ + ) + ), + 'button_color' => array( + 'gold' => array( 'code' => 'gold', 'name' => 'text_gold' - ], - 'blue' => [ + ), + 'blue' => array( 'code' => 'blue', 'name' => 'text_blue' - ], - 'silver' => [ + ), + 'silver' => array( 'code' => 'silver', 'name' => 'text_silver' - ], - 'white' => [ + ), + 'white' => array( 'code' => 'white', 'name' => 'text_white' - ], - 'black' => [ + ), + 'black' => array( 'code' => 'black', 'name' => 'text_black' - ] - ], - 'button_shape' => [ - 'pill' => [ + ) + ), + 'button_shape' => array( + 'pill' => array( 'code' => 'pill', 'name' => 'text_pill' - ], - 'rect' => [ + ), + 'rect' => array( 'code' => 'rect', 'name' => 'text_rect' - ] - ], - 'button_label' => [ - 'checkout' => [ + ) + ), + 'button_label' => array( + 'checkout' => array( 'code' => 'checkout', 'name' => 'text_checkout' - ], - 'pay' => [ + ), + 'pay' => array( 'code' => 'pay', 'name' => 'text_pay' - ], - 'buynow' => [ + ), + 'buynow' => array( 'code' => 'buynow', 'name' => 'text_buy_now' - ], - 'paypal' => [ + ), + 'paypal' => array( 'code' => 'paypal', 'name' => 'text_pay_pal' - ], - 'installment' => [ + ), + 'installment' => array( 'code' => 'installment', 'name' => 'text_installment' - ] - ], - 'button_tagline' => [ - 'true' => [ + ) + ), + 'button_tagline' => array( + 'true' => array( 'code' => 'true', 'name' => 'text_yes' - ], - 'false' => [ + ), + 'false' => array( 'code' => 'false', 'name' => 'text_no' - ], - ], - 'button_width' => [ - 'small' => '200px', - 'medium' => '250px', - 'large' => '350px', + ), + ), + 'button_width' => array( + 'small' => '200px', + 'medium' => '250px', + 'large' => '350px', 'responsive' => '' - ], - 'button_funding' => [ - 'paylater' => [ + ), + 'button_funding' => array( + 'paylater' => array( 'code' => 'paylater', 'name' => 'text_paylater' - ], - 'card' => [ + ), + 'card' => array( 'code' => 'card', 'name' => 'text_card' - ], - 'bancontact' => [ + ), + 'bancontact' => array( 'code' => 'bancontact', 'name' => 'text_bancontact' - ], - 'blik' => [ + ), + 'blik' => array( 'code' => 'blik', 'name' => 'text_blik' - ], - 'eps' => [ + ), + 'eps' => array( 'code' => 'eps', 'name' => 'text_eps' - ], - 'giropay' => [ + ), + 'giropay' => array( 'code' => 'giropay', 'name' => 'text_giropay' - ], - 'ideal' => [ + ), + 'ideal' => array( 'code' => 'ideal', 'name' => 'text_ideal' - ], - 'mercadopago' => [ + ), + 'mercadopago' => array( 'code' => 'mercadopago', 'name' => 'text_mercadopago' - ], - 'mybank' => [ + ), + 'mybank' => array( 'code' => 'mybank', 'name' => 'text_mybank' - ], - 'p24' => [ + ), + 'p24' => array( 'code' => 'p24', 'name' => 'text_p24' - ], - 'sepa' => [ + ), + 'sepa' => array( 'code' => 'sepa', 'name' => 'text_sepa' - ], - 'venmo' => [ + ), + 'venmo' => array( 'code' => 'venmo', 'name' => 'text_venmo' - ] - ], - 'googlepay_button_insert_type' => [ - 'into_begin' => [ - 'code' => 'prepend', - 'name' => 'text_insert_prepend' - ], - 'into_end' => [ - 'code' => 'append', - 'name' => 'text_insert_append' - ], - 'before' => [ - 'code' => 'before', - 'name' => 'text_insert_before' - ], - 'after' => [ - 'code' => 'after', - 'name' => 'text_insert_after' - ] - ], - 'googlepay_button_align' => [ - 'left' => [ + ) + ), + 'googlepay_button_insert_type' => array( + 'into_begin' => array( + 'code' => 'prepend', + 'name' => 'text_insert_prepend' + ), + 'into_end' => array( + 'code' => 'append', + 'name' => 'text_insert_append' + ), + 'before' => array( + 'code' => 'before', + 'name' => 'text_insert_before' + ), + 'after' => array( + 'code' => 'after', + 'name' => 'text_insert_after' + ) + ), + 'googlepay_button_align' => array( + 'left' => array( 'code' => 'left', 'name' => 'text_align_left' - ], - 'center' => [ + ), + 'center' => array( 'code' => 'center', 'name' => 'text_align_center' - ], - 'right' => [ + ), + 'right' => array( 'code' => 'right', 'name' => 'text_align_right' - ] - ], - 'googlepay_button_size' => [ - 'small' => [ + ) + ), + 'googlepay_button_size' => array( + 'small' => array( 'code' => 'small', 'name' => 'text_small' - ], - 'medium' => [ + ), + 'medium' => array( 'code' => 'medium', 'name' => 'text_medium' - ], - 'large' => [ + ), + 'large' => array( 'code' => 'large', 'name' => 'text_large' - ], - 'responsive' => [ + ), + 'responsive' => array( 'code' => 'responsive', 'name' => 'text_responsive' - ] - ], - 'googlepay_button_color' => [ - 'black' => [ + ) + ), + 'googlepay_button_color' => array( + 'black' => array( 'code' => 'black', 'name' => 'text_black' - ], - 'white' => [ + ), + 'white' => array( 'code' => 'white', 'name' => 'text_white' - ] - ], - 'googlepay_button_shape' => [ - 'pill' => [ + ) + ), + 'googlepay_button_shape' => array( + 'pill' => array( 'code' => 'pill', 'name' => 'text_pill' - ], - 'rect' => [ + ), + 'rect' => array( 'code' => 'rect', 'name' => 'text_rect' - ] - ], - 'googlepay_button_type' => [ - 'buy' => [ + ) + ), + 'googlepay_button_type' => array( + 'buy' => array( 'code' => 'buy', 'name' => 'text_buy' - ], - 'donate' => [ + ), + 'donate' => array( 'code' => 'donate', 'name' => 'text_donate' - ], - 'plain' => [ + ), + 'plain' => array( 'code' => 'plain', 'name' => 'text_plain' - ], - 'pay' => [ + ), + 'pay' => array( 'code' => 'pay', 'name' => 'text_pay' - ], - 'checkout' => [ + ), + 'checkout' => array( 'code' => 'checkout', 'name' => 'text_checkout' - ] - ], - 'googlepay_button_width' => [ - 'small' => '200px', - 'medium' => '250px', - 'large' => '350px', + ) + ), + 'googlepay_button_width' => array( + 'small' => '200px', + 'medium' => '250px', + 'large' => '350px', 'responsive' => '' - ], - 'applepay_button_insert_type' => [ - 'into_begin' => [ - 'code' => 'prepend', - 'name' => 'text_insert_prepend' - ], - 'into_end' => [ - 'code' => 'append', - 'name' => 'text_insert_append' - ], - 'before' => [ - 'code' => 'before', - 'name' => 'text_insert_before' - ], - 'after' => [ - 'code' => 'after', - 'name' => 'text_insert_after' - ] - ], - 'applepay_button_align' => [ - 'left' => [ + ), + 'applepay_button_insert_type' => array( + 'into_begin' => array( + 'code' => 'prepend', + 'name' => 'text_insert_prepend' + ), + 'into_end' => array( + 'code' => 'append', + 'name' => 'text_insert_append' + ), + 'before' => array( + 'code' => 'before', + 'name' => 'text_insert_before' + ), + 'after' => array( + 'code' => 'after', + 'name' => 'text_insert_after' + ) + ), + 'applepay_button_align' => array( + 'left' => array( 'code' => 'left', 'name' => 'text_align_left' - ], - 'center' => [ + ), + 'center' => array( 'code' => 'center', 'name' => 'text_align_center' - ], - 'right' => [ + ), + 'right' => array( 'code' => 'right', 'name' => 'text_align_right' - ] - ], - 'applepay_button_size' => [ - 'small' => [ + ) + ), + 'applepay_button_size' => array( + 'small' => array( 'code' => 'small', 'name' => 'text_small' - ], - 'medium' => [ + ), + 'medium' => array( 'code' => 'medium', 'name' => 'text_medium' - ], - 'large' => [ + ), + 'large' => array( 'code' => 'large', 'name' => 'text_large' - ], - 'responsive' => [ + ), + 'responsive' => array( 'code' => 'responsive', 'name' => 'text_responsive' - ] - ], - 'applepay_button_color' => [ - 'black' => [ + ) + ), + 'applepay_button_color' => array( + 'black' => array( 'code' => 'black', 'name' => 'text_black' - ], - 'white' => [ + ), + 'white' => array( 'code' => 'white', 'name' => 'text_white' - ], - 'white_outline' => [ + ), + 'white_outline' => array( 'code' => 'white-outline', 'name' => 'text_white_outline' - ] - ], - 'applepay_button_shape' => [ - 'pill' => [ + ) + ), + 'applepay_button_shape' => array( + 'pill' => array( 'code' => 'pill', 'name' => 'text_pill' - ], - 'rect' => [ + ), + 'rect' => array( 'code' => 'rect', 'name' => 'text_rect' - ] - ], - 'applepay_button_type' => [ - 'buy' => [ + ) + ), + 'applepay_button_type' => array( + 'buy' => array( 'code' => 'buy', 'name' => 'text_buy' - ], - 'donate' => [ + ), + 'donate' => array( 'code' => 'donate', 'name' => 'text_donate' - ], - 'plain' => [ + ), + 'plain' => array( 'code' => 'plain', 'name' => 'text_plain' - ], - 'check-out' => [ + ), + 'check-out' => array( 'code' => 'check-out', 'name' => 'text_check_out' - ] - ], - 'applepay_button_width' => [ - 'small' => '200px', - 'medium' => '250px', - 'large' => '350px', + ) + ), + 'applepay_button_width' => array( + 'small' => '200px', + 'medium' => '250px', + 'large' => '350px', 'responsive' => '' - ], - 'card_align' => [ - 'left' => [ + ), + 'card_align' => array( + 'left' => array( 'code' => 'left', 'name' => 'text_align_left' - ], - 'center' => [ + ), + 'center' => array( 'code' => 'center', 'name' => 'text_align_center' - ], - 'right' => [ + ), + 'right' => array( 'code' => 'right', 'name' => 'text_align_right' - ] - ], - 'card_size' => [ - 'medium' => [ + ) + ), + 'card_size' => array( + 'medium' => array( 'code' => 'medium', 'name' => 'text_medium' - ], - 'large' => [ + ), + 'large' => array( 'code' => 'large', 'name' => 'text_large' - ], - 'responsive' => [ + ), + 'responsive' => array( 'code' => 'responsive', 'name' => 'text_responsive' - ] - ], - 'card_width' => [ - 'medium' => '250px', - 'large' => '350px', + ) + ), + 'card_width' => array( + 'medium' => '250px', + 'large' => '350px', 'responsive' => '' - ], - 'card_secure_method' => [ - 'sca_when_required' => [ + ), + 'card_secure_method' => array( + 'sca_when_required' => array( 'code' => 'sca_when_required', 'name' => 'text_sca_when_required' - ], - 'sca_always' => [ + ), + 'sca_always' => array( 'code' => 'sca_always', 'name' => 'text_sca_always' - ] - ], - 'card_secure_scenario' => [ - 'failed_authentication' => [ - 'code' => 'failed_authentication', - 'name' => 'text_3ds_failed_authentication', - 'error' => 'error_3ds_failed_authentication', + ) + ), + 'card_secure_scenario' => array( + 'failed_authentication' => array( + 'code' => 'failed_authentication', + 'name' => 'text_3ds_failed_authentication', + 'error' => 'error_3ds_failed_authentication', 'recommended' => 0 - ], - 'rejected_authentication' => [ - 'code' => 'rejected_authentication', - 'name' => 'text_3ds_rejected_authentication', - 'error' => 'error_3ds_rejected_authentication', + ), + 'rejected_authentication' => array( + 'code' => 'rejected_authentication', + 'name' => 'text_3ds_rejected_authentication', + 'error' => 'error_3ds_rejected_authentication', 'recommended' => 0 - ], - 'attempted_authentication' => [ - 'code' => 'attempted_authentication', - 'name' => 'text_3ds_attempted_authentication', - 'error' => 'error_3ds_attempted_authentication', + ), + 'attempted_authentication' => array( + 'code' => 'attempted_authentication', + 'name' => 'text_3ds_attempted_authentication', + 'error' => 'error_3ds_attempted_authentication', 'recommended' => 1 - ], - 'unable_authentication' => [ - 'code' => 'unable_authentication', - 'name' => 'text_3ds_unable_authentication', - 'error' => 'error_3ds_unable_authentication', + ), + 'unable_authentication' => array( + 'code' => 'unable_authentication', + 'name' => 'text_3ds_unable_authentication', + 'error' => 'error_3ds_unable_authentication', 'recommended' => 0 - ], - 'challenge_authentication' => [ - 'code' => 'challenge_authentication', - 'name' => 'text_3ds_challenge_authentication', - 'error' => 'error_3ds_challenge_authentication', + ), + 'challenge_authentication' => array( + 'code' => 'challenge_authentication', + 'name' => 'text_3ds_challenge_authentication', + 'error' => 'error_3ds_challenge_authentication', 'recommended' => 0 - ], - 'card_ineligible' => [ - 'code' => 'card_ineligible', - 'name' => 'text_3ds_card_ineligible', - 'error' => 'error_3ds_card_ineligible', + ), + 'card_ineligible' => array( + 'code' => 'card_ineligible', + 'name' => 'text_3ds_card_ineligible', + 'error' => 'error_3ds_card_ineligible', 'recommended' => 1 - ], - 'system_unavailable' => [ - 'code' => 'system_unavailable', - 'name' => 'text_3ds_system_unavailable', - 'error' => 'error_3ds_system_unavailable', + ), + 'system_unavailable' => array( + 'code' => 'system_unavailable', + 'name' => 'text_3ds_system_unavailable', + 'error' => 'error_3ds_system_unavailable', 'recommended' => 0 - ], - 'system_bypassed' => [ - 'code' => 'system_bypassed', - 'name' => 'text_3ds_system_bypassed', - 'error' => 'error_3ds_system_bypassed', + ), + 'system_bypassed' => array( + 'code' => 'system_bypassed', + 'name' => 'text_3ds_system_bypassed', + 'error' => 'error_3ds_system_bypassed', 'recommended' => 1 - ] - ], - 'message_insert_type' => [ - 'into_begin' => [ - 'code' => 'prepend', - 'name' => 'text_insert_prepend' - ], - 'into_end' => [ - 'code' => 'append', - 'name' => 'text_insert_append' - ], - 'before' => [ - 'code' => 'before', - 'name' => 'text_insert_before' - ], - 'after' => [ - 'code' => 'after', - 'name' => 'text_insert_after' - ] - ], - 'contact_sales' => ['100k - 250k', '250k - 2m', '2m - 10m', '10m - 20m', '20m - 50m', '50m +'], - 'contact_product' => [ - [ + ) + ), + 'message_insert_type' => array( + 'into_begin' => array( + 'code' => 'prepend', + 'name' => 'text_insert_prepend' + ), + 'into_end' => array( + 'code' => 'append', + 'name' => 'text_insert_append' + ), + 'before' => array( + 'code' => 'before', + 'name' => 'text_insert_before' + ), + 'after' => array( + 'code' => 'after', + 'name' => 'text_insert_after' + ) + ), + 'contact_sales' => array('100k - 250k', '250k - 2m', '2m - 10m', '10m - 20m', '20m - 50m', '50m +'), + 'contact_product' => array( + array( 'code' => 'BT DCC', 'name' => 'text_bt_dcc' - ], - [ + ), + array( 'code' => 'Express Checkout (EC)', 'name' => 'text_express_checkout' - ], - [ + ), + array( 'code' => 'Credit - Installments', 'name' => 'text_credit_installments' - ], - [ + ), + array( 'code' => 'Point of Sale', 'name' => 'text_point_of_sale' - ], - [ + ), + array( 'code' => 'Invoicing API', 'name' => 'text_invoicing_api' - ], - [ + ), + array( 'code' => 'PayPal Working Capital', 'name' => 'text_paypal_working_capital' - ], - [ + ), + array( 'code' => 'Risk servicing', 'name' => 'text_risk_servicing' - ], - [ + ), + array( 'code' => 'PayPal Here', 'name' => 'text_paypal_here' - ], - [ + ), + array( 'code' => 'Payouts', 'name' => 'text_payouts' - ], - [ + ), + array( 'code' => 'Marketing solutions', 'name' => 'text_marketing_solutions' - ], - ] -]; + ), + ) +); +?> diff --git a/upload/system/config/paypal_carrier.php b/upload/system/config/paypal_carrier.php index 74fb3ff2..ac54d6c9 100644 --- a/upload/system/config/paypal_carrier.php +++ b/upload/system/config/paypal_carrier.php @@ -1,1391 +1,1392 @@ [ - '99minutos' => '99MINUTOS', - 'A2B Express Logistics' => 'A2B_BA', - 'AB Custom Group' => 'ABCUSTOM_SFTP', - 'ACI Logistix' => 'ACILOGISTIX', - 'ACOMMERCE' => 'ACOMMERCE', - 'Activos24' => 'ACTIVOS24_API', - 'ADS Express' => 'ADS', - 'AEROFLASH' => 'AEROFLASH', - 'Agediss' => 'AGEDISS_SFTP', - 'AIR 21' => 'AIR_21', - 'AIRSPEED' => 'AIRSPEED', - 'Airterra' => 'AIRTERRA', - 'AIT' => 'AITWORLDWIDE_SFTP', - 'Allied Express (FTP)' => 'ALLIED_EXPRESS_FTP', - 'ALLJOY SUPPLY CHAIN' => 'ALLJOY', - 'Amazon' => 'AMAZON_EMAIL_PUSH', - 'Amazon order' => 'AMAZON_ORDER', - 'amazon_uk_api' => 'AMAZON_UK_API', - 'AMS Group' => 'AMS_GRP', - 'Andreani' => 'ANDREANI_API', - 'Anteraja' => 'ANTERAJA', - 'Aramex' => 'ARAMEX_API', - 'Aras Cargo' => 'ARASKARGO', - 'Argents Express Group' => 'ARGENTS_WEBHOOK', - 'asendia_de' => 'ASENDIA_DE', - 'ATS Healthcare' => 'ATSHEALTHCARE', - 'Au Express' => 'AUEXPRESS', - 'Australia Post' => 'AUSTRALIA_POST_API', - 'Averitt Express' => 'AVERITT', - 'Axlehire' => 'AXLEHIRE_FTP', - 'AxleHire' => 'AXLEHIRE', - 'Barq' => 'BARQEXP', - 'BDMnet' => 'BDMNET', - 'bel_belgium_post' => 'BEL_BELGIUM_POST', - 'Belpost' => 'BLR_BELPOST', - 'BERT' => 'BERT', - 'Best Transport' => 'BESTTRANSPORT_SFTP', - 'Better Trucks' => 'BETTERTRUCKS', - 'Big Smart' => 'BIGSMART', - 'BioCair' => 'BIOCAIR_FTP', - 'BJS Distribution courier' => 'BJSHOMEDELIVERY', - 'BJS Distribution, Storage & Couriers - FTP' => 'BJSHOMEDELIVERY_FTP', - 'BLUEDART' => 'BLUEDART', - 'Bluedart' => 'BLUEDART_API', - 'Bollore Logistics' => 'BOLLORE_LOGISTICS', - 'Bomi Group' => 'BOMI', - 'Bpost (www.bpost.be)' => 'BE_BPOST', - 'Bpost API' => 'BPOST_API', - 'Bpost international' => 'BPOST_INT', - 'BRT Bartolini API' => 'BRT_IT_API', - 'BUFFALO' => 'BUFFALO', - 'Burd Delivery' => 'BURD', - 'C.H. Robinson Worldwide' => 'CHROBINSON', - 'Cago' => 'CAGO', - 'CANPAR' => 'CANPAR', - 'Capital Transport' => 'CAPITAL', - 'Carry-Flap Co.' => 'CARRY_FLAP', - 'CBL Logistica (API)' => 'CBL_LOGISTICA_API', - 'CDL Last Mile' => 'CDLDELIVERS', - 'Celeritas Transporte' => 'CELERITAS', - 'CEVA LOGISTICS' => 'CEVA', - 'CEVA Package' => 'CEVA_TRACKING', - 'Chazki' => 'CHAZKI', - 'Chienventure' => 'CHIENVENTURE_WEBHOOK', - 'Chile Express' => 'CHILEXPRESS', - 'City Express' => 'CITY56_WEBHOOK', - 'CJ GLS' => 'CJ_GLS', - 'CJ Logistics International' => 'CJ_LOGISTICS', - 'cj_philippines' => 'CJ_PHILIPPINES', - 'ClickLink' => 'CLICKLINK_SFTP', - 'CN Logistics' => 'CN_LOGISTICS', - 'COLLECTPLUS' => 'COLLECTPLUS', - 'ComOne Express' => 'COM1EXPRESS', - 'Concise' => 'CONCISE_API', - 'Coordinadora' => 'COORDINADORA_API', - 'Copa Airlines Courier' => 'COPA_COURIER', - 'CORREOS DE ESPANA' => 'CORREOS_DE_ESPANA', - 'Correos Express (API)' => 'CORREOSEXPRESS_API', - 'correos Express (www.correos.es)' => 'CORREOS_ES', - 'Courant Plus' => 'COURANT_PLUS_API', - 'COURIER POST' => 'COURIER_POST', - 'COURIERPLUS' => 'COURIERPLUS', - 'CRL Express' => 'CRLEXPRESS', - 'Crossflight Limited' => 'CROSSFLIGHT', - 'CryoPDP' => 'CRYOPDP_FTP', - 'Czech Post' => 'CESKAPOSTA_API', - 'D Express' => 'DEXPRESS_WEBHOOK', - 'DACHSER' => 'DACHSER_WEB', - 'Daeshin' => 'DAESHIN', - 'Daiichi Freight System Inc' => 'DAIICHI', - 'Danniao' => 'DANNIAO', - 'DAO365' => 'DAO365', - 'Day & Ross' => 'DAYROSS', - 'Daylight Transport' => 'DYLT', - 'DB Schenker' => 'DBSCHENKER_API', - 'DB Schenker B2B' => 'DBSCHENKER_B2B', - 'DB Schenker Iceland' => 'DBSCHENKER_ICELAND', - 'DD Express Courier' => 'DDEXPRESS', - 'DE DHL' => 'DE_DHL', - 'delcart_in' => 'DELCART_IN', - 'Deliver Your Parcel' => 'DELIVERYOURPARCEL_ZA', - 'Deliver-iT' => 'DELIVER_IT', - 'delivere' => 'DELIVERE', - 'Deliverr' => 'DELIVERR_SFTP', - 'DELTEC DE' => 'DELTEC_DE', - 'DemandShip' => 'DEMANDSHIP', - 'Dependable Supply Chain Services' => 'GODEPENDABLE', - 'deutsche_de' => 'DEUTSCHE_DE', - 'DHL' => 'DHL_API', - 'DHL (Reference number)' => 'DHL_REFERENCE_API', - 'DHL Active Tracing' => 'DHL_ACTIVE_TRACING', - 'DHL eCommerce Greater China' => 'DHL_ECOMMERCE_GC', - 'DHL eCommerce Solutions' => 'DHL_GLOBAL_MAIL_API', - 'DHL Express' => 'DHL_SFTP', - 'DHL France (www.dhl.com)' => 'DHL_FR', - 'DHL Freight' => 'DHL_FREIGHT', - 'dhl Global' => 'DHL', - 'DHL Global Forwarding API' => 'DHL_GLOBAL_FORWARDING_API', - 'DHL Global Forwarding Guatemala' => 'DHL_GT_API', - 'DHL GLOBAL FORWARDING PANAM��' => 'DHL_PA_API', - 'DHL International' => 'IT_DHL_ECOMMERCE', - 'DHL Japan' => 'DHL_JP', - 'DHL Parcel NL' => 'DHL_PARCEL_NL', - 'dhl Singapore' => 'DHL_SG', - 'DHL Spain Domestic' => 'DHL_ES_SFTP', - 'DHL supply chain India' => 'DHL_SUPPLYCHAIN_IN', - 'DHL Supply Chain Indonesia' => 'DHL_SUPPLYCHAIN_ID', - 'dhl_at' => 'DHL_AT', - 'dhl_global_mail' => 'DHL_GLOBAL_MAIL', - 'dhl_it' => 'DHL_IT', - 'dhl_pieceid' => 'DHL_PIECEID', - 'dhl_supply_chain_au' => 'DHL_SUPPLY_CHAIN_AU', - 'dhlparcel_uk' => 'DHLPARCEL_UK', - 'Dialogo Logistica' => 'DIALOGO_LOGISTICA', - 'Direct Freight Express' => 'DIRECTFREIGHT_AU_REF', - 'Direx' => 'DIREX', - 'DKSH' => 'DKSH', - 'DMF' => 'DMFGROUP', - 'DNJ Express' => 'DNJ_EXPRESS', - 'DOTZOT' => 'DOTZOT', - 'DPD' => 'DPD', - 'DPD Austria' => 'DPD_AT_SFTP', - 'DPD delistrack' => 'DPD_DELISTRACK', - 'DPD Netherlands' => 'DPD_NL', - 'DPD Russia' => 'DPD_RU_API', - 'DPD Slovakia' => 'DPD_SK_SFTP', - 'DPD Switzerland' => 'DPD_CH_SFTP', - 'DPD UK' => 'DPD_UK_SFTP', - 'dpd_de' => 'DPD_DE', - 'dpd_fr_reference' => 'DPD_FR_REFERENCE', - 'dpd_uk' => 'DPD_UK', - 'DPEX' => 'CN_DPEX', - 'DPEX (www.dpex.com)' => 'DPEX', - 'DSV courier' => 'DSV', - 'DSV Futurewave' => 'DSV_REFERENCE', - 'DX' => 'DX', - 'DX (B2B)' => 'DX_B2B_CONNUM', - 'DX Freight' => 'DX_FREIGHT', - 'Dynamic Logistics' => 'DYNALOGIC', - 'East West Courier Pte Ltd' => 'EASTWESTCOURIER_FTP', - 'EC_CN' => 'EC_CN', - 'ECARGO' => 'ECARGO', - 'ECexpress' => 'ECEXPRESS', - 'ECMS International Logistics Co.' => 'ECMS', - 'Eco Freight' => 'ECOFREIGHT', - 'ecourier' => 'ECOURIER', - 'eCoutier' => 'ECOUTIER', - 'EFS (E-commerce Fulfillment Service)' => 'EFS', - 'Elite Express' => 'ELITE_CO', - 'elogistica' => 'ELOGISTICA', - 'elta_gr' => 'ELTA_GR', - 'Emirates Post' => 'ARE_EMIRATES_POST', - 'EMS' => 'EMS', - 'ems_cn' => 'EMS_CN', - 'ENSENDA' => 'ENSENDA', - 'Estes Forwarding Worldwide' => 'EFWNOW_API', - 'Etomars' => 'ETOMARS', - 'eTotal Solution Limited' => 'ETOTAL', - 'Eurodifarm' => 'EDF_FTP', - 'eurodis' => 'EURODIS', - 'Europacket+' => 'EUROPAKET_API', - 'EVRi' => 'MYHERMES_UK_API', - 'EWE Global Express' => 'EWE', - 'Exelot Ltd.' => 'EXELOT_FTP', - 'Expeditors' => 'EXPEDITORS', - 'Expeditors API Reference' => 'EXPEDITORS_API_REF', - 'EZship' => 'EZSHIP', - 'fairsenden' => 'FAIRSENDEN_API', - 'Falcon Express' => 'FXTRAN', - 'FAN COURIER EXPRESS' => 'FAN', - 'Fast & Furious' => 'FNF_ZA', - 'Fast Despatch Logistics Limited' => 'FASTDESPATCH', - 'Fastbox' => 'FASTBOX', - 'Fastship Express' => 'FASTSHIP', - 'fasttrack' => 'FASTTRACK', - 'fastway_au' => 'FASTWAY_AU', - 'FASTWAY_UK' => 'FASTWAY_UK', - 'FASTWAY_US' => 'FASTWAY_US', - 'fastway_za' => 'FASTWAY_ZA', - 'Faxe Cargo' => 'FAXECARGO', - 'FedEx® Freight' => 'FEDEX_FR', - 'FedEx��' => 'FEDEX_API', - 'fercam_it' => 'FERCAM_IT', - 'Fetchr' => 'FETCHR', - 'First Logistics' => 'FIRST_LOGISTICS_API', - 'first_logisitcs' => 'FIRST_LOGISITCS', - 'FitzMark' => 'FITZMARK_API', - 'Flash Express' => 'FLASHEXPRESS_WEBHOOK', - 'Flight Logistics Group' => 'FLIGHTLG', - 'FlipXpress' => 'FLIPXP', - 'FLYTEXPRESS' => 'FLYTEXPRESS', - 'Forward Air' => 'FORWARDAIR', - 'FOUR PX EXPRESS' => 'FOUR_PX_EXPRESS', - 'fr_colissimo' => 'FR_COLISSIMO', - 'fr_mondial' => 'FR_MONDIAL', - 'FragilePAK' => 'FRAGILEPAK_SFTP', - 'FRONTdoor Collective' => 'FRONTDOORCORP', - 'FUJIE EXPRESS' => 'FUJEXP', - 'G.I.G' => 'GWLOGIS_API', - 'GAC' => 'GAC', - 'Gati-KWE' => 'GATI_KWE_API', - 'GDPharm Logistics' => 'GDPHARM', - 'Gebr��der Weiss' => 'GW_WORLD', - 'GEODIS' => 'GEODIS', - 'GEODIS - Distribution & Express' => 'GEODIS_API', - 'Georgian Post' => 'GPOST', - 'Giao hàng nhanh' => 'GIAO_HANG', - 'GIO Express Ecourier' => 'GIO_ECOURIER_API', - 'GIO Express Inc' => 'GIO_ECOURIER', - 'Global Post' => 'GOGLOBALPOST', - 'GLOBEGISTICS' => 'GLOBEGISTICS', - 'Glovo' => 'GLOVO', - 'GLS' => 'GLS', - 'GLS Spain' => 'GLS_SPAIN_API', - 'GLS_DE' => 'GLS_DE', - 'GLS_ES' => 'GLS_ES', - 'GLS_FR' => 'GLS_FR', - 'gls_italy_ftp' => 'GLS_ITALY_FTP', - 'gls_spain' => 'GLS_SPAIN', - 'GO Logistics & Storage' => 'GOLS', - 'Go People' => 'GOPEOPLE', - 'Go Rush' => 'GORUSH', - 'Gojek' => 'GOJEK', - 'GREYHOUND' => 'GREYHOUND', - 'Groupe Mazet' => 'MAZET', - 'HanJin' => 'HANJIN', - 'Hellenic (Greece) Post' => 'HELLENIC_POST', - 'Hellmann Worldwide Logistics' => 'HELLMANN', - 'Helthjem' => 'HELTHJEM_API', - 'Hermes Germany' => 'HERMES_DE_FTP', - 'Hermes UK' => 'HERMES_UK_SFTP', - 'hermesworld_uk' => 'HERMESWORLD_UK', - 'Hero Express' => 'HEROEXPRESS', - 'HFD' => 'HFD', - 'hk_rpx' => 'HK_RPX', - 'Home Logistics' => 'HOMELOGISTICS', - 'HomeRunner' => 'HOMERUNNER', - 'HR Parcel' => 'HERMES_IT', - 'HSDEXPRESS' => 'HSDEXPRESS', - 'HSM Global' => 'HSM_GLOBAL', - 'HuanTong' => 'HUANTONG', - 'HUBBED' => 'HUBBED', - 'Hunter Express' => 'HUNTER_EXPRESS_SFTP', - 'IB Venture' => 'IBVENTURE_WEBHOOK', - 'Iceland Post' => 'POSTUR_IS', - 'ICS COURIER' => 'ICSCOURIER', - 'iDexpress Indonesia' => 'IDEXPRESS_ID', - 'idn_pos' => 'IDN_POS', - 'ids_logistics' => 'IDS_LOGISTICS', - 'Ilyang logistics' => 'ILYANGLOGIS', - 'imexglobalsolutions' => 'IMEXGLOBALSOLUTIONS', - 'iMile' => 'IMILE_API', - 'IML courier' => 'IML', - 'IMX' => 'IMX', - 'India Post Domestic' => 'INDIA_POST', - 'India Post International' => 'INDIA_POST_INT', - 'Inexpost' => 'INEXPOST', - 'Inntralog GmbH' => 'INNTRALOG_SFTP', - 'InPost' => 'INPOST_UK', - 'Instabox' => 'INSTABOX_WEBHOOK', - 'International Seur API' => 'INTERNATIONAL_SEUR_API', - 'INTERSMARTTRANS & SOLUTIONS SL' => 'INTERSMARTTRANS', - 'INTEX Paketdienst GmbH' => 'INTEX_DE', - 'InTime' => 'INTIME_FTP', - 'iThink Logistics' => 'ITHINKLOGISTICS', - 'J&T CARGO' => 'JTCARGO', - 'J&T Express Philippines' => 'JTEXPRESS_PH', - 'J&T Express Singapore' => 'JTEXPRESS_SG_API', - 'J&T International logistics' => 'JT_LOGISTICS', - 'Javit' => 'JAVIT', - 'JCEX courier' => 'CN_JCEX', - 'JD Logistics' => 'JD_EXPRESS', - 'JD Worldwide' => 'JD_WORLDWIDE', - 'jetship_my' => 'JETSHIP_MY', - 'JNE (API)' => 'JNE_API', - 'JNE Express (Jalur Nugraha Ekakurir)' => 'IDN_JNE', - 'joyingbox' => 'JOYINGBOX', - 'KargomKolay (CargoMini)' => 'KARGOMKOLAY', - 'KedaEX' => 'KEDAEX', - 'Kerry Express Hong Kong' => 'HK_TGX', - 'Kerry Express TaiWan' => 'KERRY_EXPRESS_TW_API', - 'Kerry Express Thailand' => 'THA_KERRY', - 'Kerry Logistics' => 'KERRY_EXPRESS_TH_WEBHOOK', - 'Keuhne + Nagel Global' => 'KNG', - 'Kiala' => 'BE_KIALA', - 'Kiit��j��t' => 'LOGISYSTEMS_SFTP', - 'Komon Express' => 'KOMON_EXPRESS', - 'Kronos Express' => 'KRONOS', - 'Kuehne + Nagel' => 'KUEHNE', - 'Lalamove' => 'LALAMOVE_API', - 'LBC EXPRESS INC.' => 'LBCEXPRESS_API', - 'LCT do Brasil' => 'LCTBR_API', - 'Lietuvos pastas' => 'LTU_LIETUVOS', - 'Link Bridge(BeiJing)international logistics co.' => 'LINKBRIDGE', - 'LION PARCEL' => 'LION_PARCEL', - 'Livrapide' => 'LIVRAPIDE', - 'Loggi' => 'LOGGI', - 'LOGISTICSWORLDWIDE KR' => 'LOGISTICSWORLDWIDE_KR', - 'LOGISTICSWORLDWIDE MY' => 'LOGISTICSWORLDWIDE_MY', - 'Logwin Logistics' => 'LOGWIN_LOGISTICS', - 'Logysto' => 'LOGYSTO', - 'Luwjistik' => 'LUWJISTIK', - 'M&X cargo' => 'MX_CARGO', - 'M3 Logistics' => 'M3LOGISTICS', - 'maergo' => 'REIMAGINEDELIVERY', - 'Magyar Posta' => 'MAGYAR_POSTA_API', - 'Mail Boxes Etc.' => 'MAIL_BOX_ETC', - 'Malaysia Post EMS / Pos Laju' => 'MYS_EMS', - 'Malca Amit' => 'MALCA_AMIT_API', - 'Malca-Amit' => 'MALCA_AMIT', - 'Marken' => 'MARKEN', - 'Med Africa Logistics' => 'MEDAFRICA', - 'Meest' => 'MEEST', - 'megasave' => 'MEGASAVE', - 'Mensajeros Urbanos' => 'MENSAJEROSURBANOS_API', - 'Metropolitan Warehouse & Delivery' => 'MWD_API', - 'Mhi' => 'MHI', - 'Mikropakket' => 'MIKROPAKKET', - 'MISUMI Group Inc.' => 'MISUMI_CN', - 'MNX' => 'MNX', - 'Mobi Logistica' => 'MOBI_BR', - 'Mondial Relay France' => 'MONDIALRELAY_FR', - 'Mondial Relay Spain(Punto Pack)' => 'MONDIALRELAY_ES', - 'MONDIAL_BE' => 'MONDIAL_BE', - 'Moova' => 'MOOVA', - 'Morning Global' => 'MORNINGLOBAL', - 'Mothership' => 'MOTHERSHIP_API', - 'Movianto' => 'MOVIANTO', - 'MUDITA' => 'MUDITA', - 'My DynaLogic' => 'MYDYNALOGIC', - 'mySendle' => 'MYSENDLE_API', - 'N&M Transfer Co., Inc.' => 'NMTRANSFER', - 'nacex_spain_reference' => 'NACEX_SPAIN_REFERENCE', - 'Naeko Logistics' => 'NAEKO_FTP', - 'Naqel Express' => 'NAQEL_EXPRESS', - 'NEW ZEALAND COURIERS' => 'NEWZEALAND_COURIERS', - 'Newgistics' => 'NEWGISTICS', - 'Newgistics API' => 'NEWGISTICSAPI', - 'nightline_uk' => 'NIGHTLINE_UK', - 'NimbusPost' => 'NIMBUSPOST', - 'Nippon Express' => 'NIPPON_EXPRESS', - 'Northline' => 'NORTHLINE', - 'Nova Poshta API' => 'NOVA_POSHTA_API', - 'Novofarma' => 'NOVOFARMA_WEBHOOK', - 'NTL logistics' => 'NTL', - 'NYT SUPPLY CHAIN LOGISTICS Co., LTD' => 'NYTLOGISTICS', - 'Ohi' => 'OHI_WEBHOOK', - 'Olive' => 'SHOPOLIVE', - 'OM LOGISTICS LTD' => 'OMLOGISTICS_API', - 'Omni Returns' => 'OMNIRPS_WEBHOOK', - 'ONTRAC' => 'ONTRAC', - 'Optima Courier' => 'OPTIMACOURIER', - 'orangeconnex' => 'ORANGECONNEX', - 'OrangeDS (Orange Distribution Solutions Inc)' => 'ORANGE_DS', - 'OSM Worldwide' => 'OSM_WORLDWIDE_SFTP', - 'Ozeparts Shipping' => 'OZEPARTS_SHIPPING', - 'P2P TrakPak' => 'P2P_TRC', - 'Packeta' => 'PACKETA', - 'PACKFLEET' => 'PACKFLEET', - 'Packs' => 'PACKS', - 'Pakajo World' => 'PAKAJO', - 'Pandago' => 'PANDAGO_API', - 'Pandion' => 'PANDION', - 'PANDU' => 'PANDU', - 'Panther Reference' => 'PANTHER_REFERENCE_API', - 'panther_order_number' => 'PANTHER_ORDER_NUMBER', - 'Papa' => 'PAPA_WEBHOOK', - 'Parcel Right' => 'PARCELRIGHT', - 'Parcel To Post' => 'PARCEL_2_POST', - 'PARCELFORCE' => 'PARCELFORCE', - 'Parcelstars' => 'PARCELSTARS_WEBHOOK', - 'PARCLL' => 'PARCLL', - 'Passport Shipping' => 'PASSPORTSHIPPING', - 'Patheon Logistics' => 'PATHEON', - 'Payo' => 'PAYO', - 'Pchome Express' => 'PCHOME_API', - 'Pgeon' => 'PGEON_API', - 'PHSE' => 'PHSE_API', - 'pickupp_vnm' => 'PICKUPP_VNM', - 'Pidge' => 'PIDGE', - 'PIL Logistics (China) Co.' => 'PIL_LOGISTICS', - 'Plycon Transportation Group' => 'PLYCONGROUP', - 'PolarSpeed Inc' => 'POLARSPEED', - 'Post ONE' => 'POSTONE', - 'Posta Plus' => 'POSTAPLUS', - 'Poste Italiane Paccocelere' => 'POSTE_ITALIANE_PACCOCELERE', - 'Posten Norge (www.posten.no)' => 'POSTEN_NORGE', - 'Posti API' => 'POSTI_API', - 'PostNL International' => 'POSTNL_INTERNATIONAL', - 'Postnord sweden' => 'SWE_POSTNORD', - 'PostPlus' => 'POSTPLUS', - 'Pro Carrier' => 'PROCARRIER', - 'Product Care Services Limited' => 'PRODUCTCAREGROUP_SFTP', - 'PROFESSIONAL COURIERS' => 'PROFESSIONAL_COURIERS', - 'Professional Parcel Logistics' => 'PPL', - 'ProMed Delivery' => 'PROMEDDELIVERY', - 'purolator' => 'PUROLATOR', - 'Purolator International' => 'PUROLATOR_INTERNATIONAL', - 'QTrack' => 'QTRACK', - 'qualitypost' => 'QUALITYPOST', - 'Quickstat Courier LLC' => 'QINTL_API', - 'Quiqup' => 'QUIQUP', - 'Ransa' => 'RANSA_WEBHOOK', - 'Red je Pakketje' => 'REDJEPAKKETJE', - 'Relais Colis' => 'RELAISCOLIS', - 'Rhenus Logistics' => 'RHENUS_GROUP', - 'Rhenus Logistics UK' => 'RHENUS_UK_API', - 'Rivo' => 'AIR_CANADA', - 'Rixon Logistics' => 'RIXONHK_API', - 'Roche Internal Courier' => 'ROCHE_INTERNAL_SFTP', - 'Royal Mail' => 'ROYAL_MAIL_FTP', - 'royalshipments' => 'ROYALSHIPMENTS', - 'rrdonnelley' => 'RRDONNELLEY', - 'Russian post' => 'RUSSIAN_POST', - 'saee' => 'SAEE', - 'SAGAWA' => 'SAGAWA', - 'Sagawa' => 'SAGAWA_API', - 'Sber Logistics' => 'SBERLOGISTICS_RU', - 'Secretlab' => 'SECRETLAB_WEBHOOK', - 'Seino' => 'SEINO_API', - 'SEKO Worldwide' => 'SEKO_SFTP', - 'Sending Transporte Urgente y Comunicacion' => 'SENDING', - 'SENHONG INTERNATIONAL LOGISTICS' => 'SHOWL', - 'Sequoialog' => 'NOWLOG_API', - 'Servientrega' => 'SERVIENTREGA', - 'SerVIP' => 'SERVIP_WEBHOOK', - 'Setel Express' => 'SETEL', - 'SF Express' => 'SF_EX', - 'SF Express China' => 'SF_EXPRESS_CN', - 'SGT_IT' => 'SGT_IT', - 'Shadowfax' => 'SHADOWFAX', - 'shenzhen 1st International Logistics(Group)Co' => 'SHENZHEN', - 'SHENZHEN HOTSIN CARGO INTL FORWARDING CO., LTD' => 'HOTSIN_CARGO', - 'Shenzhen Jinghuada Logistics Co.' => 'KWT', - 'Sherpa' => 'SHERPA', - 'SHIPA' => 'SHIPA', - 'Shippie' => 'SHIPPIE', - 'Shippify, Inc' => 'SHIPPIFY', - 'Shiprocket X' => 'SHIPROCKET', - 'ShipX' => 'SHIPX', - 'SHIPXPRESS' => 'SHIPXPRES', - 'Shopee Express' => 'SPX', - 'Shopee Xpress' => 'SPX_TH', - 'ShunBang Express' => 'SHUNBANG_EXPRESS', - 'Shypmax' => 'SHYPLITE', - 'SimpleTire' => 'SIMPLETIRE_WEBHOOK', - 'Sims Global' => 'SIMSGLOBAL', - 'SIODEMKA' => 'SIODEMKA', - 'SkyNet Worldwide Express' => 'SKYNET_WORLDWIDE', - 'SkyPostal' => 'SKY_POSTAL', - 'Slovenska pošta' => 'SK_POSTA', - 'SMARTCAT' => 'SMARTCAT', - 'SmartKargo' => 'SMARTKARGO', - 'SMG Direct' => 'SMG_EXPRESS', - 'SMSA Express' => 'SMSA_EXPRESS_WEBHOOK', - 'Snt Global Etrax' => 'SNTGLOBAL_API', - 'solistica' => 'SOLISTICA_API', - 'Spanish Seur' => 'SPANISH_SEUR_FTP', - 'Spectran' => 'SPECTRAN', - 'speedex' => 'SPEEDEX', - 'Speedy' => 'SPEEDY', - 'Spreetail' => 'SPREETAIL_API', - 'SPRINT PACK' => 'SPRINT_PACK', - 'SRT Transport' => 'SRT_TRANSPORT', - 'Star Track Next Flight' => 'STAR_TRACK_NEXT_FLIGHT', - 'Starlinks Global' => 'STARLINKS_API', - 'startrack' => 'STARTRACK', - 'StarTrack' => 'STAR_TRACK_WEBHOOK', - 'startrack_express' => 'STARTRACK_EXPRESS', - 'Stat Overnight' => 'STATOVERNIGHT', - 'STO Express' => 'CN_STO', - 'Swiship' => 'SWISHIP', - 'Swiship IN' => 'AMAZON_FBA_SWISHIP_IN', - 'SWISS POST' => 'SWISS_POST', - 'T-cat' => 'T_CAT_API', - 'T&W Delivery' => 'LOGINEXT_WEBHOOK', - 'Taiwan Post' => 'TW_TAIWAN_POST', - 'Tamer Logistics' => 'TAMERGROUP_WEBHOOK', - 'TAQBIN Hong Kong' => 'TAQBIN_HK', - 'taqbin_sg' => 'TAQBIN_SG', - 'TCS' => 'TCS_API', - 'tecor' => 'TECOR', - 'Teleport' => 'TELEPORT_WEBHOOK', - 'Teliway SIC Express' => 'SIC_TELIWAY', - 'Testing Courier' => 'TESTING_COURIER', - 'TH_CJ' => 'TH_CJ', - 'The Custom Companies' => 'CUSTOMCO_API', - 'Thijs Logistiek' => 'THIJS_NL', - 'Thunder Express Australia' => 'THUNDEREXPRESS', - 'Tipsa API' => 'TIPSA_API', - 'Tipsa Reference' => 'TIPSA_REF', - 'TNT France Reference' => 'TNT_FR_REFERENCE', - 'TNT Reference' => 'TNT_REFR', - 'tnt_au' => 'TNT_AU', - 'TNT_CN' => 'TNT_CN', - 'TNT_DE' => 'TNT_DE', - 'TNT_ES' => 'TNT_ES', - 'tnt_it' => 'TNT_IT', - 'TNT_JP' => 'TNT_JP', - 'TNT_PL' => 'TNT_PL', - 'Toll Group' => 'TOLL_WEBHOOK', - 'TOLL IPEC' => 'TOLL_IPEC', - 'Toll Priority' => 'TOLL_PRIORITY', - 'Tomydoor' => 'TOMYDOOR', - 'Tonami' => 'TONAMI_FTP', - 'Top Ideal Express' => 'ESDEX', - 'Total Express' => 'TOTAL_EXPRESS_API', - 'Tourline Express' => 'TOURLINE_REFERENCE', - 'TP Logistic' => 'THAIPARCELS', - 'Trans2u' => 'TRANS2U', - 'TRANSMISSION' => 'TRANSMISSION', - 'Transport Ambientales' => 'TANET', - 'TransVirtual' => 'TRANSVIRTUAL', - 'Trunkrs' => 'TRUNKRS', - 'Trusk France' => 'TRUSK', - 'Tusk Logistics' => 'TUSKLOGISTICS', - 'TYP' => 'TYP', - 'U-ENVIOS' => 'U_ENVIOS', - 'Uber' => 'UBER_WEBHOOK', - 'UCS' => 'UCS', - 'United Delivery Service' => 'UDS', - 'United Parcel Service' => 'UPS', - 'up_express' => 'UP_EXPRESS', - 'uParcel' => 'UPARCEL', - 'UPS' => 'UPS_API', - 'UPS Freight' => 'UPS_FREIGHT', - 'UPS Reference' => 'UPS_REFERENCE', - 'Urgent Cargus' => 'URGENT_CARGUS', - 'us_apc' => 'US_APC', - 'USPS API' => 'USPS_API', - 'USPS Flats (Pitney Bowes)' => 'PB_USPSFLATS_FTP', - 'USPS Informed Visibility - Webhook' => 'USPS_WEBHOOK', - 'Value Logistics' => 'VALUE_WEBHOOK', - 'ViaXpress' => 'VIAXPRESS', - 'Vietnam Post' => 'VNPOST_API', - 'Vir Transport' => 'VIRTRANSPORT_SFTP', - 'vnpost_ems' => 'VNPOST_EMS', - 'VOX SOLUCION EMPRESARIAL SRL' => 'VOX', - 'watkins_shepard' => 'WATKINS_SHEPARD', - 'We World Express' => 'WEWORLDEXPRESS', - 'WeShip' => 'WESHIP', - 'Whistl' => 'WHISTL_SFTP', - 'Wineshipping' => 'WINESHIPPING_WEBHOOK', - 'Wish' => 'WISH_EMAIL_PUSH', - 'WOO YOUNG LOGISTICS CO., LTD.' => 'WOOYOUNG_LOGISTICS_SFTP', - 'World Courier' => 'WORLDCOURIER', - 'Worldnet Logistics' => 'WORLDNET', - 'WSP Express' => 'WSPEXPRESS', - 'Xingyunyi Logistics' => 'XYY', - 'Xpedigo' => 'XPEDIGO', - 'XPRESSBEES' => 'XPRESSBEES', - 'YAMATO' => 'YAMATO', - 'Yamato Singapore' => 'TAQBIN_SG_API', - 'YiFan Express' => 'YIFAN', - 'yodel' => 'YODEL', - 'Yodel API' => 'YODEL_API', - 'Yodel Direct' => 'YODEL_DIR', - 'Yodel International' => 'YODEL_INTNL', - 'Yusen Logistics' => 'YUSEN_SFTP', - 'yycom' => 'YYCOM', - 'YYEXPRESS' => 'YYEXPRESS', - 'ZTO Express China' => 'ZTO_DOMESTIC', - 'Zuellig Pharma Korea' => 'ZUELLIGPHARMA_SFTP', - 'Other' => 'OTHER' - ], + '99minutos' => '99MINUTOS', + 'A2B Express Logistics' => 'A2B_BA', + 'AB Custom Group' => 'ABCUSTOM_SFTP', + 'ACI Logistix' => 'ACILOGISTIX', + 'ACOMMERCE' => 'ACOMMERCE', + 'Activos24' => 'ACTIVOS24_API', + 'ADS Express' => 'ADS', + 'AEROFLASH' => 'AEROFLASH', + 'Agediss' => 'AGEDISS_SFTP', + 'AIR 21' => 'AIR_21', + 'AIRSPEED' => 'AIRSPEED', + 'Airterra' => 'AIRTERRA', + 'AIT' => 'AITWORLDWIDE_SFTP', + 'Allied Express (FTP)' => 'ALLIED_EXPRESS_FTP', + 'ALLJOY SUPPLY CHAIN' => 'ALLJOY', + 'Amazon' => 'AMAZON_EMAIL_PUSH', + 'Amazon order' => 'AMAZON_ORDER', + 'amazon_uk_api' => 'AMAZON_UK_API', + 'AMS Group' => 'AMS_GRP', + 'Andreani' => 'ANDREANI_API', + 'Anteraja' => 'ANTERAJA', + 'Aramex' => 'ARAMEX_API', + 'Aras Cargo' => 'ARASKARGO', + 'Argents Express Group' => 'ARGENTS_WEBHOOK', + 'asendia_de' => 'ASENDIA_DE', + 'ATS Healthcare' => 'ATSHEALTHCARE', + 'Au Express' => 'AUEXPRESS', + 'Australia Post' => 'AUSTRALIA_POST_API', + 'Averitt Express' => 'AVERITT', + 'Axlehire' => 'AXLEHIRE_FTP', + 'AxleHire' => 'AXLEHIRE', + 'Barq' => 'BARQEXP', + 'BDMnet' => 'BDMNET', + 'bel_belgium_post' => 'BEL_BELGIUM_POST', + 'Belpost' => 'BLR_BELPOST', + 'BERT' => 'BERT', + 'Best Transport' => 'BESTTRANSPORT_SFTP', + 'Better Trucks' => 'BETTERTRUCKS', + 'Big Smart' => 'BIGSMART', + 'BioCair' => 'BIOCAIR_FTP', + 'BJS Distribution courier' => 'BJSHOMEDELIVERY', + 'BJS Distribution, Storage & Couriers - FTP' => 'BJSHOMEDELIVERY_FTP', + 'BLUEDART' => 'BLUEDART', + 'Bluedart' => 'BLUEDART_API', + 'Bollore Logistics' => 'BOLLORE_LOGISTICS', + 'Bomi Group' => 'BOMI', + 'Bpost (www.bpost.be)' => 'BE_BPOST', + 'Bpost API' => 'BPOST_API', + 'Bpost international' => 'BPOST_INT', + 'BRT Bartolini API' => 'BRT_IT_API', + 'BUFFALO' => 'BUFFALO', + 'Burd Delivery' => 'BURD', + 'C.H. Robinson Worldwide' => 'CHROBINSON', + 'Cago' => 'CAGO', + 'CANPAR' => 'CANPAR', + 'Capital Transport' => 'CAPITAL', + 'Carry-Flap Co.' => 'CARRY_FLAP', + 'CBL Logistica (API)' => 'CBL_LOGISTICA_API', + 'CDL Last Mile' => 'CDLDELIVERS', + 'Celeritas Transporte' => 'CELERITAS', + 'CEVA LOGISTICS' => 'CEVA', + 'CEVA Package' => 'CEVA_TRACKING', + 'Chazki' => 'CHAZKI', + 'Chienventure' => 'CHIENVENTURE_WEBHOOK', + 'Chile Express' => 'CHILEXPRESS', + 'City Express' => 'CITY56_WEBHOOK', + 'CJ GLS' => 'CJ_GLS', + 'CJ Logistics International' => 'CJ_LOGISTICS', + 'cj_philippines' => 'CJ_PHILIPPINES', + 'ClickLink' => 'CLICKLINK_SFTP', + 'CN Logistics' => 'CN_LOGISTICS', + 'COLLECTPLUS' => 'COLLECTPLUS', + 'ComOne Express' => 'COM1EXPRESS', + 'Concise' => 'CONCISE_API', + 'Coordinadora' => 'COORDINADORA_API', + 'Copa Airlines Courier' => 'COPA_COURIER', + 'CORREOS DE ESPANA' => 'CORREOS_DE_ESPANA', + 'Correos Express (API)' => 'CORREOSEXPRESS_API', + 'correos Express (www.correos.es)' => 'CORREOS_ES', + 'Courant Plus' => 'COURANT_PLUS_API', + 'COURIER POST' => 'COURIER_POST', + 'COURIERPLUS' => 'COURIERPLUS', + 'CRL Express' => 'CRLEXPRESS', + 'Crossflight Limited' => 'CROSSFLIGHT', + 'CryoPDP' => 'CRYOPDP_FTP', + 'Czech Post' => 'CESKAPOSTA_API', + 'D Express' => 'DEXPRESS_WEBHOOK', + 'DACHSER' => 'DACHSER_WEB', + 'Daeshin' => 'DAESHIN', + 'Daiichi Freight System Inc' => 'DAIICHI', + 'Danniao' => 'DANNIAO', + 'DAO365' => 'DAO365', + 'Day & Ross' => 'DAYROSS', + 'Daylight Transport' => 'DYLT', + 'DB Schenker' => 'DBSCHENKER_API', + 'DB Schenker B2B' => 'DBSCHENKER_B2B', + 'DB Schenker Iceland' => 'DBSCHENKER_ICELAND', + 'DD Express Courier' => 'DDEXPRESS', + 'DE DHL' => 'DE_DHL', + 'delcart_in' => 'DELCART_IN', + 'Deliver Your Parcel' => 'DELIVERYOURPARCEL_ZA', + 'Deliver-iT' => 'DELIVER_IT', + 'delivere' => 'DELIVERE', + 'Deliverr' => 'DELIVERR_SFTP', + 'DELTEC DE' => 'DELTEC_DE', + 'DemandShip' => 'DEMANDSHIP', + 'Dependable Supply Chain Services' => 'GODEPENDABLE', + 'deutsche_de' => 'DEUTSCHE_DE', + 'DHL' => 'DHL_API', + 'DHL (Reference number)' => 'DHL_REFERENCE_API', + 'DHL Active Tracing' => 'DHL_ACTIVE_TRACING', + 'DHL eCommerce Greater China' => 'DHL_ECOMMERCE_GC', + 'DHL eCommerce Solutions' => 'DHL_GLOBAL_MAIL_API', + 'DHL Express' => 'DHL_SFTP', + 'DHL France (www.dhl.com)' => 'DHL_FR', + 'DHL Freight' => 'DHL_FREIGHT', + 'dhl Global' => 'DHL', + 'DHL Global Forwarding API' => 'DHL_GLOBAL_FORWARDING_API', + 'DHL Global Forwarding Guatemala' => 'DHL_GT_API', + 'DHL GLOBAL FORWARDING PANAM��' => 'DHL_PA_API', + 'DHL International' => 'IT_DHL_ECOMMERCE', + 'DHL Japan' => 'DHL_JP', + 'DHL Parcel NL' => 'DHL_PARCEL_NL', + 'dhl Singapore' => 'DHL_SG', + 'DHL Spain Domestic' => 'DHL_ES_SFTP', + 'DHL supply chain India' => 'DHL_SUPPLYCHAIN_IN', + 'DHL Supply Chain Indonesia' => 'DHL_SUPPLYCHAIN_ID', + 'dhl_at' => 'DHL_AT', + 'dhl_global_mail' => 'DHL_GLOBAL_MAIL', + 'dhl_it' => 'DHL_IT', + 'dhl_pieceid' => 'DHL_PIECEID', + 'dhl_supply_chain_au' => 'DHL_SUPPLY_CHAIN_AU', + 'dhlparcel_uk' => 'DHLPARCEL_UK', + 'Dialogo Logistica' => 'DIALOGO_LOGISTICA', + 'Direct Freight Express' => 'DIRECTFREIGHT_AU_REF', + 'Direx' => 'DIREX', + 'DKSH' => 'DKSH', + 'DMF' => 'DMFGROUP', + 'DNJ Express' => 'DNJ_EXPRESS', + 'DOTZOT' => 'DOTZOT', + 'DPD' => 'DPD', + 'DPD Austria' => 'DPD_AT_SFTP', + 'DPD delistrack' => 'DPD_DELISTRACK', + 'DPD Netherlands' => 'DPD_NL', + 'DPD Russia' => 'DPD_RU_API', + 'DPD Slovakia' => 'DPD_SK_SFTP', + 'DPD Switzerland' => 'DPD_CH_SFTP', + 'DPD UK' => 'DPD_UK_SFTP', + 'dpd_de' => 'DPD_DE', + 'dpd_fr_reference' => 'DPD_FR_REFERENCE', + 'dpd_uk' => 'DPD_UK', + 'DPEX' => 'CN_DPEX', + 'DPEX (www.dpex.com)' => 'DPEX', + 'DSV courier' => 'DSV', + 'DSV Futurewave' => 'DSV_REFERENCE', + 'DX' => 'DX', + 'DX (B2B)' => 'DX_B2B_CONNUM', + 'DX Freight' => 'DX_FREIGHT', + 'Dynamic Logistics' => 'DYNALOGIC', + 'East West Courier Pte Ltd' => 'EASTWESTCOURIER_FTP', + 'EC_CN' => 'EC_CN', + 'ECARGO' => 'ECARGO', + 'ECexpress' => 'ECEXPRESS', + 'ECMS International Logistics Co.' => 'ECMS', + 'Eco Freight' => 'ECOFREIGHT', + 'ecourier' => 'ECOURIER', + 'eCoutier' => 'ECOUTIER', + 'EFS (E-commerce Fulfillment Service)' => 'EFS', + 'Elite Express' => 'ELITE_CO', + 'elogistica' => 'ELOGISTICA', + 'elta_gr' => 'ELTA_GR', + 'Emirates Post' => 'ARE_EMIRATES_POST', + 'EMS' => 'EMS', + 'ems_cn' => 'EMS_CN', + 'ENSENDA' => 'ENSENDA', + 'Estes Forwarding Worldwide' => 'EFWNOW_API', + 'Etomars' => 'ETOMARS', + 'eTotal Solution Limited' => 'ETOTAL', + 'Eurodifarm' => 'EDF_FTP', + 'eurodis' => 'EURODIS', + 'Europacket+' => 'EUROPAKET_API', + 'EVRi' => 'MYHERMES_UK_API', + 'EWE Global Express' => 'EWE', + 'Exelot Ltd.' => 'EXELOT_FTP', + 'Expeditors' => 'EXPEDITORS', + 'Expeditors API Reference' => 'EXPEDITORS_API_REF', + 'EZship' => 'EZSHIP', + 'fairsenden' => 'FAIRSENDEN_API', + 'Falcon Express' => 'FXTRAN', + 'FAN COURIER EXPRESS' => 'FAN', + 'Fast & Furious' => 'FNF_ZA', + 'Fast Despatch Logistics Limited' => 'FASTDESPATCH', + 'Fastbox' => 'FASTBOX', + 'Fastship Express' => 'FASTSHIP', + 'fasttrack' => 'FASTTRACK', + 'fastway_au' => 'FASTWAY_AU', + 'FASTWAY_UK' => 'FASTWAY_UK', + 'FASTWAY_US' => 'FASTWAY_US', + 'fastway_za' => 'FASTWAY_ZA', + 'Faxe Cargo' => 'FAXECARGO', + 'FedEx® Freight' => 'FEDEX_FR', + 'FedEx��' => 'FEDEX_API', + 'fercam_it' => 'FERCAM_IT', + 'Fetchr' => 'FETCHR', + 'First Logistics' => 'FIRST_LOGISTICS_API', + 'first_logisitcs' => 'FIRST_LOGISITCS', + 'FitzMark' => 'FITZMARK_API', + 'Flash Express' => 'FLASHEXPRESS_WEBHOOK', + 'Flight Logistics Group' => 'FLIGHTLG', + 'FlipXpress' => 'FLIPXP', + 'FLYTEXPRESS' => 'FLYTEXPRESS', + 'Forward Air' => 'FORWARDAIR', + 'FOUR PX EXPRESS' => 'FOUR_PX_EXPRESS', + 'fr_colissimo' => 'FR_COLISSIMO', + 'fr_mondial' => 'FR_MONDIAL', + 'FragilePAK' => 'FRAGILEPAK_SFTP', + 'FRONTdoor Collective' => 'FRONTDOORCORP', + 'FUJIE EXPRESS' => 'FUJEXP', + 'G.I.G' => 'GWLOGIS_API', + 'GAC' => 'GAC', + 'Gati-KWE' => 'GATI_KWE_API', + 'GDPharm Logistics' => 'GDPHARM', + 'Gebr��der Weiss' => 'GW_WORLD', + 'GEODIS' => 'GEODIS', + 'GEODIS - Distribution & Express' => 'GEODIS_API', + 'Georgian Post' => 'GPOST', + 'Giao hàng nhanh' => 'GIAO_HANG', + 'GIO Express Ecourier' => 'GIO_ECOURIER_API', + 'GIO Express Inc' => 'GIO_ECOURIER', + 'Global Post' => 'GOGLOBALPOST', + 'GLOBEGISTICS' => 'GLOBEGISTICS', + 'Glovo' => 'GLOVO', + 'GLS' => 'GLS', + 'GLS Spain' => 'GLS_SPAIN_API', + 'GLS_DE' => 'GLS_DE', + 'GLS_ES' => 'GLS_ES', + 'GLS_FR' => 'GLS_FR', + 'gls_italy_ftp' => 'GLS_ITALY_FTP', + 'gls_spain' => 'GLS_SPAIN', + 'GO Logistics & Storage' => 'GOLS', + 'Go People' => 'GOPEOPLE', + 'Go Rush' => 'GORUSH', + 'Gojek' => 'GOJEK', + 'GREYHOUND' => 'GREYHOUND', + 'Groupe Mazet' => 'MAZET', + 'HanJin' => 'HANJIN', + 'Hellenic (Greece) Post' => 'HELLENIC_POST', + 'Hellmann Worldwide Logistics' => 'HELLMANN', + 'Helthjem' => 'HELTHJEM_API', + 'Hermes Germany' => 'HERMES_DE_FTP', + 'Hermes UK' => 'HERMES_UK_SFTP', + 'hermesworld_uk' => 'HERMESWORLD_UK', + 'Hero Express' => 'HEROEXPRESS', + 'HFD' => 'HFD', + 'hk_rpx' => 'HK_RPX', + 'Home Logistics' => 'HOMELOGISTICS', + 'HomeRunner' => 'HOMERUNNER', + 'HR Parcel' => 'HERMES_IT', + 'HSDEXPRESS' => 'HSDEXPRESS', + 'HSM Global' => 'HSM_GLOBAL', + 'HuanTong' => 'HUANTONG', + 'HUBBED' => 'HUBBED', + 'Hunter Express' => 'HUNTER_EXPRESS_SFTP', + 'IB Venture' => 'IBVENTURE_WEBHOOK', + 'Iceland Post' => 'POSTUR_IS', + 'ICS COURIER' => 'ICSCOURIER', + 'iDexpress Indonesia' => 'IDEXPRESS_ID', + 'idn_pos' => 'IDN_POS', + 'ids_logistics' => 'IDS_LOGISTICS', + 'Ilyang logistics' => 'ILYANGLOGIS', + 'imexglobalsolutions' => 'IMEXGLOBALSOLUTIONS', + 'iMile' => 'IMILE_API', + 'IML courier' => 'IML', + 'IMX' => 'IMX', + 'India Post Domestic' => 'INDIA_POST', + 'India Post International' => 'INDIA_POST_INT', + 'Inexpost' => 'INEXPOST', + 'Inntralog GmbH' => 'INNTRALOG_SFTP', + 'InPost' => 'INPOST_UK', + 'Instabox' => 'INSTABOX_WEBHOOK', + 'International Seur API' => 'INTERNATIONAL_SEUR_API', + 'INTERSMARTTRANS & SOLUTIONS SL' => 'INTERSMARTTRANS', + 'INTEX Paketdienst GmbH' => 'INTEX_DE', + 'InTime' => 'INTIME_FTP', + 'iThink Logistics' => 'ITHINKLOGISTICS', + 'J&T CARGO' => 'JTCARGO', + 'J&T Express Philippines' => 'JTEXPRESS_PH', + 'J&T Express Singapore' => 'JTEXPRESS_SG_API', + 'J&T International logistics' => 'JT_LOGISTICS', + 'Javit' => 'JAVIT', + 'JCEX courier' => 'CN_JCEX', + 'JD Logistics' => 'JD_EXPRESS', + 'JD Worldwide' => 'JD_WORLDWIDE', + 'jetship_my' => 'JETSHIP_MY', + 'JNE (API)' => 'JNE_API', + 'JNE Express (Jalur Nugraha Ekakurir)' => 'IDN_JNE', + 'joyingbox' => 'JOYINGBOX', + 'KargomKolay (CargoMini)' => 'KARGOMKOLAY', + 'KedaEX' => 'KEDAEX', + 'Kerry Express Hong Kong' => 'HK_TGX', + 'Kerry Express TaiWan' => 'KERRY_EXPRESS_TW_API', + 'Kerry Express Thailand' => 'THA_KERRY', + 'Kerry Logistics' => 'KERRY_EXPRESS_TH_WEBHOOK', + 'Keuhne + Nagel Global' => 'KNG', + 'Kiala' => 'BE_KIALA', + 'Kiit��j��t' => 'LOGISYSTEMS_SFTP', + 'Komon Express' => 'KOMON_EXPRESS', + 'Kronos Express' => 'KRONOS', + 'Kuehne + Nagel' => 'KUEHNE', + 'Lalamove' => 'LALAMOVE_API', + 'LBC EXPRESS INC.' => 'LBCEXPRESS_API', + 'LCT do Brasil' => 'LCTBR_API', + 'Lietuvos pastas' => 'LTU_LIETUVOS', + 'Link Bridge(BeiJing)international logistics co.' => 'LINKBRIDGE', + 'LION PARCEL' => 'LION_PARCEL', + 'Livrapide' => 'LIVRAPIDE', + 'Loggi' => 'LOGGI', + 'LOGISTICSWORLDWIDE KR' => 'LOGISTICSWORLDWIDE_KR', + 'LOGISTICSWORLDWIDE MY' => 'LOGISTICSWORLDWIDE_MY', + 'Logwin Logistics' => 'LOGWIN_LOGISTICS', + 'Logysto' => 'LOGYSTO', + 'Luwjistik' => 'LUWJISTIK', + 'M&X cargo' => 'MX_CARGO', + 'M3 Logistics' => 'M3LOGISTICS', + 'maergo' => 'REIMAGINEDELIVERY', + 'Magyar Posta' => 'MAGYAR_POSTA_API', + 'Mail Boxes Etc.' => 'MAIL_BOX_ETC', + 'Malaysia Post EMS / Pos Laju' => 'MYS_EMS', + 'Malca Amit' => 'MALCA_AMIT_API', + 'Malca-Amit' => 'MALCA_AMIT', + 'Marken' => 'MARKEN', + 'Med Africa Logistics' => 'MEDAFRICA', + 'Meest' => 'MEEST', + 'megasave' => 'MEGASAVE', + 'Mensajeros Urbanos' => 'MENSAJEROSURBANOS_API', + 'Metropolitan Warehouse & Delivery' => 'MWD_API', + 'Mhi' => 'MHI', + 'Mikropakket' => 'MIKROPAKKET', + 'MISUMI Group Inc.' => 'MISUMI_CN', + 'MNX' => 'MNX', + 'Mobi Logistica' => 'MOBI_BR', + 'Mondial Relay France' => 'MONDIALRELAY_FR', + 'Mondial Relay Spain(Punto Pack)' => 'MONDIALRELAY_ES', + 'MONDIAL_BE' => 'MONDIAL_BE', + 'Moova' => 'MOOVA', + 'Morning Global' => 'MORNINGLOBAL', + 'Mothership' => 'MOTHERSHIP_API', + 'Movianto' => 'MOVIANTO', + 'MUDITA' => 'MUDITA', + 'My DynaLogic' => 'MYDYNALOGIC', + 'mySendle' => 'MYSENDLE_API', + 'N&M Transfer Co., Inc.' => 'NMTRANSFER', + 'nacex_spain_reference' => 'NACEX_SPAIN_REFERENCE', + 'Naeko Logistics' => 'NAEKO_FTP', + 'Naqel Express' => 'NAQEL_EXPRESS', + 'NEW ZEALAND COURIERS' => 'NEWZEALAND_COURIERS', + 'Newgistics' => 'NEWGISTICS', + 'Newgistics API' => 'NEWGISTICSAPI', + 'nightline_uk' => 'NIGHTLINE_UK', + 'NimbusPost' => 'NIMBUSPOST', + 'Nippon Express' => 'NIPPON_EXPRESS', + 'Northline' => 'NORTHLINE', + 'Nova Poshta API' => 'NOVA_POSHTA_API', + 'Novofarma' => 'NOVOFARMA_WEBHOOK', + 'NTL logistics' => 'NTL', + 'NYT SUPPLY CHAIN LOGISTICS Co., LTD' => 'NYTLOGISTICS', + 'Ohi' => 'OHI_WEBHOOK', + 'Olive' => 'SHOPOLIVE', + 'OM LOGISTICS LTD' => 'OMLOGISTICS_API', + 'Omni Returns' => 'OMNIRPS_WEBHOOK', + 'ONTRAC' => 'ONTRAC', + 'Optima Courier' => 'OPTIMACOURIER', + 'orangeconnex' => 'ORANGECONNEX', + 'OrangeDS (Orange Distribution Solutions Inc)' => 'ORANGE_DS', + 'OSM Worldwide' => 'OSM_WORLDWIDE_SFTP', + 'Ozeparts Shipping' => 'OZEPARTS_SHIPPING', + 'P2P TrakPak' => 'P2P_TRC', + 'Packeta' => 'PACKETA', + 'PACKFLEET' => 'PACKFLEET', + 'Packs' => 'PACKS', + 'Pakajo World' => 'PAKAJO', + 'Pandago' => 'PANDAGO_API', + 'Pandion' => 'PANDION', + 'PANDU' => 'PANDU', + 'Panther Reference' => 'PANTHER_REFERENCE_API', + 'panther_order_number' => 'PANTHER_ORDER_NUMBER', + 'Papa' => 'PAPA_WEBHOOK', + 'Parcel Right' => 'PARCELRIGHT', + 'Parcel To Post' => 'PARCEL_2_POST', + 'PARCELFORCE' => 'PARCELFORCE', + 'Parcelstars' => 'PARCELSTARS_WEBHOOK', + 'PARCLL' => 'PARCLL', + 'Passport Shipping' => 'PASSPORTSHIPPING', + 'Patheon Logistics' => 'PATHEON', + 'Payo' => 'PAYO', + 'Pchome Express' => 'PCHOME_API', + 'Pgeon' => 'PGEON_API', + 'PHSE' => 'PHSE_API', + 'pickupp_vnm' => 'PICKUPP_VNM', + 'Pidge' => 'PIDGE', + 'PIL Logistics (China) Co.' => 'PIL_LOGISTICS', + 'Plycon Transportation Group' => 'PLYCONGROUP', + 'PolarSpeed Inc' => 'POLARSPEED', + 'Post ONE' => 'POSTONE', + 'Posta Plus' => 'POSTAPLUS', + 'Poste Italiane Paccocelere' => 'POSTE_ITALIANE_PACCOCELERE', + 'Posten Norge (www.posten.no)' => 'POSTEN_NORGE', + 'Posti API' => 'POSTI_API', + 'PostNL International' => 'POSTNL_INTERNATIONAL', + 'Postnord sweden' => 'SWE_POSTNORD', + 'PostPlus' => 'POSTPLUS', + 'Pro Carrier' => 'PROCARRIER', + 'Product Care Services Limited' => 'PRODUCTCAREGROUP_SFTP', + 'PROFESSIONAL COURIERS' => 'PROFESSIONAL_COURIERS', + 'Professional Parcel Logistics' => 'PPL', + 'ProMed Delivery' => 'PROMEDDELIVERY', + 'purolator' => 'PUROLATOR', + 'Purolator International' => 'PUROLATOR_INTERNATIONAL', + 'QTrack' => 'QTRACK', + 'qualitypost' => 'QUALITYPOST', + 'Quickstat Courier LLC' => 'QINTL_API', + 'Quiqup' => 'QUIQUP', + 'Ransa' => 'RANSA_WEBHOOK', + 'Red je Pakketje' => 'REDJEPAKKETJE', + 'Relais Colis' => 'RELAISCOLIS', + 'Rhenus Logistics' => 'RHENUS_GROUP', + 'Rhenus Logistics UK' => 'RHENUS_UK_API', + 'Rivo' => 'AIR_CANADA', + 'Rixon Logistics' => 'RIXONHK_API', + 'Roche Internal Courier' => 'ROCHE_INTERNAL_SFTP', + 'Royal Mail' => 'ROYAL_MAIL_FTP', + 'royalshipments' => 'ROYALSHIPMENTS', + 'rrdonnelley' => 'RRDONNELLEY', + 'Russian post' => 'RUSSIAN_POST', + 'saee' => 'SAEE', + 'SAGAWA' => 'SAGAWA', + 'Sagawa' => 'SAGAWA_API', + 'Sber Logistics' => 'SBERLOGISTICS_RU', + 'Secretlab' => 'SECRETLAB_WEBHOOK', + 'Seino' => 'SEINO_API', + 'SEKO Worldwide' => 'SEKO_SFTP', + 'Sending Transporte Urgente y Comunicacion' => 'SENDING', + 'SENHONG INTERNATIONAL LOGISTICS' => 'SHOWL', + 'Sequoialog' => 'NOWLOG_API', + 'Servientrega' => 'SERVIENTREGA', + 'SerVIP' => 'SERVIP_WEBHOOK', + 'Setel Express' => 'SETEL', + 'SF Express' => 'SF_EX', + 'SF Express China' => 'SF_EXPRESS_CN', + 'SGT_IT' => 'SGT_IT', + 'Shadowfax' => 'SHADOWFAX', + 'shenzhen 1st International Logistics(Group)Co' => 'SHENZHEN', + 'SHENZHEN HOTSIN CARGO INTL FORWARDING CO., LTD' => 'HOTSIN_CARGO', + 'Shenzhen Jinghuada Logistics Co.' => 'KWT', + 'Sherpa' => 'SHERPA', + 'SHIPA' => 'SHIPA', + 'Shippie' => 'SHIPPIE', + 'Shippify, Inc' => 'SHIPPIFY', + 'Shiprocket X' => 'SHIPROCKET', + 'ShipX' => 'SHIPX', + 'SHIPXPRESS' => 'SHIPXPRES', + 'Shopee Express' => 'SPX', + 'Shopee Xpress' => 'SPX_TH', + 'ShunBang Express' => 'SHUNBANG_EXPRESS', + 'Shypmax' => 'SHYPLITE', + 'SimpleTire' => 'SIMPLETIRE_WEBHOOK', + 'Sims Global' => 'SIMSGLOBAL', + 'SIODEMKA' => 'SIODEMKA', + 'SkyNet Worldwide Express' => 'SKYNET_WORLDWIDE', + 'SkyPostal' => 'SKY_POSTAL', + 'Slovenska pošta' => 'SK_POSTA', + 'SMARTCAT' => 'SMARTCAT', + 'SmartKargo' => 'SMARTKARGO', + 'SMG Direct' => 'SMG_EXPRESS', + 'SMSA Express' => 'SMSA_EXPRESS_WEBHOOK', + 'Snt Global Etrax' => 'SNTGLOBAL_API', + 'solistica' => 'SOLISTICA_API', + 'Spanish Seur' => 'SPANISH_SEUR_FTP', + 'Spectran' => 'SPECTRAN', + 'speedex' => 'SPEEDEX', + 'Speedy' => 'SPEEDY', + 'Spreetail' => 'SPREETAIL_API', + 'SPRINT PACK' => 'SPRINT_PACK', + 'SRT Transport' => 'SRT_TRANSPORT', + 'Star Track Next Flight' => 'STAR_TRACK_NEXT_FLIGHT', + 'Starlinks Global' => 'STARLINKS_API', + 'startrack' => 'STARTRACK', + 'StarTrack' => 'STAR_TRACK_WEBHOOK', + 'startrack_express' => 'STARTRACK_EXPRESS', + 'Stat Overnight' => 'STATOVERNIGHT', + 'STO Express' => 'CN_STO', + 'Swiship' => 'SWISHIP', + 'Swiship IN' => 'AMAZON_FBA_SWISHIP_IN', + 'SWISS POST' => 'SWISS_POST', + 'T-cat' => 'T_CAT_API', + 'T&W Delivery' => 'LOGINEXT_WEBHOOK', + 'Taiwan Post' => 'TW_TAIWAN_POST', + 'Tamer Logistics' => 'TAMERGROUP_WEBHOOK', + 'TAQBIN Hong Kong' => 'TAQBIN_HK', + 'taqbin_sg' => 'TAQBIN_SG', + 'TCS' => 'TCS_API', + 'tecor' => 'TECOR', + 'Teleport' => 'TELEPORT_WEBHOOK', + 'Teliway SIC Express' => 'SIC_TELIWAY', + 'Testing Courier' => 'TESTING_COURIER', + 'TH_CJ' => 'TH_CJ', + 'The Custom Companies' => 'CUSTOMCO_API', + 'Thijs Logistiek' => 'THIJS_NL', + 'Thunder Express Australia' => 'THUNDEREXPRESS', + 'Tipsa API' => 'TIPSA_API', + 'Tipsa Reference' => 'TIPSA_REF', + 'TNT France Reference' => 'TNT_FR_REFERENCE', + 'TNT Reference' => 'TNT_REFR', + 'tnt_au' => 'TNT_AU', + 'TNT_CN' => 'TNT_CN', + 'TNT_DE' => 'TNT_DE', + 'TNT_ES' => 'TNT_ES', + 'tnt_it' => 'TNT_IT', + 'TNT_JP' => 'TNT_JP', + 'TNT_PL' => 'TNT_PL', + 'Toll Group' => 'TOLL_WEBHOOK', + 'TOLL IPEC' => 'TOLL_IPEC', + 'Toll Priority' => 'TOLL_PRIORITY', + 'Tomydoor' => 'TOMYDOOR', + 'Tonami' => 'TONAMI_FTP', + 'Top Ideal Express' => 'ESDEX', + 'Total Express' => 'TOTAL_EXPRESS_API', + 'Tourline Express' => 'TOURLINE_REFERENCE', + 'TP Logistic' => 'THAIPARCELS', + 'Trans2u' => 'TRANS2U', + 'TRANSMISSION' => 'TRANSMISSION', + 'Transport Ambientales' => 'TANET', + 'TransVirtual' => 'TRANSVIRTUAL', + 'Trunkrs' => 'TRUNKRS', + 'Trusk France' => 'TRUSK', + 'Tusk Logistics' => 'TUSKLOGISTICS', + 'TYP' => 'TYP', + 'U-ENVIOS' => 'U_ENVIOS', + 'Uber' => 'UBER_WEBHOOK', + 'UCS' => 'UCS', + 'United Delivery Service' => 'UDS', + 'United Parcel Service' => 'UPS', + 'up_express' => 'UP_EXPRESS', + 'uParcel' => 'UPARCEL', + 'UPS' => 'UPS_API', + 'UPS Freight' => 'UPS_FREIGHT', + 'UPS Reference' => 'UPS_REFERENCE', + 'Urgent Cargus' => 'URGENT_CARGUS', + 'us_apc' => 'US_APC', + 'USPS API' => 'USPS_API', + 'USPS Flats (Pitney Bowes)' => 'PB_USPSFLATS_FTP', + 'USPS Informed Visibility - Webhook' => 'USPS_WEBHOOK', + 'Value Logistics' => 'VALUE_WEBHOOK', + 'ViaXpress' => 'VIAXPRESS', + 'Vietnam Post' => 'VNPOST_API', + 'Vir Transport' => 'VIRTRANSPORT_SFTP', + 'vnpost_ems' => 'VNPOST_EMS', + 'VOX SOLUCION EMPRESARIAL SRL' => 'VOX', + 'watkins_shepard' => 'WATKINS_SHEPARD', + 'We World Express' => 'WEWORLDEXPRESS', + 'WeShip' => 'WESHIP', + 'Whistl' => 'WHISTL_SFTP', + 'Wineshipping' => 'WINESHIPPING_WEBHOOK', + 'Wish' => 'WISH_EMAIL_PUSH', + 'WOO YOUNG LOGISTICS CO., LTD.' => 'WOOYOUNG_LOGISTICS_SFTP', + 'World Courier' => 'WORLDCOURIER', + 'Worldnet Logistics' => 'WORLDNET', + 'WSP Express' => 'WSPEXPRESS', + 'Xingyunyi Logistics' => 'XYY', + 'Xpedigo' => 'XPEDIGO', + 'XPRESSBEES' => 'XPRESSBEES', + 'YAMATO' => 'YAMATO', + 'Yamato Singapore' => 'TAQBIN_SG_API', + 'YiFan Express' => 'YIFAN', + 'yodel' => 'YODEL', + 'Yodel API' => 'YODEL_API', + 'Yodel Direct' => 'YODEL_DIR', + 'Yodel International' => 'YODEL_INTNL', + 'Yusen Logistics' => 'YUSEN_SFTP', + 'yycom' => 'YYCOM', + 'YYEXPRESS' => 'YYEXPRESS', + 'ZTO Express China' => 'ZTO_DOMESTIC', + 'Zuellig Pharma Korea' => 'ZUELLIGPHARMA_SFTP', + 'Other' => 'OTHER' + ], 'ARG' => [ - 'Fasttrack' => 'FASTRACK', - 'Grupo logistico Andreani' => 'ANDREANI', - 'OCA Argentina' => 'ARG_OCA' - ], + 'Fasttrack' => 'FASTRACK', + 'Grupo logistico Andreani' => 'ANDREANI', + 'OCA Argentina' => 'ARG_OCA' + ], 'AUS' => [ - 'ADSone' => 'ADSONE', - 'Allied Express' => 'ALLIEDEXPRESS', - 'Aramex Australia (formerly Fastway AU)' => 'ARAMEX_AU', - 'Australia Post' => 'AU_AU_POST', - 'Blue Star' => 'BLUESTAR', - 'Bonds Courier Service (bondscouriers.com.au)' => 'BONDSCOURIERS', - 'Border Express' => 'BORDEREXPRESS', - 'Cope Sensitive Freight' => 'COPE', - 'CouriersPlease (couriersplease.com.au)' => 'COURIERS_PLEASE', - 'deliverE' => 'IND_DELIVREE', - 'Designer Transport' => 'DESIGNERTRANSPORT_WEBHOOK', - 'DHL Supply Chain Australia' => 'DHL_AU', - 'Direct Couriers' => 'DIRECTCOURIERS', - 'DTDC Australia' => 'DTDC_AU', - 'Endeavour Delivery' => 'ENDEAVOUR_DELIVERY', - 'Hunter Express' => 'HUNTER_EXPRESS', - 'iCumulus' => 'ICUMULUS', - 'Interparcel Australia' => 'INTERPARCEL_AU', - 'Neway Transport' => 'NEWAY', - 'Parcelpoint' => 'PARCELPOINT', - 'PFL' => 'PFLOGISTICS', - 'Sendle' => 'SENDLE', - 'Shippit' => 'SHIPPIT', - 'SortHub courier' => 'THENILE_WEBHOOK', - 'Star Track Express' => 'STAR_TRACK_EXPRESS', - 'StarTrack (startrack.com.au)' => 'AUS_STARTRACK', - 'TFM Xpress' => 'TFM', - 'TIG Freight' => 'TIGFREIGHT', - 'Toll IPEC' => 'TOLL', - 'UBI Smart Parcel' => 'UBI_LOGISTICS', - 'XL Express' => 'XL_EXPRESS' - ], + 'ADSone' => 'ADSONE', + 'Allied Express' => 'ALLIEDEXPRESS', + 'Aramex Australia (formerly Fastway AU)' => 'ARAMEX_AU', + 'Australia Post' => 'AU_AU_POST', + 'Blue Star' => 'BLUESTAR', + 'Bonds Courier Service (bondscouriers.com.au)' => 'BONDSCOURIERS', + 'Border Express' => 'BORDEREXPRESS', + 'Cope Sensitive Freight' => 'COPE', + 'CouriersPlease (couriersplease.com.au)' => 'COURIERS_PLEASE', + 'deliverE' => 'IND_DELIVREE', + 'Designer Transport' => 'DESIGNERTRANSPORT_WEBHOOK', + 'DHL Supply Chain Australia' => 'DHL_AU', + 'Direct Couriers' => 'DIRECTCOURIERS', + 'DTDC Australia' => 'DTDC_AU', + 'Endeavour Delivery' => 'ENDEAVOUR_DELIVERY', + 'Hunter Express' => 'HUNTER_EXPRESS', + 'iCumulus' => 'ICUMULUS', + 'Interparcel Australia' => 'INTERPARCEL_AU', + 'Neway Transport' => 'NEWAY', + 'Parcelpoint' => 'PARCELPOINT', + 'PFL' => 'PFLOGISTICS', + 'Sendle' => 'SENDLE', + 'Shippit' => 'SHIPPIT', + 'SortHub courier' => 'THENILE_WEBHOOK', + 'Star Track Express' => 'STAR_TRACK_EXPRESS', + 'StarTrack (startrack.com.au)' => 'AUS_STARTRACK', + 'TFM Xpress' => 'TFM', + 'TIG Freight' => 'TIGFREIGHT', + 'Toll IPEC' => 'TOLL', + 'UBI Smart Parcel' => 'UBI_LOGISTICS', + 'XL Express' => 'XL_EXPRESS' + ], 'AUT' => [ - 'austrian post' => 'AUSTRIAN_POST_EXPRESS', + 'austrian post' => 'AUSTRIAN_POST_EXPRESS', 'Austrian Post (Registered)' => 'AU_AUSTRIAN_POST' - ], + ], 'BGD' => [ 'Paperfly Private Limited' => 'PAPERFLY' - ], + ], 'BEL' => [ - 'B2C courier Europe' => 'B_TWO_C_EUROPE', - 'dhl benelux' => 'DHL_BENELUX', - 'DHL Benelux' => 'BEL_DHL', - 'Landmark Global' => 'LANDMARK_GLOBAL', - 'Landmark Global Reference' => 'LANDMARK_GLOBAL_REFERENCE', - 'Mikropakket Belgium' => 'MIKROPAKKET_BE' - ], + 'B2C courier Europe' => 'B_TWO_C_EUROPE', + 'dhl benelux' => 'DHL_BENELUX', + 'DHL Benelux' => 'BEL_DHL', + 'Landmark Global' => 'LANDMARK_GLOBAL', + 'Landmark Global Reference' => 'LANDMARK_GLOBAL_REFERENCE', + 'Mikropakket Belgium' => 'MIKROPAKKET_BE' + ], 'BIH' => [ 'BH Posta (www.posta.ba)' => 'BH_POSTA' - ], + ], 'BRA' => [ - 'Correios Brazil' => 'BRA_CORREIOS', - 'Directlog (www.directlog.com.br)' => 'DIRECTLOG', - 'Frete Rapido' => 'FRETERAPIDO', - 'Intelipost (TMS for LATAM)' => 'INTELIPOST', - 'Total Express' => 'TOTAL_EXPRESS' - ], + 'Correios Brazil' => 'BRA_CORREIOS', + 'Directlog (www.directlog.com.br)' => 'DIRECTLOG', + 'Frete Rapido' => 'FRETERAPIDO', + 'Intelipost (TMS for LATAM)' => 'INTELIPOST', + 'Total Express' => 'TOTAL_EXPRESS' + ], 'BGR' => [ - 'A1Post' => 'A1POST', + 'A1Post' => 'A1POST', 'Bulgarian Posts' => 'BG_BULGARIAN_POST' - ], + ], 'KHM' => [ - 'AFL LOGISTICS' => 'AFLLOG_FTP', - 'Cambodia Post' => 'KHM_CAMBODIA_POST', + 'AFL LOGISTICS' => 'AFLLOG_FTP', + 'Cambodia Post' => 'KHM_CAMBODIA_POST', 'Roadbull Logistics' => 'ROADRUNNER_FREIGHT' - ], + ], 'CAN' => [ - 'Canada Post' => 'CA_CANADA_POST', - 'Chit Chats' => 'CHITCHATS', - 'Corporate Couriers' => 'CORPORATECOURIERS_WEBHOOK', - 'Courant Plus' => 'COURANT_PLUS', - 'Estes Express Lines' => 'GLOBAL_ESTES', - 'GLS Logistic Systems Canada Ltd./Dicom' => 'DICOM', - 'Locus courier' => 'LOCUS_WEBHOOK', - 'Loomis Express' => 'LOOMIS_EXPRESS', - 'MBW Courier Inc.' => 'MBW', - 'Nationex courier' => 'NATIONEX', - 'ParcelPal' => 'PARCELPAL_WEBHOOK', - 'Rivo (Air canada)' => 'AIR_CANADA_GLOBAL', - 'Routific' => 'ROUTIFIC_WEBHOOK', - 'RPX Logistics' => 'RPXLOGISTICS', - 'Stallion Express' => 'STALLIONEXPRESS', - 'Ziing Final Mile Inc' => 'ZIINGFINALMILE' - ], + 'Canada Post' => 'CA_CANADA_POST', + 'Chit Chats' => 'CHITCHATS', + 'Corporate Couriers' => 'CORPORATECOURIERS_WEBHOOK', + 'Courant Plus' => 'COURANT_PLUS', + 'Estes Express Lines' => 'GLOBAL_ESTES', + 'GLS Logistic Systems Canada Ltd./Dicom' => 'DICOM', + 'Locus courier' => 'LOCUS_WEBHOOK', + 'Loomis Express' => 'LOOMIS_EXPRESS', + 'MBW Courier Inc.' => 'MBW', + 'Nationex courier' => 'NATIONEX', + 'ParcelPal' => 'PARCELPAL_WEBHOOK', + 'Rivo (Air canada)' => 'AIR_CANADA_GLOBAL', + 'Routific' => 'ROUTIFIC_WEBHOOK', + 'RPX Logistics' => 'RPXLOGISTICS', + 'Stallion Express' => 'STALLIONEXPRESS', + 'Ziing Final Mile Inc' => 'ZIINGFINALMILE' + ], 'CHL' => [ - 'Blue Express' => 'BLUEX', + 'Blue Express' => 'BLUEX', 'STARKEN couriers' => 'STARKEN' - ], + ], 'CHN' => [ - '17 Post Service' => 'CN_17POST', - 'ACS Worldwide Express' => 'ACSWORLDWIDE', - 'AliExpress Standard Shipping' => 'CAINIAO', - 'Anjun couriers' => 'ANJUN', - 'ANSERX courier' => 'ANSERX', - 'AuPost China' => 'AUPOST_CN', - 'BEL North Russia' => 'BEL_RS', - 'Best Express' => 'CN_BESTEXPRESS', - 'BoxC courier' => 'CN_BOXC', - 'buylogic' => 'BUYLOGIC', - 'Captain Express International' => 'CPEX', - 'CGS Express' => 'CGS_EXPRESS', - 'China Post' => 'CN_CHINA_POST_EMS', - 'Chukou1' => 'CHUKOU1', - 'CJ Packet' => 'CJPACKET', - 'Clevy Links' => 'CLEVY_LINKS', - 'CND Express' => 'CNDEXPRESS', - 'CNE Express' => 'CNEXPS', - 'CometTech' => 'COMET_TECH', - 'Cpacket couriers' => 'CPACKET', - 'Cuckoo Express' => 'CUCKOOEXPRESS', - 'DEX-I courier' => 'DEX_I', - 'DIDADI Logistics tech' => 'DIDADI', - 'DPE Express' => 'DPE_EXPRESS', - 'DTD Express' => 'DTD_EXPR', - 'EMPS Express' => 'EMPS_CN', - 'Equick China' => 'CN_EQUICK', - 'Eshipping' => 'ESHIPPING', - 'Eshun international Logistic' => 'ZES_EXPRESS', - 'FAR international' => 'FAR_INTERNATIONAL', - 'FarGood' => 'FARGOOD', - 'Fulfillme' => 'FULFILLME', - 'GANGBAO Supplychain' => 'GANGBAO', - 'GESWL Express' => 'GESWL', - 'GoFly' => 'CN_GOFLY', - 'Haidaibao' => 'HDB', - 'Haidaibao (BOX)' => 'HDB_BOX', - 'Hua Han Logistics' => 'HH_EXP', - 'HUAHANG EXPRESS' => 'HUAHAN_EXPRESS', - 'Huodull' => 'HUODULL', - 'HX Express' => 'HX_EXPRESS', - 'IDEX courier' => 'IDEXPRESS', - 'Intel-Valley Supply chain (ShenZhen) Co. Ltd' => 'INTEL_VALLEY', - 'J-Net' => 'J_NET', - 'jindouyun courier' => 'JINDOUYUN', - 'Joom Logistics' => 'JOOM_LOGIS', - 'Joying Box' => 'JOYING_BOX', - 'K1 Express' => 'K1_EXPRESS', - 'Kua Yue Express' => 'KY_EXPRESS', - 'Lalamove' => 'LALAMOVE', - 'leader' => 'LEADER', - 'lightning monkey' => 'SDH_SCM', - 'Logisters' => 'LOGISTERS', - 'LTIAN EXP' => 'LTIANEXP', - 'LTL COURIER' => 'LTL', - 'Morelink' => 'MORE_LINK', - 'MXE Express' => 'MXE', - 'Nanjing Woyuan' => 'NANJINGWOYUAN', - 'One World Express' => 'ONEWORLDEXPRESS', - 'padtf.com' => 'PADTF', - 'Pago Logistics' => 'PAGO', - 'Pan-Asia International' => 'PAN_ASIA', - 'PayPal Package' => 'CN_PAYPAL_PACKAGE', - 'PFC Express' => 'PFCEXPRESS', - 'Post56' => 'CN_POST56', - 'Qingdao HKD International Logistics' => 'HKD', - 'RETS express' => 'ETS_EXPRESS', - 'Ruston' => 'RUSTON', - 'SF Express (www.sf-express.com)' => 'CN_SF_EXPRESS', - 'SF International' => 'SFB2C', - 'SFC' => 'SFC_LOGISTICS', - 'SFC Service' => 'SFCSERVICE', - 'Shanghai Aqrum Chemical Logistics Co.Ltd' => 'DAJIN', - 'Sinotrans' => 'SINOTRANS', - 'STONE3PL' => 'STONE3PL', - 'Sunyou Post' => 'SYPOST', - 'TONDA GLOBAL' => 'TARRIVE', - 'Tophatter Express' => 'TOPHATTEREXPRESS', - 'TopYou' => 'TOPYOU', - 'ucexpress' => 'UC_EXPRE', - 'VIWO IoT' => 'VIWO', - 'WanbExpress' => 'WANBEXPRESS', - 'Weaship' => 'WEASHIP', - 'WeDo Logistics' => 'CN_WEDO', - 'WinIt' => 'WINIT', - 'Wise Express' => 'WISE_EXPRESS', - 'WishPost' => 'CN_WISHPOST', - 'XQ Express' => 'XQ_EXPRESS', - 'Yanwen Logistics' => 'YANWEN', - 'YDH express' => 'YDH_EXPRESS', - 'Yilian (Elian) Supply Chain' => 'ELIAN_POST', - 'yingnuo logistics' => 'YINGNUO_LOGISTICS', - 'YTO Express' => 'YTO', - 'Yunda Express' => 'CN_YUNDA', - 'YunExpress' => 'YUNEXPRESS', - 'ZJS International' => 'ZJS_EXPRESS', - 'ZTO Express' => 'ZTO_EXPRESS' - ], + '17 Post Service' => 'CN_17POST', + 'ACS Worldwide Express' => 'ACSWORLDWIDE', + 'AliExpress Standard Shipping' => 'CAINIAO', + 'Anjun couriers' => 'ANJUN', + 'ANSERX courier' => 'ANSERX', + 'AuPost China' => 'AUPOST_CN', + 'BEL North Russia' => 'BEL_RS', + 'Best Express' => 'CN_BESTEXPRESS', + 'BoxC courier' => 'CN_BOXC', + 'buylogic' => 'BUYLOGIC', + 'Captain Express International' => 'CPEX', + 'CGS Express' => 'CGS_EXPRESS', + 'China Post' => 'CN_CHINA_POST_EMS', + 'Chukou1' => 'CHUKOU1', + 'CJ Packet' => 'CJPACKET', + 'Clevy Links' => 'CLEVY_LINKS', + 'CND Express' => 'CNDEXPRESS', + 'CNE Express' => 'CNEXPS', + 'CometTech' => 'COMET_TECH', + 'Cpacket couriers' => 'CPACKET', + 'Cuckoo Express' => 'CUCKOOEXPRESS', + 'DEX-I courier' => 'DEX_I', + 'DIDADI Logistics tech' => 'DIDADI', + 'DPE Express' => 'DPE_EXPRESS', + 'DTD Express' => 'DTD_EXPR', + 'EMPS Express' => 'EMPS_CN', + 'Equick China' => 'CN_EQUICK', + 'Eshipping' => 'ESHIPPING', + 'Eshun international Logistic' => 'ZES_EXPRESS', + 'FAR international' => 'FAR_INTERNATIONAL', + 'FarGood' => 'FARGOOD', + 'Fulfillme' => 'FULFILLME', + 'GANGBAO Supplychain' => 'GANGBAO', + 'GESWL Express' => 'GESWL', + 'GoFly' => 'CN_GOFLY', + 'Haidaibao' => 'HDB', + 'Haidaibao (BOX)' => 'HDB_BOX', + 'Hua Han Logistics' => 'HH_EXP', + 'HUAHANG EXPRESS' => 'HUAHAN_EXPRESS', + 'Huodull' => 'HUODULL', + 'HX Express' => 'HX_EXPRESS', + 'IDEX courier' => 'IDEXPRESS', + 'Intel-Valley Supply chain (ShenZhen) Co. Ltd' => 'INTEL_VALLEY', + 'J-Net' => 'J_NET', + 'jindouyun courier' => 'JINDOUYUN', + 'Joom Logistics' => 'JOOM_LOGIS', + 'Joying Box' => 'JOYING_BOX', + 'K1 Express' => 'K1_EXPRESS', + 'Kua Yue Express' => 'KY_EXPRESS', + 'Lalamove' => 'LALAMOVE', + 'leader' => 'LEADER', + 'lightning monkey' => 'SDH_SCM', + 'Logisters' => 'LOGISTERS', + 'LTIAN EXP' => 'LTIANEXP', + 'LTL COURIER' => 'LTL', + 'Morelink' => 'MORE_LINK', + 'MXE Express' => 'MXE', + 'Nanjing Woyuan' => 'NANJINGWOYUAN', + 'One World Express' => 'ONEWORLDEXPRESS', + 'padtf.com' => 'PADTF', + 'Pago Logistics' => 'PAGO', + 'Pan-Asia International' => 'PAN_ASIA', + 'PayPal Package' => 'CN_PAYPAL_PACKAGE', + 'PFC Express' => 'PFCEXPRESS', + 'Post56' => 'CN_POST56', + 'Qingdao HKD International Logistics' => 'HKD', + 'RETS express' => 'ETS_EXPRESS', + 'Ruston' => 'RUSTON', + 'SF Express (www.sf-express.com)' => 'CN_SF_EXPRESS', + 'SF International' => 'SFB2C', + 'SFC' => 'SFC_LOGISTICS', + 'SFC Service' => 'SFCSERVICE', + 'Shanghai Aqrum Chemical Logistics Co.Ltd' => 'DAJIN', + 'Sinotrans' => 'SINOTRANS', + 'STONE3PL' => 'STONE3PL', + 'Sunyou Post' => 'SYPOST', + 'TONDA GLOBAL' => 'TARRIVE', + 'Tophatter Express' => 'TOPHATTEREXPRESS', + 'TopYou' => 'TOPYOU', + 'ucexpress' => 'UC_EXPRE', + 'VIWO IoT' => 'VIWO', + 'WanbExpress' => 'WANBEXPRESS', + 'Weaship' => 'WEASHIP', + 'WeDo Logistics' => 'CN_WEDO', + 'WinIt' => 'WINIT', + 'Wise Express' => 'WISE_EXPRESS', + 'WishPost' => 'CN_WISHPOST', + 'XQ Express' => 'XQ_EXPRESS', + 'Yanwen Logistics' => 'YANWEN', + 'YDH express' => 'YDH_EXPRESS', + 'Yilian (Elian) Supply Chain' => 'ELIAN_POST', + 'yingnuo logistics' => 'YINGNUO_LOGISTICS', + 'YTO Express' => 'YTO', + 'Yunda Express' => 'CN_YUNDA', + 'YunExpress' => 'YUNEXPRESS', + 'ZJS International' => 'ZJS_EXPRESS', + 'ZTO Express' => 'ZTO_EXPRESS' + ], 'COL' => [ 'Coordinadora' => 'COORDINADORA' - ], + ], 'HRV' => [ - 'GLS Croatia' => 'GLS_CROTIA', - 'Hrvatska posta' => 'HRV_HRVATSKA', + 'GLS Croatia' => 'GLS_CROTIA', + 'Hrvatska posta' => 'HRV_HRVATSKA', 'Overseas Express' => 'OVERSE_EXP' - ], + ], 'CYP' => [ 'cyprus post' => 'CYPRUS_POST_CYP' - ], + ], 'CZE' => [ - 'Czech Post' => 'CESKA_CZ', + 'Czech Post' => 'CESKA_CZ', 'GLS Czech Republic' => 'GLS_CZ' - ], + ], 'DNK' => [ - 'Budbee courier' => 'BUDBEE_WEBHOOK', - 'Danske Fragtaend' => 'DANSKE_FRAGT', - 'ostnord denmark' => 'POSTNORD_LOGISTICS_DK', - 'PostNord Logistics' => 'POSTNORD_LOGISTICS', - 'Xpressen courier' => 'XPRESSEN_DK' - ], + 'Budbee courier' => 'BUDBEE_WEBHOOK', + 'Danske Fragtaend' => 'DANSKE_FRAGT', + 'ostnord denmark' => 'POSTNORD_LOGISTICS_DK', + 'PostNord Logistics' => 'POSTNORD_LOGISTICS', + 'Xpressen courier' => 'XPRESSEN_DK' + ], 'EST' => [ 'Omniva' => 'OMNIVA' - ], + ], 'FIN' => [ - 'Matkahuolto' => 'MATKAHUOLTO', + 'Matkahuolto' => 'MATKAHUOLTO', 'Posti courier' => 'POSTI' - ], + ], 'FRA' => [ - 'Chronopost france (www.chronopost.fr)' => 'CHRONOPOST_FR', - 'Colis Privé' => 'COLIS_PRIVE', - 'Colissimo' => 'FR_COLIS', - 'Cubyn' => 'CUBYN', - 'DPD France' => 'DPD_FR', - 'DPD France (formerly exapaq)' => 'FR_EXAPAQ', - 'Geodis E-space' => 'GEODIS_ESPACE', - 'Heppner France' => 'HEPPNER_FR', - 'La Poste' => 'LA_POSTE_SUIVI', - 'TNT France' => 'TNT_FR', - 'VIR Transport' => 'VIRTRANSPORT' - ], + 'Chronopost france (www.chronopost.fr)' => 'CHRONOPOST_FR', + 'Colis Privé' => 'COLIS_PRIVE', + 'Colissimo' => 'FR_COLIS', + 'Cubyn' => 'CUBYN', + 'DPD France' => 'DPD_FR', + 'DPD France (formerly exapaq)' => 'FR_EXAPAQ', + 'Geodis E-space' => 'GEODIS_ESPACE', + 'Heppner France' => 'HEPPNER_FR', + 'La Poste' => 'LA_POSTE_SUIVI', + 'TNT France' => 'TNT_FR', + 'VIR Transport' => 'VIRTRANSPORT' + ], 'DEU' => [ - 'Hermes Germany' => 'HERMES_DE', - 'AO Deutschland' => 'AO_DEUTSCHLAND', - 'DPD Germany' => 'DE_DPD_DELISTRACK', - 'Fiege Logistics' => 'FIEGE', - 'Geis CZ' => 'GEIS', - 'Gel Express Logistik' => 'GEL_EXPRESS', - 'Go!Express and logistics' => 'GENERAL_OVERNIGHT', - 'Heppner Internationale Spedition GmbH & Co.' => 'HEPPNER', - 'Hermes Einrichtungs Service GmbH & Co. KG' => 'HERMES_2MANN_HANDLING', - 'Innight Express Germany GmbH (nox NachtExpress)' => 'NOX_NACHTEXPRESS', - 'liefery' => 'LIEFERY', - 'NOX NightTimeExpress' => 'NOX_NIGHT_TIME_EXPRESS', - 'PARCEL ONE' => 'PARCELONE', - 'Pressio' => 'PRESSIODE', - 'Raben Group' => 'RABEN_GROUP', - 'Streck Transport' => 'STRECK_TRANSPORT', - 'Swiship DE' => 'SWISHIP_DE' - ], + 'Hermes Germany' => 'HERMES_DE', + 'AO Deutschland' => 'AO_DEUTSCHLAND', + 'DPD Germany' => 'DE_DPD_DELISTRACK', + 'Fiege Logistics' => 'FIEGE', + 'Geis CZ' => 'GEIS', + 'Gel Express Logistik' => 'GEL_EXPRESS', + 'Go!Express and logistics' => 'GENERAL_OVERNIGHT', + 'Heppner Internationale Spedition GmbH & Co.' => 'HEPPNER', + 'Hermes Einrichtungs Service GmbH & Co. KG' => 'HERMES_2MANN_HANDLING', + 'Innight Express Germany GmbH (nox NachtExpress)' => 'NOX_NACHTEXPRESS', + 'liefery' => 'LIEFERY', + 'NOX NightTimeExpress' => 'NOX_NIGHT_TIME_EXPRESS', + 'PARCEL ONE' => 'PARCELONE', + 'Pressio' => 'PRESSIODE', + 'Raben Group' => 'RABEN_GROUP', + 'Streck Transport' => 'STRECK_TRANSPORT', + 'Swiship DE' => 'SWISHIP_DE' + ], 'GRC' => [ - 'ACS Courier' => 'ACS_GR', - 'Easy Mail' => 'EASY_MAIL', - 'Geniki Taxydromiki' => 'GENIKI_GR', - 'Speed Couriers' => 'SPEEDCOURIERS_GR', - 'SPEEDEX couriers' => 'SPEEDEXCOURIER' - ], + 'ACS Courier' => 'ACS_GR', + 'Easy Mail' => 'EASY_MAIL', + 'Geniki Taxydromiki' => 'GENIKI_GR', + 'Speed Couriers' => 'SPEEDCOURIERS_GR', + 'SPEEDEX couriers' => 'SPEEDEXCOURIER' + ], 'HKG' => [ - 'CFL Logistics' => 'CFL_LOGISTICS', - 'CJ Logistics International(Hong Kong)' => 'CJ_HK_INTERNATIONAL', - 'CL E-Logistics Solutions Limited' => 'CLE_LOGISTICS', - 'Continental' => 'CONTINENTAL', - 'Cosmetics Now' => 'COSTMETICSNOW', - 'DealerSend' => 'DEALERSEND', - 'DHL eCommerce Asia (API)' => 'DHL_ECOMERCE_ASA', - 'DHL Global Mail Asia (www.dhl.com)' => 'DHL_GLOBAL_MAIL_ASIA', - 'DHL HonKong' => 'DHL_HK', - 'DPD HongKong' => 'DPD_HK', - 'DTDC express' => 'DTDC_EXPRESS', - 'Globavend' => 'GLOBAVEND', - 'Hongkong Post (www.hongkongpost.hk)' => 'HK_POST', - 'Janco Ecommerce' => 'JANCO', - 'JS EXPRESS' => 'JS_EXPRESS', - 'KEC courier' => 'KEC', - 'Kerry eCommerce' => 'KERRY_ECOMMERCE', - 'LHT Express' => 'LHT_EXPRESS', - 'Logistic Worldwide Express (LWE Honkong)' => 'LOGISTICSWORLDWIDE_HK', - 'Mainway' => 'MAINWAY', - 'Morning Express' => 'MORNING_EXPRESS', - 'OkayParcel' => 'OKAYPARCEL', - 'Omni Parcel' => 'OMNIPARCEL', - 'PAL Express Limited' => 'PALEXPRESS', - 'Pickupp' => 'PICKUP', - 'Quantium' => 'QUANTIUM', - 'RPX Online' => 'RPX', - 'SEKO Logistics' => 'SEKOLOGISTICS', - 'Ship It Asia' => 'SHIP_IT_ASIA', - 'Smooth Couriers' => 'SMOOTH', - 'STEP FORWARD FREIGHT SERVICE CO LTD' => 'STEPFORWARDFS', - 'Zeek courier' => 'SFPLUS_WEBHOOK', - 'Zeek2Door' => 'ZEEK_2_DOOR' - ], + 'CFL Logistics' => 'CFL_LOGISTICS', + 'CJ Logistics International(Hong Kong)' => 'CJ_HK_INTERNATIONAL', + 'CL E-Logistics Solutions Limited' => 'CLE_LOGISTICS', + 'Continental' => 'CONTINENTAL', + 'Cosmetics Now' => 'COSTMETICSNOW', + 'DealerSend' => 'DEALERSEND', + 'DHL eCommerce Asia (API)' => 'DHL_ECOMERCE_ASA', + 'DHL Global Mail Asia (www.dhl.com)' => 'DHL_GLOBAL_MAIL_ASIA', + 'DHL HonKong' => 'DHL_HK', + 'DPD HongKong' => 'DPD_HK', + 'DTDC express' => 'DTDC_EXPRESS', + 'Globavend' => 'GLOBAVEND', + 'Hongkong Post (www.hongkongpost.hk)' => 'HK_POST', + 'Janco Ecommerce' => 'JANCO', + 'JS EXPRESS' => 'JS_EXPRESS', + 'KEC courier' => 'KEC', + 'Kerry eCommerce' => 'KERRY_ECOMMERCE', + 'LHT Express' => 'LHT_EXPRESS', + 'Logistic Worldwide Express (LWE Honkong)' => 'LOGISTICSWORLDWIDE_HK', + 'Mainway' => 'MAINWAY', + 'Morning Express' => 'MORNING_EXPRESS', + 'OkayParcel' => 'OKAYPARCEL', + 'Omni Parcel' => 'OMNIPARCEL', + 'PAL Express Limited' => 'PALEXPRESS', + 'Pickupp' => 'PICKUP', + 'Quantium' => 'QUANTIUM', + 'RPX Online' => 'RPX', + 'SEKO Logistics' => 'SEKOLOGISTICS', + 'Ship It Asia' => 'SHIP_IT_ASIA', + 'Smooth Couriers' => 'SMOOTH', + 'STEP FORWARD FREIGHT SERVICE CO LTD' => 'STEPFORWARDFS', + 'Zeek courier' => 'SFPLUS_WEBHOOK', + 'Zeek2Door' => 'ZEEK_2_DOOR' + ], 'HUN' => [ - 'DPD Hungary' => 'DPD_HGRY', + 'DPD Hungary' => 'DPD_HGRY', 'Magyar Post' => 'MAGYAR_HU' - ], + ], 'IND' => [ - 'Bombino Express Pvt' => 'BOMBINOEXP', - 'Delhivery India' => 'IND_DELHIVERY', - 'DELIVERYONTIME LOGISTICS PVT LTD' => 'DELIVERYONTIME', - 'DTDC India' => 'DTDC_IN', - 'Ecom Express' => 'IND_ECOM', - 'Ekart logistics (ekartlogistics.com)' => 'EKART', - 'First Flight Couriers' => 'IND_FIRSTFLIGHT', - 'Gati-KWE' => 'IND_GATI', - 'GoJavas' => 'IND_GOJAVAS', - 'Holisol' => 'HOLISOL', - 'LexShip' => 'LEXSHIP', - 'OCS ANA Group' => 'OCS', - 'Parcelled.in' => 'PARCELLED_IN', - 'Pickrr' => 'PICKRR', - 'Safexpress' => 'IND_SAFEEXPRESS', - 'Scudex Express' => 'SCUDEX_EXPRESS', - 'Shree Anjani Courier' => 'SHREE_ANJANI_COURIER', - 'Shree Maruti Courier Services Pvt Ltd' => 'SHREE_MARUTI', - 'SHREE NANDAN COURIER' => 'SHREENANDANCOURIER', - 'SHREE TIRUPATI COURIER SERVICES PVT. LTD.' => 'SHREETIRUPATI', - 'SPOTON Logistics Pvt Ltd' => 'SPOTON', - 'Trackon Couriers Pvt. Ltd' => 'TRACKON' - ], + 'Bombino Express Pvt' => 'BOMBINOEXP', + 'Delhivery India' => 'IND_DELHIVERY', + 'DELIVERYONTIME LOGISTICS PVT LTD' => 'DELIVERYONTIME', + 'DTDC India' => 'DTDC_IN', + 'Ecom Express' => 'IND_ECOM', + 'Ekart logistics (ekartlogistics.com)' => 'EKART', + 'First Flight Couriers' => 'IND_FIRSTFLIGHT', + 'Gati-KWE' => 'IND_GATI', + 'GoJavas' => 'IND_GOJAVAS', + 'Holisol' => 'HOLISOL', + 'LexShip' => 'LEXSHIP', + 'OCS ANA Group' => 'OCS', + 'Parcelled.in' => 'PARCELLED_IN', + 'Pickrr' => 'PICKRR', + 'Safexpress' => 'IND_SAFEEXPRESS', + 'Scudex Express' => 'SCUDEX_EXPRESS', + 'Shree Anjani Courier' => 'SHREE_ANJANI_COURIER', + 'Shree Maruti Courier Services Pvt Ltd' => 'SHREE_MARUTI', + 'SHREE NANDAN COURIER' => 'SHREENANDANCOURIER', + 'SHREE TIRUPATI COURIER SERVICES PVT. LTD.' => 'SHREETIRUPATI', + 'SPOTON Logistics Pvt Ltd' => 'SPOTON', + 'Trackon Couriers Pvt. Ltd' => 'TRACKON' + ], 'IDN' => [ - 'AlfaTrex' => 'ALFATREX', - 'Choir Express Indonesia' => 'CHOIR_EXP', - 'INDOPAKET' => 'INDOPAKET', - 'JX courier' => 'JX', - 'KURASI' => 'KURASI', - 'Ninja Van Indonesia' => 'NINJAVAN_ID', - 'Ninjavan Webhook' => 'NINJAVAN_WB', - 'PT MGLOBAL LOGISTICS INDONESIA' => 'MGLOBAL', - 'PT Prima Multi Cipta' => 'PRIMAMULTICIPTA', - 'Red Carpet Logistics' => 'RCL', - 'RPX Indonesia' => 'RPX_ID', - 'SAP EXPRESS' => 'SAP_EXPRESS', - 'Sin Global Express' => 'SIN_GLBL', - 'Tiki shipment' => 'TIKI_ID', - 'Trans Kargo Internasional' => 'TRANS_KARGO', + 'AlfaTrex' => 'ALFATREX', + 'Choir Express Indonesia' => 'CHOIR_EXP', + 'INDOPAKET' => 'INDOPAKET', + 'JX courier' => 'JX', + 'KURASI' => 'KURASI', + 'Ninja Van Indonesia' => 'NINJAVAN_ID', + 'Ninjavan Webhook' => 'NINJAVAN_WB', + 'PT MGLOBAL LOGISTICS INDONESIA' => 'MGLOBAL', + 'PT Prima Multi Cipta' => 'PRIMAMULTICIPTA', + 'Red Carpet Logistics' => 'RCL', + 'RPX Indonesia' => 'RPX_ID', + 'SAP EXPRESS' => 'SAP_EXPRESS', + 'Sin Global Express' => 'SIN_GLBL', + 'Tiki shipment' => 'TIKI_ID', + 'Trans Kargo Internasional' => 'TRANS_KARGO', 'Wahana express (www.wahana.com)' => 'WAHANA_ID' - ], + ], 'IRL' => [ - 'An Post' => 'AN_POST', - 'DPD Ireland' => 'DPD_IR', - 'Fastway Ireland' => 'FASTWAY_IR', - 'Wiseloads' => 'WISELOADS' - ], + 'An Post' => 'AN_POST', + 'DPD Ireland' => 'DPD_IR', + 'Fastway Ireland' => 'FASTWAY_IR', + 'Wiseloads' => 'WISELOADS' + ], 'ISR' => [ - 'Israel Post' => 'ISRAEL_POST', + 'Israel Post' => 'ISRAEL_POST', 'Israel Post Domestic' => 'ISR_POST_DOMESTIC' - ], + ], 'ITA' => [ - 'BRT Bartolini(Parcel ID)' => 'BRT_IT_PARCELID', - 'BRT couriers Italy (www.brt.it)' => 'BRT_IT', - 'Arco Spedizioni SP' => 'ARCO_SPEDIZIONI', - 'Blink' => 'BLINKLASTMILE', - 'BRT Bartolini(Sender Reference)' => 'BRT_IT_SENDER_REF', - 'DMM Network' => 'DMM_NETWORK', - 'GLS Italy' => 'GLS_ITALY', - 'HR Parcel' => 'HRPARCEL', - 'i-dika' => 'I_DIKA', - 'LICCARDI EXPRESS COURIER' => 'LICCARDI_EXPRESS', - 'Milkman courier' => 'MILKMAN', - 'Nexive (TNT Post Italy)' => 'IT_NEXIVE', - 'Poste italiane (www.poste.it)' => 'IT_POSTE_ITALIA', - 'SAILPOST' => 'SAILPOST', - 'SDA Italy' => 'SDA_IT', - 'TNT-Click Italy' => 'TNT_CLICK_IT' - ], + 'BRT Bartolini(Parcel ID)' => 'BRT_IT_PARCELID', + 'BRT couriers Italy (www.brt.it)' => 'BRT_IT', + 'Arco Spedizioni SP' => 'ARCO_SPEDIZIONI', + 'Blink' => 'BLINKLASTMILE', + 'BRT Bartolini(Sender Reference)' => 'BRT_IT_SENDER_REF', + 'DMM Network' => 'DMM_NETWORK', + 'GLS Italy' => 'GLS_ITALY', + 'HR Parcel' => 'HRPARCEL', + 'i-dika' => 'I_DIKA', + 'LICCARDI EXPRESS COURIER' => 'LICCARDI_EXPRESS', + 'Milkman courier' => 'MILKMAN', + 'Nexive (TNT Post Italy)' => 'IT_NEXIVE', + 'Poste italiane (www.poste.it)' => 'IT_POSTE_ITALIA', + 'SAILPOST' => 'SAILPOST', + 'SDA Italy' => 'SDA_IT', + 'TNT-Click Italy' => 'TNT_CLICK_IT' + ], 'JPN' => [ - 'eFEx (E-Commerce Fulfillment & Express)' => 'EFEX', - 'Japan Post' => 'JPN_JAPAN_POST', - 'KWE Global' => 'KWE_GLOBAL', - 'MailPlus' => 'MAIL_PLUS', - 'MailPlus (Japan)' => 'MAILPLUS_JPN', - 'Seino' => 'SEINO' - ], + 'eFEx (E-Commerce Fulfillment & Express)' => 'EFEX', + 'Japan Post' => 'JPN_JAPAN_POST', + 'KWE Global' => 'KWE_GLOBAL', + 'MailPlus' => 'MAIL_PLUS', + 'MailPlus (Japan)' => 'MAILPLUS_JPN', + 'Seino' => 'SEINO' + ], 'JEY' => [ 'Jersey Post' => 'JERSEY_POST' - ], + ], 'KOR' => [ - 'Cello Square' => 'CELLO_SQUARE', - 'Croshot' => 'CROSHOT', - 'Doora Logistics' => 'DOORA', - 'eParcel Korea' => 'EPARCEL_KR', - 'Korea Post' => 'KPOST', - 'Koreapost (www.koreapost.go.kr)' => 'KR_KOREA_POST', - 'Kyungdong Parcel' => 'KYUNGDONG_PARCEL', - 'Lotte Global Logistics' => 'LOTTE', - 'Rincos' => 'RINCOS', - 'Rocket Parcel International' => 'ROCKET_PARCEL', - 'ShipGate' => 'SHIP_GATE', - 'SHIPTER' => 'SHIPTER', - 'SRE Korea (www.srekorea.co.kr)' => 'SRE_KOREA', - 'Tolos courier' => 'TOLOS' - ], + 'Cello Square' => 'CELLO_SQUARE', + 'Croshot' => 'CROSHOT', + 'Doora Logistics' => 'DOORA', + 'eParcel Korea' => 'EPARCEL_KR', + 'Korea Post' => 'KPOST', + 'Koreapost (www.koreapost.go.kr)' => 'KR_KOREA_POST', + 'Kyungdong Parcel' => 'KYUNGDONG_PARCEL', + 'Lotte Global Logistics' => 'LOTTE', + 'Rincos' => 'RINCOS', + 'Rocket Parcel International' => 'ROCKET_PARCEL', + 'ShipGate' => 'SHIP_GATE', + 'SHIPTER' => 'SHIPTER', + 'SRE Korea (www.srekorea.co.kr)' => 'SRE_KOREA', + 'Tolos courier' => 'TOLOS' + ], 'KWT' => [ 'Posta Plus' => 'POSTA_PLUS' - ], + ], 'LAO' => [ 'Lao Post' => 'LAO_POST' - ], + ], 'LVA' => [ - 'CDEK courier' => 'CDEK', + 'CDEK courier' => 'CDEK', 'Latvijas Pasts' => 'LATVIJAS_PASTS' - ], + ], 'LTU' => [ 'Venipak' => 'VENIPAK' - ], + ], 'MYS' => [ - 'ABX Express' => 'ABXEXPRESS_MY', - 'Airpak Express' => 'MYS_AIRPAK', - 'City-Link Express' => 'CITYLINK_MY', - 'CJ Century' => 'CJ_CENTURY', - 'CJ International malaysia' => 'CJ_INT_MY', - 'CollectCo' => 'COLLECTCO', - 'FMX' => 'FMX', - 'GDEX courier' => 'MYS_GDEX', - 'J&T EXPRESS MALAYSIA' => 'JTEXPRESS', - 'JINSUNG TRADING' => 'JINSUNG', - 'Jocom' => 'JOCOM', - 'Kangaroo Worldwide Express' => 'KANGAROO_MY', - 'Line Clear Express & Logistics Sdn Bhd' => 'LINE', - 'Logistika' => 'LOGISTIKA', - 'M Xpress Sdn Bhd' => 'M_XPRESS', - 'Malaysia Post' => 'MYS_MYS_POST', - 'Matdespatch' => 'MATDESPATCH', - 'Mypostonline' => 'MYS_MYPOST_ONLINE', - 'Nationwide Express Courier Services Bhd (www.nationwide.com.my)' => 'NATIONWIDE_MY', - 'ninja van (www.ninjavan.co)' => 'NINJAVAN_MY', - 'PICK UPP' => 'PICKUPP_MYS', - 'Skynet Malaysia' => 'MYS_SKYNET', - 'TAQBIN Malaysia' => 'TAQBIN_MY', - 'WePost Sdn Bhd' => 'WEPOST', - 'Wyngs' => 'WYNGS', - 'ZeptoExpress' => 'ZEPTO_EXPRESS' - ], + 'ABX Express' => 'ABXEXPRESS_MY', + 'Airpak Express' => 'MYS_AIRPAK', + 'City-Link Express' => 'CITYLINK_MY', + 'CJ Century' => 'CJ_CENTURY', + 'CJ International malaysia' => 'CJ_INT_MY', + 'CollectCo' => 'COLLECTCO', + 'FMX' => 'FMX', + 'GDEX courier' => 'MYS_GDEX', + 'J&T EXPRESS MALAYSIA' => 'JTEXPRESS', + 'JINSUNG TRADING' => 'JINSUNG', + 'Jocom' => 'JOCOM', + 'Kangaroo Worldwide Express' => 'KANGAROO_MY', + 'Line Clear Express & Logistics Sdn Bhd' => 'LINE', + 'Logistika' => 'LOGISTIKA', + 'M Xpress Sdn Bhd' => 'M_XPRESS', + 'Malaysia Post' => 'MYS_MYS_POST', + 'Matdespatch' => 'MATDESPATCH', + 'Mypostonline' => 'MYS_MYPOST_ONLINE', + 'Nationwide Express Courier Services Bhd (www.nationwide.com.my)' => 'NATIONWIDE_MY', + 'ninja van (www.ninjavan.co)' => 'NINJAVAN_MY', + 'PICK UPP' => 'PICKUPP_MYS', + 'Skynet Malaysia' => 'MYS_SKYNET', + 'TAQBIN Malaysia' => 'TAQBIN_MY', + 'WePost Sdn Bhd' => 'WEPOST', + 'Wyngs' => 'WYNGS', + 'ZeptoExpress' => 'ZEPTO_EXPRESS' + ], 'MEX' => [ - 'correos mexico' => 'CORREOS_DE_MEXICO', - 'Estafeta (www.estafeta.com)' => 'MEX_ESTAFETA', - 'Grupo ampm' => 'GRUPO', - 'Hound Express' => 'HOUNDEXPRESS', - 'Ivoy courier' => 'IVOY_WEBHOOK', - 'mexico senda express' => 'MEX_SENDA', - 'Paquetexpress' => 'PAQUETEXPRESS', - 'Redpack' => 'MEX_REDPACK' - ], + 'correos mexico' => 'CORREOS_DE_MEXICO', + 'Estafeta (www.estafeta.com)' => 'MEX_ESTAFETA', + 'Grupo ampm' => 'GRUPO', + 'Hound Express' => 'HOUNDEXPRESS', + 'Ivoy courier' => 'IVOY_WEBHOOK', + 'mexico senda express' => 'MEX_SENDA', + 'Paquetexpress' => 'PAQUETEXPRESS', + 'Redpack' => 'MEX_REDPACK' + ], 'NLD' => [ - 'Brouwer Transport en Logistiek' => 'BROUWER_TRANSPORT', - 'DHL Netherland' => 'NLD_DHL', - 'Fiege Netherlands' => 'FIEGE_NL', - 'GLS Netherland' => 'NLD_GLS', - 'Happy 2ThePoint' => 'HAPPY2POINT', - 'Paper Express' => 'PAPER_EXPRESS', - 'PostNL International 3S' => 'POSTNL_INTL_3S', - 'Trunkrs courier' => 'TRUNKRS_WEBHOOK' - ], + 'Brouwer Transport en Logistiek' => 'BROUWER_TRANSPORT', + 'DHL Netherland' => 'NLD_DHL', + 'Fiege Netherlands' => 'FIEGE_NL', + 'GLS Netherland' => 'NLD_GLS', + 'Happy 2ThePoint' => 'HAPPY2POINT', + 'Paper Express' => 'PAPER_EXPRESS', + 'PostNL International 3S' => 'POSTNL_INTL_3S', + 'Trunkrs courier' => 'TRUNKRS_WEBHOOK' + ], 'NZL' => [ - 'Fastway New Zealand' => 'FASTWAY_NZ', - 'Interparcel New Zealand' => 'INTERPARCEL_NZ', - 'Mainfreight' => 'MAINFREIGHT', - 'New Zealand Post' => 'NZ_NZ_POST', - 'Toll New Zealand' => 'TOLL_NZ' - ], + 'Fastway New Zealand' => 'FASTWAY_NZ', + 'Interparcel New Zealand' => 'INTERPARCEL_NZ', + 'Mainfreight' => 'MAINFREIGHT', + 'New Zealand Post' => 'NZ_NZ_POST', + 'Toll New Zealand' => 'TOLL_NZ' + ], 'NGA' => [ 'NIpost (www.nipost.gov.ng)' => 'NIPOST_NG' - ], + ], 'NOR' => [ 'Helthjem' => 'HELTHJEM' - ], + ], 'PAK' => [ - 'forrun Pvt Ltd (Arpatech Venture)' => 'FORRUN', - 'TCS courier' => 'TCS' - ], + 'forrun Pvt Ltd (Arpatech Venture)' => 'FORRUN', + 'TCS courier' => 'TCS' + ], 'PRY' => [ 'AEX Group' => 'AEX' - ], + ], 'PHL' => [ - '2GO Courier' => 'TWO_GO', - 'Jam Express Philippines' => 'PHL_JAMEXPRESS', - 'PIXSELL LOGISTICS' => 'PIXSELL', - 'RAF Philippines' => 'RAF_PH', - 'Ximex Delivery Express' => 'XDE_WEBHOOK', - 'Xpost.ph' => 'XPOST' - ], + '2GO Courier' => 'TWO_GO', + 'Jam Express Philippines' => 'PHL_JAMEXPRESS', + 'PIXSELL LOGISTICS' => 'PIXSELL', + 'RAF Philippines' => 'RAF_PH', + 'Ximex Delivery Express' => 'XDE_WEBHOOK', + 'Xpost.ph' => 'XPOST' + ], 'POL' => [ - 'DHL Poland' => 'DHL_PL', - 'DPD Poland' => 'DPD_POLAND', - 'FedEx® Poland Domestic' => 'FEDEX_POLAND', - 'InPost Paczkomaty' => 'INPOST_PACZKOMATY', - 'Poczta Polska (www.poczta-polska.pl)' => 'PL_POCZTA_POLSKA', - 'Royal Mail' => 'ROYAL_MAIL' - ], + 'DHL Poland' => 'DHL_PL', + 'DPD Poland' => 'DPD_POLAND', + 'FedEx® Poland Domestic' => 'FEDEX_POLAND', + 'InPost Paczkomaty' => 'INPOST_PACZKOMATY', + 'Poczta Polska (www.poczta-polska.pl)' => 'PL_POCZTA_POLSKA', + 'Royal Mail' => 'ROYAL_MAIL' + ], 'PRT' => [ - 'Adicional Logistics' => 'ADICIONAL', - 'Bneed courier' => 'BNEED', - 'Carriers courier' => 'CARRIERS', - 'Chronopost Portugal' => 'PRT_CHRONOPOST', - 'CTT Portugal' => 'PRT_CTT', - 'Delnext' => 'DELNEXT' - ], + 'Adicional Logistics' => 'ADICIONAL', + 'Bneed courier' => 'BNEED', + 'Carriers courier' => 'CARRIERS', + 'Chronopost Portugal' => 'PRT_CHRONOPOST', + 'CTT Portugal' => 'PRT_CTT', + 'Delnext' => 'DELNEXT' + ], 'ROU' => [ - 'DPD Romania' => 'DPD_RO', + 'DPD Romania' => 'DPD_RO', 'Post Roman (www.posta-romana.ro)' => 'POSTA_RO' - ], + ], 'RUS' => [ - 'Boxberry courier' => 'BOX_BERRY', - 'CSE courier' => 'CSE', - 'DHL Parcel Russia' => 'DHL_PARCEL_RU', - 'DobroPost' => 'DOBROPOST', - 'DPD Russia' => 'DPD_RU', - 'Expresssale' => 'EXPRESSSALE', - 'GBS-Broker' => 'GBS_BROKER', - 'Pony express' => 'PONY_EXPRESS', - 'ShopfansRU LLC' => 'SHOPFANS' - ], + 'Boxberry courier' => 'BOX_BERRY', + 'CSE courier' => 'CSE', + 'DHL Parcel Russia' => 'DHL_PARCEL_RU', + 'DobroPost' => 'DOBROPOST', + 'DPD Russia' => 'DPD_RU', + 'Expresssale' => 'EXPRESSSALE', + 'GBS-Broker' => 'GBS_BROKER', + 'Pony express' => 'PONY_EXPRESS', + 'ShopfansRU LLC' => 'SHOPFANS' + ], 'SAU' => [ - 'Saudi Post' => 'SAU_SAUDI_POST', - 'SMSA Express' => 'SMSA_EXPRESS', - 'Thabit Logistics' => 'THABIT_LOGISTICS', + 'Saudi Post' => 'SAU_SAUDI_POST', + 'SMSA Express' => 'SMSA_EXPRESS', + 'Thabit Logistics' => 'THABIT_LOGISTICS', 'Zajil Express Company' => 'ZAJIL_EXPRESS' - ], + ], 'SRB' => [ 'Posta Serbia' => 'POST_SERBIA' - ], + ], 'SGP' => [ - 'Cloudwish Asia' => 'CLOUDWISH_ASIA', - 'Detrack' => 'SG_DETRACK', - 'Fonsen Logistics' => 'FONSEN', - 'Grab courier' => 'GRAB_WEBHOOK', - 'J&T Express Singapore' => 'SIMPLYPOST', - 'Janio Asia' => 'JANIO', - 'Jayon Express (JEX)' => 'IND_JAYONEXPRESS', - 'Jet-Ship Worldwide' => 'JET_SHIP', - 'KGM Hub' => 'KGMHUB', - 'Legion Express' => 'LEGION_EXPRESS', - 'Nhans Solutions' => 'NHANS_SOLUTIONS', - 'Ninja van Singapore' => 'NINJAVAN_SG', - 'Parcel Post Singapore' => 'PARCELPOST_SG', - 'Park N Parcel' => 'PARKNPARCEL', - 'PICK UPP (Singapore)' => 'PICKUPP_SGP', - 'Qxpress' => 'SG_QXPRESS', - 'RaidereX' => 'RAIDEREX', - 'Red Carpet Logistics' => 'ROADBULL', - 'RZY Express' => 'RZYEXPRESS', - 'Singapore Post' => 'SG_SG_POST', - 'Singapore Speedpost' => 'SG_SPEEDPOST', - 'TCK Express' => 'TCK_EXPRESS', - 'Urbanfox' => 'COUREX', - 'WMG Delivery' => 'WMG', - 'Zyllem' => 'ZYLLEM' - ], + 'Cloudwish Asia' => 'CLOUDWISH_ASIA', + 'Detrack' => 'SG_DETRACK', + 'Fonsen Logistics' => 'FONSEN', + 'Grab courier' => 'GRAB_WEBHOOK', + 'J&T Express Singapore' => 'SIMPLYPOST', + 'Janio Asia' => 'JANIO', + 'Jayon Express (JEX)' => 'IND_JAYONEXPRESS', + 'Jet-Ship Worldwide' => 'JET_SHIP', + 'KGM Hub' => 'KGMHUB', + 'Legion Express' => 'LEGION_EXPRESS', + 'Nhans Solutions' => 'NHANS_SOLUTIONS', + 'Ninja van Singapore' => 'NINJAVAN_SG', + 'Parcel Post Singapore' => 'PARCELPOST_SG', + 'Park N Parcel' => 'PARKNPARCEL', + 'PICK UPP (Singapore)' => 'PICKUPP_SGP', + 'Qxpress' => 'SG_QXPRESS', + 'RaidereX' => 'RAIDEREX', + 'Red Carpet Logistics' => 'ROADBULL', + 'RZY Express' => 'RZYEXPRESS', + 'Singapore Post' => 'SG_SG_POST', + 'Singapore Speedpost' => 'SG_SPEEDPOST', + 'TCK Express' => 'TCK_EXPRESS', + 'Urbanfox' => 'COUREX', + 'WMG Delivery' => 'WMG', + 'Zyllem' => 'ZYLLEM' + ], 'SVK' => [ 'GLS General Logistics Systems Slovakia s.r.o.' => 'GLS_SLOV' - ], + ], 'SVN' => [ - 'GLS Slovenia' => 'GLS_SLOVEN', + 'GLS Slovenia' => 'GLS_SLOVEN', 'Post of Slovenia' => 'POST_SLOVENIA' - ], + ], 'ZAF' => [ - 'Courier IT' => 'ZA_COURIERIT', - 'Dawn Wing' => 'DAWN_WING', - 'DPE South Africa' => 'DPE_SOUTH_AFRC', - 'Internet Express' => 'INTEXPRESS', - 'MDS Collivery Pty (Ltd)' => 'COLLIVERY', - 'RAM courier' => 'RAM', - 'Skynet World Wide Express South Africa' => 'SKYNET_ZA', - 'South African Post Office' => 'SOUTH_AFRICAN_POST_OFFICE', - 'Specialised Freight' => 'ZA_SPECIALISED_FREIGHT', - 'The Courier Guy' => 'THECOURIERGUY' - ], + 'Courier IT' => 'ZA_COURIERIT', + 'Dawn Wing' => 'DAWN_WING', + 'DPE South Africa' => 'DPE_SOUTH_AFRC', + 'Internet Express' => 'INTEXPRESS', + 'MDS Collivery Pty (Ltd)' => 'COLLIVERY', + 'RAM courier' => 'RAM', + 'Skynet World Wide Express South Africa' => 'SKYNET_ZA', + 'South African Post Office' => 'SOUTH_AFRICAN_POST_OFFICE', + 'Specialised Freight' => 'ZA_SPECIALISED_FREIGHT', + 'The Courier Guy' => 'THECOURIERGUY' + ], 'ESP' => [ - 'AB Custom Group' => 'ABCUSTOM', - 'Ader couriers' => 'ADERONLINE', - 'ASIGNA courier' => 'ASIGNA', - 'ASM(GLS Spain)' => 'ESP_ASM', - 'CBL Logistica' => 'CBL_LOGISTICA', - 'Correos Express' => 'CORREOS_EXPRESS', - 'DHL parcel Spain(www.dhl.com)' => 'DHL_PARCEL_ES', - 'DHL Spain(www.dhl.com)' => 'DHL_ES', - 'ECOSCOOTING' => 'ECOSCOOTING', - 'Envialia' => 'ESP_ENVIALIA', - 'Envialia Reference' => 'ENVIALIA_REFERENCE', - 'Integra2' => 'INTEGRA2_FTP', - 'MRW courier' => 'MRW_FTP', - 'MRW spain' => 'ESP_MRW', - 'NACEX' => 'NACEX', - 'NACEX Spain' => 'ESP_NACEX', - 'Paack courier' => 'PAACK_WEBHOOK', - 'Packlink' => 'ESP_PACKLINK', - 'Redur Spain' => 'ESP_REDUR', - 'SEUR International' => 'PRT_INT_SEUR', - 'SEUR portugal' => 'PRT_SEUR', - 'Seur Spain' => 'SEUR_ES', - 'Spanish Seur API' => 'SEUR_SP_API', - 'Spring GDS' => 'SPRING_GDS', - 'SZENDEX' => 'SZENDEX', - 'THT Netherland' => 'TNT_NL', - 'TIPSA courier' => 'TIPSA', - 'TNT Express' => 'TNT', - 'TNT global' => 'GLOBAL_TNT', - 'tourline' => 'TOURLINE', - 'VAMOX' => 'VAMOX', - 'Viaxpress' => 'VIA_EXPRESS', - 'Zeleris' => 'ZELERIS' - ], + 'AB Custom Group' => 'ABCUSTOM', + 'Ader couriers' => 'ADERONLINE', + 'ASIGNA courier' => 'ASIGNA', + 'ASM(GLS Spain)' => 'ESP_ASM', + 'CBL Logistica' => 'CBL_LOGISTICA', + 'Correos Express' => 'CORREOS_EXPRESS', + 'DHL parcel Spain(www.dhl.com)' => 'DHL_PARCEL_ES', + 'DHL Spain(www.dhl.com)' => 'DHL_ES', + 'ECOSCOOTING' => 'ECOSCOOTING', + 'Envialia' => 'ESP_ENVIALIA', + 'Envialia Reference' => 'ENVIALIA_REFERENCE', + 'Integra2' => 'INTEGRA2_FTP', + 'MRW courier' => 'MRW_FTP', + 'MRW spain' => 'ESP_MRW', + 'NACEX' => 'NACEX', + 'NACEX Spain' => 'ESP_NACEX', + 'Paack courier' => 'PAACK_WEBHOOK', + 'Packlink' => 'ESP_PACKLINK', + 'Redur Spain' => 'ESP_REDUR', + 'SEUR International' => 'PRT_INT_SEUR', + 'SEUR portugal' => 'PRT_SEUR', + 'Seur Spain' => 'SEUR_ES', + 'Spanish Seur API' => 'SEUR_SP_API', + 'Spring GDS' => 'SPRING_GDS', + 'SZENDEX' => 'SZENDEX', + 'THT Netherland' => 'TNT_NL', + 'TIPSA courier' => 'TIPSA', + 'TNT Express' => 'TNT', + 'TNT global' => 'GLOBAL_TNT', + 'tourline' => 'TOURLINE', + 'VAMOX' => 'VAMOX', + 'Viaxpress' => 'VIA_EXPRESS', + 'Zeleris' => 'ZELERIS' + ], 'SWE' => [ - 'Airmee couriers' => 'AIRMEE_WEBHOOK', - 'Bring' => 'BRING', - 'DB Schenker (www.dbschenker.com)' => 'DBSCHENKER_SE', - 'DB Schenker Sweden' => 'DBSCHENKER_SV' - ], + 'Airmee couriers' => 'AIRMEE_WEBHOOK', + 'Bring' => 'BRING', + 'DB Schenker (www.dbschenker.com)' => 'DBSCHENKER_SE', + 'DB Schenker Sweden' => 'DBSCHENKER_SV' + ], 'CHE' => [ - 'Asendia HonKong' => 'ASENDIA_HK', - 'Planzer Group' => 'PLANZER', - 'Swiss Post FTP' => 'SWISS_POST_FTP', - 'ViaEurope' => 'VIAEUROPE' - ], + 'Asendia HonKong' => 'ASENDIA_HK', + 'Planzer Group' => 'PLANZER', + 'Swiss Post FTP' => 'SWISS_POST_FTP', + 'ViaEurope' => 'VIAEUROPE' + ], 'TWN' => [ - 'cnwangtong' => 'CNWANGTONG', - 'CTC Express' => 'CTC_EXPRESS', - 'Dimerco Express Group' => 'DIMERCO', - 'HCT LOGISTICS CO.LTD.' => 'HCT_LOGISTICS', - 'Kerry TJ Logistics' => 'KERRYTJ', - 'PRESIDENT TRANSNET CORP' => 'PRESIDENT_TRANS', + 'cnwangtong' => 'CNWANGTONG', + 'CTC Express' => 'CTC_EXPRESS', + 'Dimerco Express Group' => 'DIMERCO', + 'HCT LOGISTICS CO.LTD.' => 'HCT_LOGISTICS', + 'Kerry TJ Logistics' => 'KERRYTJ', + 'PRESIDENT TRANSNET CORP' => 'PRESIDENT_TRANS', 'Tai Wan Global Business' => 'GLOBAL_EXPRESS' - ], + ], 'THA' => [ - 'Alphafast (www.alphafast.com)' => 'ALPHAFAST', - 'CJ Korea Express' => 'CJ_KR', - 'Dynamic Logistics' => 'THA_DYNAMIC_LOGISTICS', - 'Fastrak Services' => 'FASTRK_SERV', - 'Flash Express' => 'FLASHEXPRESS', - 'Nim Express' => 'NIM_EXPRESS', - 'Ninja van Thai' => 'NINJAVAN_THAI', - 'Sendit' => 'SENDIT', - 'SKYBOX' => 'SKYBOX', + 'Alphafast (www.alphafast.com)' => 'ALPHAFAST', + 'CJ Korea Express' => 'CJ_KR', + 'Dynamic Logistics' => 'THA_DYNAMIC_LOGISTICS', + 'Fastrak Services' => 'FASTRK_SERV', + 'Flash Express' => 'FLASHEXPRESS', + 'Nim Express' => 'NIM_EXPRESS', + 'Ninja van Thai' => 'NINJAVAN_THAI', + 'Sendit' => 'SENDIT', + 'SKYBOX' => 'SKYBOX', 'Thailand Post (www.thailandpost.co.th)' => 'THA_THAILAND_POST' - ], + ], 'TUR' => [ - 'ASE KARGO' => 'ASE', - 'CDEK TR' => 'CDEK_TR', - 'PTS courier' => 'PTS', - 'PTT Post' => 'PTT_POST', - 'ShipEntegra' => 'SHIPENTEGRA', + 'ASE KARGO' => 'ASE', + 'CDEK TR' => 'CDEK_TR', + 'PTS courier' => 'PTS', + 'PTT Post' => 'PTT_POST', + 'ShipEntegra' => 'SHIPENTEGRA', 'Yurtici Kargo' => 'YURTICI_KARGO' - ], + ], 'UKR' => [ - 'Nova Poshta (International)' => 'NOVA_POSHTA_INT', - 'Nova Poshta (novaposhta.ua)' => 'NOVA_POSHTA', - 'UkrPoshta' => 'POSTA_UKR' - ], + 'Nova Poshta (International)' => 'NOVA_POSHTA_INT', + 'Nova Poshta (novaposhta.ua)' => 'NOVA_POSHTA', + 'UkrPoshta' => 'POSTA_UKR' + ], 'ARE' => [ - 'Beone Logistics' => 'IBEONE', - 'Mara Xpress' => 'MARA_XPRESS', - 'Mena 360 (Fetchr)' => 'FETCHR_WEBHOOK', - 'One click delivery services' => 'ONECLICK', - 'SKYNET UAE' => 'SKYNET_UAE' - ], + 'Beone Logistics' => 'IBEONE', + 'Mara Xpress' => 'MARA_XPRESS', + 'Mena 360 (Fetchr)' => 'FETCHR_WEBHOOK', + 'One click delivery services' => 'ONECLICK', + 'SKYNET UAE' => 'SKYNET_UAE' + ], 'GBR' => [ - 'Amazon Shipping' => 'AMAZON', - 'AO Logistics' => 'AO_COURIER', - 'APC overnight (apc-overnight.com)' => 'APC_OVERNIGHT', - 'APC Overnight Consignment' => 'APC_OVERNIGHT_CONNUM', - 'APG eCommerce Solutions' => 'APG', - 'ARK Logistics' => 'ARK_LOGISTICS', - 'Arrow XL' => 'GB_ARROW', - 'Asendia UK' => 'ASENDIA_UK', - 'B&H Worldwide' => 'BH_WORLDWIDE', - 'BirdSystem' => 'BIRDSYSTEM', - 'Bluecare Express Ltd' => 'BLUECARE', - 'CAE Delivers' => 'CAE_DELIVERS', - 'Caribou' => 'CARIBOU', - 'DAI Post' => 'DAIGLOBALTRACK', - 'Deltec Courier' => 'DELTEC_UK', - 'DHl (Reference number)' => 'DHL_REFR', - 'dhl UK' => 'DHL_UK', - 'Diamond Eurogistics Limited' => 'DIAMOND_EUROGISTICS', - 'Direct Parcels' => 'DIRECTPARCELS', - 'DMSMatrix' => 'DMS_MATRIX', - 'DPD Local' => 'DPD_LOCAL', - 'DPD Local reference' => 'DPD_LOCAL_REF', - 'DX (SFTP)' => 'DX_SFTP', - 'EU Fleet Solutions' => 'EU_FLEET_SOLUTIONS', - 'FedEx® UK' => 'FEDEX_UK', - 'Furdeco' => 'FURDECO', - 'GBA Services Ltd' => 'GBA', - 'GEM Worldwide' => 'GEMWORLDWIDE', - 'HermesWorld UK' => 'HERMES', - 'Home Delivery Solutions Ltd' => 'HOME_DELIVERY_SOLUTIONS', - 'Interparcel UK' => 'INTERPARCEL_UK', - 'MyHermes UK' => 'MYHERMES', - 'National Sameday' => 'NATIONAL_SAMEDAY', - 'Norsk Global' => 'GB_NORSK', - 'OCS WORLDWIDE' => 'OCS_WORLDWIDE', - 'Palletways' => 'PALLETWAYS', - 'Panther' => 'GB_PANTHER', - 'Panther Reference' => 'PANTHER_REFERENCE', - 'Parcel2Go' => 'PARCEL2GO', - 'Parcelink Logistics' => 'PARCELINKLOGISTICS', - 'Plus UK Logistics' => 'PLUS_LOG_UK', - 'RPD2man Deliveries' => 'RPD2MAN', - 'Skynet UK' => 'SKYNET_UK', - 'Swiship UK' => 'AMAZON_FBA_SWISHIP', - 'TDG – The Delivery Group' => 'THEDELIVERYGROUP', - 'The Pallet Network' => 'PALLET_NETWORK', - 'TNT UK Limited (www.tnt.com)' => 'TNT_UK', - 'TNT UK Reference' => 'TNT_UK_REFR', - 'Tuffnells Parcels Express' => 'GB_TUFFNELLS', - 'Tuffnells Parcels Express- Reference' => 'TUFFNELLS_REFERENCE', - 'UK mail (ukmail.com)' => 'UK_UK_MAIL', - 'Whistl' => 'WHISTL', - 'wnDirect' => 'WNDIRECT', - 'XDP Express' => 'UK_XDP', - 'XDP Express Reference' => 'XDP_UK_REFERENCE', - 'Xpert Delivery' => 'XPERT_DELIVERY', - 'Yodel (www.yodel.co.uk)' => 'UK_YODEL' - ], + 'Amazon Shipping' => 'AMAZON', + 'AO Logistics' => 'AO_COURIER', + 'APC overnight (apc-overnight.com)' => 'APC_OVERNIGHT', + 'APC Overnight Consignment' => 'APC_OVERNIGHT_CONNUM', + 'APG eCommerce Solutions' => 'APG', + 'ARK Logistics' => 'ARK_LOGISTICS', + 'Arrow XL' => 'GB_ARROW', + 'Asendia UK' => 'ASENDIA_UK', + 'B&H Worldwide' => 'BH_WORLDWIDE', + 'BirdSystem' => 'BIRDSYSTEM', + 'Bluecare Express Ltd' => 'BLUECARE', + 'CAE Delivers' => 'CAE_DELIVERS', + 'Caribou' => 'CARIBOU', + 'DAI Post' => 'DAIGLOBALTRACK', + 'Deltec Courier' => 'DELTEC_UK', + 'DHl (Reference number)' => 'DHL_REFR', + 'dhl UK' => 'DHL_UK', + 'Diamond Eurogistics Limited' => 'DIAMOND_EUROGISTICS', + 'Direct Parcels' => 'DIRECTPARCELS', + 'DMSMatrix' => 'DMS_MATRIX', + 'DPD Local' => 'DPD_LOCAL', + 'DPD Local reference' => 'DPD_LOCAL_REF', + 'DX (SFTP)' => 'DX_SFTP', + 'EU Fleet Solutions' => 'EU_FLEET_SOLUTIONS', + 'FedEx® UK' => 'FEDEX_UK', + 'Furdeco' => 'FURDECO', + 'GBA Services Ltd' => 'GBA', + 'GEM Worldwide' => 'GEMWORLDWIDE', + 'HermesWorld UK' => 'HERMES', + 'Home Delivery Solutions Ltd' => 'HOME_DELIVERY_SOLUTIONS', + 'Interparcel UK' => 'INTERPARCEL_UK', + 'MyHermes UK' => 'MYHERMES', + 'National Sameday' => 'NATIONAL_SAMEDAY', + 'Norsk Global' => 'GB_NORSK', + 'OCS WORLDWIDE' => 'OCS_WORLDWIDE', + 'Palletways' => 'PALLETWAYS', + 'Panther' => 'GB_PANTHER', + 'Panther Reference' => 'PANTHER_REFERENCE', + 'Parcel2Go' => 'PARCEL2GO', + 'Parcelink Logistics' => 'PARCELINKLOGISTICS', + 'Plus UK Logistics' => 'PLUS_LOG_UK', + 'RPD2man Deliveries' => 'RPD2MAN', + 'Skynet UK' => 'SKYNET_UK', + 'Swiship UK' => 'AMAZON_FBA_SWISHIP', + 'TDG – The Delivery Group' => 'THEDELIVERYGROUP', + 'The Pallet Network' => 'PALLET_NETWORK', + 'TNT UK Limited (www.tnt.com)' => 'TNT_UK', + 'TNT UK Reference' => 'TNT_UK_REFR', + 'Tuffnells Parcels Express' => 'GB_TUFFNELLS', + 'Tuffnells Parcels Express- Reference' => 'TUFFNELLS_REFERENCE', + 'UK mail (ukmail.com)' => 'UK_UK_MAIL', + 'Whistl' => 'WHISTL', + 'wnDirect' => 'WNDIRECT', + 'XDP Express' => 'UK_XDP', + 'XDP Express Reference' => 'XDP_UK_REFERENCE', + 'Xpert Delivery' => 'XPERT_DELIVERY', + 'Yodel (www.yodel.co.uk)' => 'UK_YODEL' + ], 'USA' => [ - 'A Duie Pyle' => 'ADUIEPYLE', - 'AAA Cooper' => 'AAA_COOPER', - 'ABF Freight' => 'GLOBAL_ABF', - 'Aeronet couriers' => 'AERONET', - 'Agility' => 'AGILITY', - 'Always Express' => 'ALWAYS_EXPRESS', - 'Amazon Shipping + Amazon MCF' => 'AMAZON_SHIP_MCF', - 'Amstan Logistics' => 'AMSTAN', - 'ANICAM BOX EXPRESS' => 'ANICAM_BOX', - 'APC postal logistics germany' => 'GB_APC', - 'Aprisa Express' => 'APRISAEXPRESS', - 'Aquiline' => 'AQUILINE', - 'Asendia USA' => 'ASENDIA_US', - 'Best Way Parcel' => 'BESTWAYPARCEL', - 'Bond courier' => 'BOND', - 'Champion Logistics' => 'CHAMPION_LOGISTICS', - 'Con-way Freight' => 'CON_WAY', - 'Dayton Freight' => 'DAYTON_FREIGHT', - 'Destiny Transportation' => 'DESTINY', - 'DHL Supply Chain APAC' => 'DHL_SUPPLY_CHAIN', - 'DoorDash' => 'DOORDASH_WEBHOOK', - 'Echo courier' => 'ECHO', - 'EP-Box courier' => 'EP_BOX', - 'ePost Global' => 'EPST_GLBL', - 'FDSEXPRESS' => 'FDSEXPRESS', - 'Fedex' => 'FEDEX', - 'FedEx Cross Border' => 'FEDEX_CROSSBORDER', - 'FedEx International MailService' => 'FEDEX_INTL_MLSERV', - 'FirstMile' => 'FIRSTMILE', - 'Freightquote by C.H. Robinson' => 'FREIGHTQUOTE', - 'Fulfilla' => 'FULFILLA', - 'Gio Express' => 'GIO_EXPRESS', - 'GlobalTranz' => 'GLOBALTRANZ', - 'GSI EXPRESS' => 'GSI_EXPRESS', - 'GSO(GLS-USA)' => 'GSO', - 'Hipshipper' => 'HIPSHIPPER', - 'i-parcel' => 'GLOBAL_IPARCEL', - 'Innovel courier' => 'DESCARTES', - 'LaserShip' => 'US_LASERSHIP', - 'Lone Star Overnight' => 'LONESTAR', - 'MailAmericas' => 'MAILAMERICAS', - 'Newegg Express' => 'NEWEGGEXPRESS', - 'Old Dominion Freight Line' => 'US_OLD_DOMINION', - 'OSM Worldwide' => 'OSM_WORLDWIDE', - 'PCF Final Mile' => 'PCFCORP', - 'Pilot Freight Services' => 'PILOT_FREIGHT', - 'Pitney Bowes' => 'PITNEY_BOWES', - 'PITT OHIO' => 'PITTOHIO', - 'Qwintry Logistics' => 'QWINTRY', - 'RL Carriers' => 'RL_US', - 'Saia LTL Freight' => 'SAIA_FREIGHT', - 'Shiptor' => 'SHIPTOR', - 'Sonic Transportation & Logistics' => 'SONICTL', - 'Southeastern Freight Lines' => 'SEFL', - 'Spee-Dee Delivery' => 'SPEEDEE', - 'Sutton Transport' => 'SUTTON', - 'Tazmanian Freight Systems' => 'TAZMANIAN_FREIGHT', - 'TForce Final Mile' => 'TFORCE_FINALMILE', - 'Transgroup courier' => 'LOGISTYX_TRANSGROUP', - 'TRUMPCARD LLC' => 'TRUMPCARD', - 'United States Postal Service' => 'USPS', - 'UPS Mail Innovations' => 'UPS_MAIL_INNOVATIONS', - 'USF Reddaway' => 'USF_REDDAWAY', - 'uShip courier' => 'USHIP', - 'West Bank Courier' => 'WESTBANK_COURIER', - 'Westgate Global' => 'WESTGATE_GL', - 'Wizmo' => 'WIZMO', - 'XPO logistics' => 'XPO_LOGISTICS', - 'Yakit courier' => 'YAKIT', - 'YRC courier' => 'US_YRC', - 'Zinc courier' => 'ZINC' - ], + 'A Duie Pyle' => 'ADUIEPYLE', + 'AAA Cooper' => 'AAA_COOPER', + 'ABF Freight' => 'GLOBAL_ABF', + 'Aeronet couriers' => 'AERONET', + 'Agility' => 'AGILITY', + 'Always Express' => 'ALWAYS_EXPRESS', + 'Amazon Shipping + Amazon MCF' => 'AMAZON_SHIP_MCF', + 'Amstan Logistics' => 'AMSTAN', + 'ANICAM BOX EXPRESS' => 'ANICAM_BOX', + 'APC postal logistics germany' => 'GB_APC', + 'Aprisa Express' => 'APRISAEXPRESS', + 'Aquiline' => 'AQUILINE', + 'Asendia USA' => 'ASENDIA_US', + 'Best Way Parcel' => 'BESTWAYPARCEL', + 'Bond courier' => 'BOND', + 'Champion Logistics' => 'CHAMPION_LOGISTICS', + 'Con-way Freight' => 'CON_WAY', + 'Dayton Freight' => 'DAYTON_FREIGHT', + 'Destiny Transportation' => 'DESTINY', + 'DHL Supply Chain APAC' => 'DHL_SUPPLY_CHAIN', + 'DoorDash' => 'DOORDASH_WEBHOOK', + 'Echo courier' => 'ECHO', + 'EP-Box courier' => 'EP_BOX', + 'ePost Global' => 'EPST_GLBL', + 'FDSEXPRESS' => 'FDSEXPRESS', + 'Fedex' => 'FEDEX', + 'FedEx Cross Border' => 'FEDEX_CROSSBORDER', + 'FedEx International MailService' => 'FEDEX_INTL_MLSERV', + 'FirstMile' => 'FIRSTMILE', + 'Freightquote by C.H. Robinson' => 'FREIGHTQUOTE', + 'Fulfilla' => 'FULFILLA', + 'Gio Express' => 'GIO_EXPRESS', + 'GlobalTranz' => 'GLOBALTRANZ', + 'GSI EXPRESS' => 'GSI_EXPRESS', + 'GSO(GLS-USA)' => 'GSO', + 'Hipshipper' => 'HIPSHIPPER', + 'i-parcel' => 'GLOBAL_IPARCEL', + 'Innovel courier' => 'DESCARTES', + 'LaserShip' => 'US_LASERSHIP', + 'Lone Star Overnight' => 'LONESTAR', + 'MailAmericas' => 'MAILAMERICAS', + 'Newegg Express' => 'NEWEGGEXPRESS', + 'Old Dominion Freight Line' => 'US_OLD_DOMINION', + 'OSM Worldwide' => 'OSM_WORLDWIDE', + 'PCF Final Mile' => 'PCFCORP', + 'Pilot Freight Services' => 'PILOT_FREIGHT', + 'Pitney Bowes' => 'PITNEY_BOWES', + 'PITT OHIO' => 'PITTOHIO', + 'Qwintry Logistics' => 'QWINTRY', + 'RL Carriers' => 'RL_US', + 'Saia LTL Freight' => 'SAIA_FREIGHT', + 'Shiptor' => 'SHIPTOR', + 'Sonic Transportation & Logistics' => 'SONICTL', + 'Southeastern Freight Lines' => 'SEFL', + 'Spee-Dee Delivery' => 'SPEEDEE', + 'Sutton Transport' => 'SUTTON', + 'Tazmanian Freight Systems' => 'TAZMANIAN_FREIGHT', + 'TForce Final Mile' => 'TFORCE_FINALMILE', + 'Transgroup courier' => 'LOGISTYX_TRANSGROUP', + 'TRUMPCARD LLC' => 'TRUMPCARD', + 'United States Postal Service' => 'USPS', + 'UPS Mail Innovations' => 'UPS_MAIL_INNOVATIONS', + 'USF Reddaway' => 'USF_REDDAWAY', + 'uShip courier' => 'USHIP', + 'West Bank Courier' => 'WESTBANK_COURIER', + 'Westgate Global' => 'WESTGATE_GL', + 'Wizmo' => 'WIZMO', + 'XPO logistics' => 'XPO_LOGISTICS', + 'Yakit courier' => 'YAKIT', + 'YRC courier' => 'US_YRC', + 'Zinc courier' => 'ZINC' + ], 'URY' => [ 'Correo Uruguayo' => 'CORREO_UY' - ], + ], 'VNM' => [ - 'J&T Express Vietnam' => 'JTEXPRESS_VN', - 'Kerry Express (Vietnam) Co Ltd' => 'KERRYTTC_VN', - 'Nhat Tin Logistics' => 'NTLOGISTICS_VN', - 'Vietnam Post' => 'VNM_VIETNAM_POST', - 'ViettelPost' => 'VNM_VIETTELPOST' + 'J&T Express Vietnam' => 'JTEXPRESS_VN', + 'Kerry Express (Vietnam) Co Ltd' => 'KERRYTTC_VN', + 'Nhat Tin Logistics' => 'NTLOGISTICS_VN', + 'Vietnam Post' => 'VNM_VIETNAM_POST', + 'ViettelPost' => 'VNM_VIETTELPOST' ] -]; +] +?> \ No newline at end of file diff --git a/upload/system/library/paypal/paypal.php b/upload/system/library/paypal/paypal.php index 3c959a49..e588840c 100644 --- a/upload/system/library/paypal/paypal.php +++ b/upload/system/library/paypal/paypal.php @@ -1,182 +1,182 @@ 'https://api.sandbox.paypal.com', + private $server = array( + 'sandbox' => '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 = []; - private $last_response = []; - + private $errors = array(); + private $last_response = array(); + //IN: paypal info public function __construct($paypal_info) { if (!empty($paypal_info['partner_id'])) { $this->partner_id = $paypal_info['partner_id']; } - + if (!empty($paypal_info['client_id'])) { $this->client_id = $paypal_info['client_id']; } - + if (!empty($paypal_info['secret'])) { $this->secret = $paypal_info['secret']; } - + if (!empty($paypal_info['environment']) && (($paypal_info['environment'] == 'production') || ($paypal_info['environment'] == 'sandbox'))) { $this->environment = $paypal_info['environment']; } - + if (!empty($paypal_info['partner_attribution_id'])) { $this->partner_attribution_id = $paypal_info['partner_attribution_id']; } } - + //IN: token info //OUT: access token, if no return - check errors public function setAccessToken($token_info) { $command = '/v1/oauth2/token'; - + $params = $token_info; - + $result = $this->execute('POST', $command, $params); - + if (!empty($result['access_token'])) { $this->access_token = $result['access_token']; - + return $result; } else { return false; } } - + //OUT: access token public function getAccessToken() { return $this->access_token; } - + //OUT: access token, if no return - check errors public function getClientToken() { $command = '/v1/identity/generate-token'; - + $result = $this->execute('POST', $command); - + if (!empty($result['client_token'])) { return $result['client_token']; } else { return false; } } - + //OUT: merchant info, if no return - check errors public function getUserInfo() { $command = '/v1/identity/oauth2/userinfo'; - - $params = [ + + $params = array( 'schema' => 'paypalv1.1' - ]; - + ); + $result = $this->execute('GET', $command, $params); - + if (!empty($result['user_id'])) { return $result; } else { return false; } } - + //IN: partner id //OUT: merchant info, if no return - check errors public function getSellerCredentials($partner_id) { $command = '/v1/customer/partners/' . $partner_id . '/merchant-integrations/credentials'; - + $result = $this->execute('GET', $command); - + if (!empty($result['client_id'])) { return $result; } else { return false; } } - + //IN: partner id, merchant id //OUT: merchant info, if no return - check errors public function getSellerStatus($partner_id, $merchant_id) { $command = '/v1/customer/partners/' . $partner_id . '/merchant-integrations/' . $merchant_id; - + $result = $this->execute('GET', $command); - + if (!empty($result['merchant_id'])) { return $result; } else { return false; } } - + //IN: webhook info public function createWebhook($webhook_info) { $command = '/v1/notifications/webhooks'; - + $params = $webhook_info; - + $result = $this->execute('POST', $command, $params, true); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: webhook id //OUT: webhook info, if no return - check errors public function updateWebhook($webhook_id, $webhook_info) { $command = '/v1/notifications/webhooks/' . $webhook_id; - + $params = $webhook_info; - + $result = $this->execute('PATCH', $command, $params, true); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: webhook id public function deleteWebhook($webhook_id) { $command = '/v1/notifications/webhooks/' . $webhook_id; - + $result = $this->execute('DELETE', $command); - + return true; } - + //IN: webhook id //OUT: webhook info, if no return - check errors public function getWebhook($webhook_id) { $command = '/v1/notifications/webhooks/' . $webhook_id; - + $result = $this->execute('GET', $command); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //OUT: webhooks info, if no return - check errors public function getWebhooks() { $command = '/v1/notifications/webhooks'; - + $result = $this->execute('GET', $command); - + if (!empty($result['webhooks'])) { return $result['webhooks']; } else { @@ -188,343 +188,343 @@ public function getWebhooks() { //OUT: webhook event info, if no return - check errors public function getWebhookEvent($webhook_event_id) { $command = '/v1/notifications/webhooks-events/' . $webhook_event_id; - + $result = $this->execute('GET', $command); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //OUT: webhook events info, if no return - check errors public function getWebhookEvents() { $command = '/v1/notifications/webhooks-events'; - + $result = $this->execute('GET', $command); - + if (!empty($result['events'])) { return $result['events']; } else { return false; } } - + //IN: payment token info public function createPaymentToken($payment_token_info) { $command = '/v3/vault/payment-tokens'; - + $params = $payment_token_info; - + $result = $this->execute('POST', $command, $params, true); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: payment token id public function deletePaymentToken($payment_token_id) { $command = '/v3/vault/payment-tokens/' . $payment_token_id; - + $result = $this->execute('DELETE', $command); - + return true; } - + //IN: payment token id //OUT: payment token info, if no return - check errors public function getPaymentToken($payment_token_id) { $command = '/v3/vault/payment-tokens/' . $payment_token_id; - + $result = $this->execute('GET', $command); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: customer id //OUT: payment tokens info, if no return - check errors public function getPaymentTokens($customer_id) { $command = '/v3/vault/payment-tokens'; - - $params = ['customer_id' => $customer_id]; - + + $params = array('customer_id' => $customer_id); + $result = $this->execute('GET', $command, $params); - + if (!empty($result['payment_tokens'])) { return $result['payment_tokens']; } else { return false; } } - + //IN: setup token info public function createSetupToken($setup_token_info) { $command = '/v3/vault/setup-tokens'; - + $params = $setup_token_info; - + $result = $this->execute('POST', $command, $params, true); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: setup token id //OUT: setup token info, if no return - check errors public function getSetupToken($setup_token_id) { $command = '/v3/vault/setup-tokens/' . $setup_token_id; - + $result = $this->execute('GET', $command); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: order info public function createOrder($order_info) { $command = '/v2/checkout/orders'; - + $params = $order_info; - + $result = $this->execute('POST', $command, $params, true); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: order id, order info public function updateOrder($order_id, $order_info) { $command = '/v2/checkout/orders/' . $order_id; - + $params = $order_info; - + $result = $this->execute('PATCH', $command, $params, true); - + return true; } - + //IN: order id //OUT: order info, if no return - check errors public function getOrder($order_id) { $command = '/v2/checkout/orders/' . $order_id; - + $result = $this->execute('GET', $command); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: order id public function setOrderAuthorize($order_id) { $command = '/v2/checkout/orders/' . $order_id . '/authorize'; - + $result = $this->execute('POST', $command); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: order id public function setOrderCapture($order_id) { $command = '/v2/checkout/orders/' . $order_id . '/capture'; - + $result = $this->execute('POST', $command); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: transaction id public function setPaymentCapture($transaction_id, $transaction_info) { $command = '/v2/payments/authorizations/' . $transaction_id . '/capture'; - + $params = $transaction_info; - + $result = $this->execute('POST', $command, $params, true); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: transaction id public function setPaymentReauthorize($transaction_id, $transaction_info) { $command = '/v2/payments/authorizations/' . $transaction_id . '/reauthorize'; - + $params = $transaction_info; - + $result = $this->execute('POST', $command, $params, true); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: transaction id public function setPaymentVoid($transaction_id) { $command = '/v2/payments/authorizations/' . $transaction_id . '/void'; - + $result = $this->execute('POST', $command); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: transaction id public function setPaymentRefund($transaction_id, $transaction_info) { $command = '/v2/payments/captures/' . $transaction_id . '/refund'; - + $params = $transaction_info; - + $result = $this->execute('POST', $command, $params, true); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: transaction id //OUT: transaction info, if no return - check errors public function getPaymentAuthorize($transaction_id) { $command = '/v2/payments/authorizations/' . $transaction_id; - + $result = $this->execute('GET', $command); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: transaction id //OUT: transaction info, if no return - check errors public function getPaymentCapture($transaction_id) { $command = '/v2/payments/captures/' . $transaction_id; - + $result = $this->execute('GET', $command); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: transaction id //OUT: transaction info, if no return - check errors public function getPaymentRefund($transaction_id) { $command = '/v2/payments/refunds/' . $transaction_id; - + $result = $this->execute('GET', $command); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: order id, tracker info public function createOrderTracker($order_id, $tracker_info) { $command = '/v2/checkout/orders/' . $order_id . '/track'; - + $params = $tracker_info; - + $result = $this->execute('POST', $command, $params, true); - + if (!empty($result['id'])) { return $result; } else { return false; } } - + //IN: order id, tracker id //OUT: tracker info, if no return - check errors public function updateOrderTracker($order_id, $tracker_id, $tracker_info) { $command = '/v2/checkout/orders/' . $order_id . '/trackers/' . $tracker_id; - + $params = $tracker_info; - + $result = $this->execute('PATCH', $command, $params, true); - + return true; } - + //OUT: number of errors - public function hasErrors() { + public function hasErrors() { return count($this->errors); } - + //OUT: array of errors - public function getErrors() { + public function getErrors() { return $this->errors; } - + //OUT: last response public function getResponse() { return $this->last_response; } - - private function execute($method, $command, $params = [], $json = false) { - $this->errors = []; + + private function execute($method, $command, $params = array(), $json = false) { + $this->errors = array(); if ($method && $command) { - $curl_options = [ - CURLOPT_URL => $this->server[$this->environment] . $command, - CURLOPT_HEADER => true, + $curl_options = array( + CURLOPT_URL => $this->server[$this->environment] . $command, + CURLOPT_HEADER => true, CURLOPT_RETURNTRANSFER => true, - CURLOPT_INFILESIZE => null, - CURLOPT_HTTPHEADER => [], + CURLOPT_INFILESIZE => Null, + CURLOPT_HTTPHEADER => array(), CURLOPT_CONNECTTIMEOUT => 10, - CURLOPT_TIMEOUT => 10, + 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'; $curl_options[CURLOPT_HTTPHEADER][] = 'Accept-Language: en_US'; $curl_options[CURLOPT_HTTPHEADER][] = 'Content-Type: application/json'; $curl_options[CURLOPT_HTTPHEADER][] = 'PayPal-Request-Id: ' . $this->token(50); $curl_options[CURLOPT_HTTPHEADER][] = 'PayPal-Partner-Attribution-Id: ' . $this->partner_attribution_id; - + if ($this->access_token) { $curl_options[CURLOPT_HTTPHEADER][] = 'Authorization: Bearer ' . $this->access_token; } elseif ($this->client_id && $this->secret) { @@ -537,28 +537,28 @@ private function execute($method, $command, $params = [], $json = false) { case 'get': $curl_options[CURLOPT_HTTPGET] = true; $curl_options[CURLOPT_URL] .= '?' . $this->buildQuery($params, $json); - + break; case 'post': $curl_options[CURLOPT_POST] = true; $curl_options[CURLOPT_POSTFIELDS] = $this->buildQuery($params, $json); - + break; case 'patch': $curl_options[CURLOPT_POST] = true; $curl_options[CURLOPT_POSTFIELDS] = $this->buildQuery($params, $json); $curl_options[CURLOPT_CUSTOMREQUEST] = strtoupper($method); - + break; case 'delete': $curl_options[CURLOPT_POST] = true; $curl_options[CURLOPT_POSTFIELDS] = $this->buildQuery($params, $json); $curl_options[CURLOPT_CUSTOMREQUEST] = strtoupper($method); - + break; case 'put': $curl_options[CURLOPT_PUT] = true; - + if ($params) { if ($buffer = fopen('php://memory', 'w+')) { $params_string = $this->buildQuery($params, $json); @@ -567,94 +567,94 @@ private function execute($method, $command, $params = [], $json = false) { $curl_options[CURLOPT_INFILE] = $buffer; $curl_options[CURLOPT_INFILESIZE] = strlen($params_string); } else { - $this->errors[] = ['name' => 'FAILED_OPEN_TEMP_FILE', 'message' => 'Unable to open a temporary file']; + $this->errors[] = array('name' => 'FAILED_OPEN_TEMP_FILE', 'message' => 'Unable to open a temporary file'); } } - + break; case 'head': $curl_options[CURLOPT_NOBODY] = true; - + break; default: $curl_options[CURLOPT_CUSTOMREQUEST] = strtoupper($method); } - + $ch = curl_init(); curl_setopt_array($ch, $curl_options); $response = curl_exec($ch); - + if (curl_errno($ch)) { $curl_code = curl_errno($ch); - + $constant = get_defined_constants(true); $curl_constant = preg_grep('/^CURLE_/', array_flip($constant['curl'])); - - $this->errors[] = ['name' => $curl_constant[$curl_code], 'message' => curl_strerror($curl_code)]; + + $this->errors[] = array('name' => $curl_constant[$curl_code], 'message' => curl_strerror($curl_code)); } - + $head = ''; $body = ''; - + $parts = explode("\r\n\r\n", $response, 3); - + if (isset($parts[0]) && isset($parts[1])) { if (($parts[0] == 'HTTP/1.1 100 Continue') && isset($parts[2])) { - [$head, $body] = [$parts[1], $parts[2]]; + list($head, $body) = array($parts[1], $parts[2]); } else { - [$head, $body] = [$parts[0], $parts[1]]; + list($head, $body) = array($parts[0], $parts[1]); } - } - - $response_headers = []; - $header_lines = explode("\r\n", $head); - array_shift($header_lines); - - foreach ($header_lines as $line) { - [$key, $value] = explode(':', $line, 2); - $response_headers[$key] = $value; - } - + } + + $response_headers = array(); + $header_lines = explode("\r\n", $head); + array_shift($header_lines); + + foreach ($header_lines as $line) { + list($key, $value) = explode(':', $line, 2); + $response_headers[$key] = $value; + } + curl_close($ch); - + if (isset($buffer) && is_resource($buffer)) { - fclose($buffer); - } + fclose($buffer); + } $this->last_response = json_decode($body, true); - + if (!empty($this->last_response['message'])) { $this->errors[] = (array)$this->last_response; } - - return (array)$this->last_response; + + return (array)$this->last_response; } } - + private function buildQuery($params, $json) { if (is_string($params)) { - return $params; - } - + return $params; + } + if ($json) { return json_encode($params); } else { return http_build_query($params); } - } - + } + private function token($length = 32) { // Create random token $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - + $max = strlen($string) - 1; - + $token = ''; - + for ($i = 0; $i < $length; $i++) { $token .= $string[mt_rand(0, $max)]; - } - + } + return $token; } -} +} \ No newline at end of file