✏️ 正在编辑: axepta.php
路径:
/home/bpioifn/www/pigmentse/modules/axepta/axepta.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php /** * 2007-2019 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2019 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ require_once(_PS_CONFIG_DIR_ . '/config.inc.php'); if (!defined('_PS_VERSION_')) { exit; } require_once _PS_MODULE_DIR_ . 'axepta/classes/AxeptaBlowfish.php'; require_once _PS_MODULE_DIR_ . 'axepta/classes/AxeptaXml.php'; require_once _PS_MODULE_DIR_ . 'axepta/classes/AxeptaApi.php'; require_once _PS_MODULE_DIR_ . 'axepta/classes/AxeptaConfigurationAccount.php'; require_once _PS_MODULE_DIR_ . 'axepta/classes/AxeptaConfigurationAccountPaygate.php'; require_once _PS_MODULE_DIR_ . 'axepta/classes/AxeptaTransaction.php'; require_once _PS_MODULE_DIR_ . 'axepta/classes/AxeptaPaymentRecurring.php'; require_once _PS_MODULE_DIR_ . 'axepta/classes/AxeptaCustomerPaymentRecurring.php'; require_once _PS_MODULE_DIR_ . 'axepta/classes/AxeptaOrderReference.php'; require_once _PS_MODULE_DIR_ . 'axepta/classes/AxeptaConfigurationAccount.php'; require_once _PS_MODULE_DIR_ . 'axepta/classes/AxeptaCustomerOneClickPaymentCard.php'; require_once _PS_MODULE_DIR_ . 'axepta/classes/AxeptaLogger.php'; require_once _PS_MODULE_DIR_ . 'axepta/classes/AxeptaXmlPaygatePosition.php'; use PrestaShop\PrestaShop\Core\Payment\PaymentOption; class Axepta extends PaymentModule { protected $config_form = false; public function __construct() { $this->name = 'axepta'; $this->tab = 'payments_gateways'; $this->version = '1.2.1'; $this->author = 'Quadra Informatique'; $this->module_key = '919f11438b9153e472acdbcd4d8fdfd1'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('BNP Paribas - Axepta'); $this->description = $this->l('Accept online and mobile payments on a secure page with BNP Paribas Axepta official module'); $this->confirmUninstall = $this->l('Are you sure you want to unistall this module ?'); $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); } public function install() { include(dirname(__FILE__) . '/sql/install.php'); if (!$this->installBackOffice()) { return false; } $this->registerOrderStatus(); // Defaults values Configuration::updateGlobalValue('AXEPTA_MSG_VER', '2.0'); if (!parent::install()) { return false; } // Trick Installation Process to launch update files in /upgrade Directories $module = Module::getInstanceByName('axepta'); $module->database_version = '1.0.0'; $module->installed = true; if (self::initUpgradeModule($module)) { $this->runUpgradeModule(); } if (!AxeptaXml::insertXmlToDb()){ return false; } return $this->registerHook('displayHeader') && $this->registerHook('backOfficeHeader') && $this->registerHook('paymentReturn') && $this->registerHook('displayAdminProductsExtra') && $this->registerHook('actionProductUpdate') && $this->registerHook('displayAdminOrder') && $this->registerHook('displayBackOfficeHeader') && $this->registerHook('displayCustomerAccount') && $this->registerHook('actionAdminControllerSetMedia') && $this->registerHook('paymentOptions'); } public function uninstall() { return parent::uninstall(); } private function postProcess() { // Used for not validate form by changing shop if (count($_POST) <= 1) { return false; } } public function getContent() { $output = null; if (Tools::isSubmit('submit' . $this->name)) { $this->postProcess(); if (count($this->_errors) > 0) { $output .= $this->displayError(implode('<br />', $this->_errors)); } else { $output .= $this->displayConfirmation($this->l('Server settings updated')); } } $link = new Link(); $ajax_url = $link->getAdminLink('AdminManageAxeptaConf'); $update_url = $link->getAdminLink('AdminManageAxeptaConf'); // same as ajax_url => set in back.js // Display Advices $this->context->smarty->assign(array( 'ajax_url' => $ajax_url, 'update_url' => $update_url, 'content_dir' => Tools::getHttpHost(true) . str_replace( _PS_ROOT_DIR_ . '/', __PS_BASE_URI__, $this->_path ) . 'views/img/', 'errors' => $this->context->cookie->__get('debugFileError') )); $this->context->cookie->__unset('debugFileError'); return $output . $this->displayForm(); } public function displayForm() { // Get default Language $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); // for ajax translate $this->l('Reset complete'); $this->l('Udpate not needed, tables already up to date'); $this->l('Update complete'); $this->l('Total number of items : '); // Init Fields form array $fields_form = array(); $link = new Link(); $fields_form[1]['form'] = array( 'legend' => array( 'title' => $this->l('Go to payment configurations page'), 'icon' => 'icon-cogs', ), 'input' => array( array( 'tab' => 'go_to_config_button', 'type' => 'html', 'name' => 'go_to_config_button', 'html_content' => $this->context->smarty->fetch($this->local_path . 'views/templates/admin/go_to_configuration.tpl'), ) ), ); $fields_form[2]['form'] = array( 'legend' => array( 'title' => $this->l('Settings XML'), 'icon' => 'icon-cogs', ), 'input' => array( array( 'type' => 'textbutton', 'label' => $this->l('Current XML URL'), 'name' => 'AXEPTA_XML_VERSION', 'required' => false, 'size' => 50, 'button' => array( 'label' => $this->l('Update your account list'), 'attributes' => array( 'onclick' => 'updateXML(this);' ) ) ), ), ); $fields_form[3]['form'] = array( 'legend' => array( 'title' => $this->l('Debug'), 'icon' => 'icon-cogs', ), 'input' => array( array( 'type' => 'textbutton', 'label' => $this->l('Download Debug file'), 'required' => false, 'name' => 'debug_file_key', 'size' => 50, 'placeholder' => 'File KEY', 'button' => array( 'label' => $this->l('Download'), 'attributes' => array( 'data-url' => $link->getAdminLink('AdminManageAxeptaConf', true), 'data-action' => 'download', 'id' => 'downloadDebugFile' ) ) ), ), ); $helper = new HelperForm(); // Module, token and currentIndex $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name; // Language $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; $helper->base_tpl = 'form.tpl'; // Title and toolbar $helper->title = $this->displayName; $helper->show_toolbar = true; $helper->toolbar_scroll = true; //$helper->submit_action = 'submit' . $this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => $helper->currentIndex . '&save' . $this->name . '&token=' . $helper->token, ), 'back' => array( 'href' => AdminController::$currentIndex . '&token=' . $helper->token, 'desc' => $this->l('Back to list') ) ); // Load current value $helper->fields_value['AXEPTA_XML_VERSION'] = Configuration::getGlobalValue('AXEPTA_XML_VERSION'); $helper->fields_value['debug_file_key'] = null; return $helper->generateForm($fields_form); } /** * Add the CSS & JavaScript files you want to be loaded in the BO. */ public function hookBackOfficeHeader() { if (Tools::getValue('module_name') == $this->name) { $this->context->controller->addCSS($this->_path . 'views/css/back.css'); } } public function installBackOffice() { $this->l('Your reccuring payment has been stopped'); try { $id_lang_en = LanguageCore::getIdByIso('en'); $id_lang_fr = LanguageCore::getIdByIso('fr'); $id_root_tab = Tab::getIdFromClassName('axepta'); if (!$id_root_tab) { $this->installModuleTab( 'axepta', array( $id_lang_fr => 'Axepta BNP Paribas', $id_lang_en => 'Axepta BNP Paribas' ), Tab::getIdFromClassName('IMPROVE') ); $id_root_tab = Tab::getIdFromClassName('axepta'); } $id_tab = Tab::getIdFromClassName('AdminManageAxeptaConf'); if(!$id_tab) { $this->installModuleTab( 'AdminManageAxeptaConf', array( $id_lang_fr => 'Configuration paiements Axepta BNP Paribas', $id_lang_en => 'Axepta Payments configuration BNP Paribas' ), $id_root_tab ); } $id_tab = Tab::getIdFromClassName('AdminAxeptatransaction'); if(!$id_tab) { $this->installModuleTab( 'AdminAxeptatransaction', array( $id_lang_fr => 'Axepta liste des transactions', $id_lang_en => 'Axepta transaction list' ), $id_root_tab ); } $id_tab = Tab::getIdFromClassName('AdminAxeptaRecurring'); if(!$id_tab) { $this->installModuleTab( 'AdminAxeptaRecurring', array( $id_lang_fr => 'Axepta liste des abonnements', $id_lang_en => 'Axepta recurring list' ), $id_root_tab ); } } catch (Exception $e) { AxeptaLogger::log('Installation Exception : ' . $e->getMessage()); return false; } return true; } /** * Create Axepta order status pending * @return boolean */ public function registerOrderStatus() { if (!(int)Configuration::getGlobalValue('AXEPTA_PENDING_OS_PAYMENT')) { $order_state = new OrderState(); $order_state->unremovable = true; $order_state->name = array(); foreach (Language::getLanguages() as $language) { if (Tools::strtolower($language['iso_code']) == 'fr') { $order_state->name[$language['id_lang']] = 'Axepta - En attente de validation Cetelem Presto'; } else { $order_state->name[$language['id_lang']] = 'Axepta - Pending validation Cetelem Presto'; } } $order_state->module_name = $this->name; $order_state->color = '#4169E1'; $order_state->hidden = false; $order_state->delivery = false; $order_state->logable = false; $order_state->invoice = false; $order_state->send_email = false; $order_state->template = ''; if ($order_state->save()) { copy(_PS_MODULE_DIR_.$this->name.'/logo.gif', _PS_IMG_DIR_.'os/'.(int)$order_state->id.'.gif'); Configuration::updateGlobalValue('AXEPTA_PENDING_OS_PAYMENT', (int)$order_state->id); } } if (!(int)Configuration::getGlobalValue('AXEPTA_INCOMPLETE_OS_PAYMENT')) { $order_state = new OrderState(); $order_state->unremovable = true; $order_state->name = array(); foreach (Language::getLanguages() as $language) { if (Tools::strtolower($language['iso_code']) == 'fr') { $order_state->name[$language['id_lang']] = 'Axepta - Paiement incomplet'; } else { $order_state->name[$language['id_lang']] = 'Axepta - Incomplete payment'; } } $order_state->module_name = $this->name; $order_state->color = '#4169E1'; $order_state->hidden = false; $order_state->delivery = false; $order_state->logable = false; $order_state->invoice = false; $order_state->send_email = false; $order_state->template = ''; if ($order_state->save()) { copy(_PS_MODULE_DIR_.$this->name.'/logo.gif', _PS_IMG_DIR_.'os/'.(int)$order_state->id.'.gif'); Configuration::updateGlobalValue('AXEPTA_INCOMPLETE_OS_PAYMENT', (int)$order_state->id); } } } public function uninstallModuleTab($tabClass) { $idTab = Tab::getIdFromClassName($tabClass); if ($idTab != 0) { $tab = new Tab($idTab); $tab->delete(); return true; } return false; } public function installModuleTab($tabClass, $tabName, $idTabParent) { $tab = new Tab(); $tab->name = $tabName; $tab->class_name = $tabClass; $tab->module = $this->name; $tab->id_parent = (int) ($idTabParent); $tab->icon = 'icon-' . $tabClass; return (bool) $tab->save(); } public function hookDisplayAdminProductsExtra($params) { $product = new Product((int) $params['id_product']); if (Validate::isLoadedObject($product)) { $axepta_payment_recurring = AxeptaPaymentRecurring::getPaymentRecurringByProductId((int) $product->id); $this->context->smarty->assign( array( 'axepta_payment_recurring' => $axepta_payment_recurring, 'axepta_types' => AxeptaPaymentRecurring::getTypes(), 'axepta_periodicities' => AxeptaPaymentRecurring::getPeriodicities() ) ); } return $this->display(__FILE__, 'admin-product-extra.tpl'); } /** * Add the CSS & JavaScript files you want to be added on the FO. */ public function hookDisplayHeader($params) { $this->context->controller->addCSS($this->_path . '/views/css/front.css'); $context = Context::getContext(); if (($context->controller->php_self == 'order') || ($context->controller->php_self == 'order-opc')) { $this->context->controller->addJs(($this->_path) . 'views/js/front.js', 'all'); } if ($context->controller->php_self == 'order-confirmation') { $this->context->controller->addJs(($this->_path) . 'views/js/order-conf.js', 'all'); } } /** * This hook is used to display the order confirmation page. */ public function hookPaymentReturn($params) { if ($this->active == false) { return; } $order = $params['order']; if (!in_array($order->getCurrentOrderState()->id , [ Configuration::get('PS_OS_ERROR'), Configuration::get('PS_OS_OUTOFSTOCK_UNPAID') ])) { $this->smarty->assign('status', 'ok'); $transaction = AxeptaTransaction::getTransactionByOrderId((int) $order->id); } $this->smarty->assign(array( 'id_order' => $order->id, 'reference' => $order->reference, 'shop_name' => $this->context->shop->name, 'transaction' => (empty($transaction)) ? null : $transaction, 'pay_id' => (empty($transaction['pay_id'])) ? null : $transaction['pay_id'], 'params' => $params, 'total' => Tools::displayPrice($order->getOrdersTotalPaid(), new Currency($order->id_currency), false), )); return $this->display(__FILE__, 'views/templates/hook/confirmation.tpl'); } public function hookActionProductUpdate($params) { $product = new Product((int) Tools::getValue('id_product')); if (Validate::isLoadedObject($product) && $this->active) { if (empty(\Tools::getValue('axepta_type')) && empty(\Tools::getValue('axepta_periodicity')) && empty(\Tools::getValue('axepta_number_occurrences'))) { return true; } $error = false; // Type if (empty(Tools::getValue('axepta_type'))) { $error = true; } // Periodicity if (empty(Tools::getValue('axepta_periodicity'))) { $error = true; } // Occurrences if (empty(Tools::getValue('axepta_number_occurrences')) && (int) Tools::getValue('axepta_type') != 1) { $error = true; } if (!$error) { $id_payment_recurring = AxeptaPaymentRecurring::getIdPaymentRecurringByProductId((int) $product->id); // Add || Save $payment_recurring = new AxeptaPaymentRecurring((int) $id_payment_recurring); $payment_recurring->id_product = (int) $product->id; $payment_recurring->type = (int) Tools::getValue('axepta_type'); $payment_recurring->periodicity = (int) Tools::getValue('axepta_periodicity'); $payment_recurring->number_occurences = (int) Tools::getValue('axepta_number_occurrences'); $payment_recurring->recurring_amount = (float) Tools::getValue('axepta_recurring_amount'); $payment_recurring->save(); } } } public function hookDisplayAdminOrder($params) { $errors = array(); // Refund Submit if (Tools::isSubmit('submitAxeptaRefund')) { if (!Tools::getValue('axepta_refund_transaction')) { $errors[] = $this->l('Select a transaction to refund.'); } if (!Tools::getValue('axepta_refund_slip')) { $errors[] = $this->l('Select a slip to refund.'); } if (!count($errors)) { $pay_id = Tools::getValue('axepta_refund_transaction'); $transaction = AxeptaTransaction::getTransactionByPayId($pay_id); if (Validate::isLoadedObject($transaction)) { // Get slip $slip_id = Tools::getValue('axepta_refund_slip'); $slip = new OrderSlip($slip_id); if ($slip->id) { // Refund $amount = ($slip->total_shipping_tax_incl + $slip->total_products_tax_incl) * 100; $result = AxeptaApi::processRefund($slip->id_order, (int)$amount, $slip->id); if (!$result) { $errors[] = $this->l('Erreur sur remboursement :').' '.$pay_id; } } else { $errors[] = $this->l('Unknown slip ID:').' '.$slip_id; } } else { $errors[] = $this->l('Unknown transaction ID:').' '.$pay_id; } } } $order = new Order((int) $params['id_order']); $transactions = AxeptaTransaction::getTransactionByOrderId((int) $order->id); $infos = AxeptaTransaction::getTransactionByReferenceAndType($order->reference); $slips = AxeptaTransaction::getRefundableSlips($order->id); if ($order->module == $this->name) { $this->smarty->assign( array( 'transaction_id' => $infos['id_axepta_transaction'], 'pay_id' => $infos['pay_id'], 'transactions' => (!empty($transactions)) ? $transactions : null, 'module_name' => $this->displayName, 'order' => $order, 'slips' => $slips, 'refund_label' => $this->l('Refund'), 'errors' => $errors ) ); return $this->display(__FILE__, 'admin-orders.tpl'); } } public function hookDisplayCustomerAccount($params) { $id_account = AxeptaApi::getIdAccountAndIdCurrency($this->context->country->id, $this->context->currency->id); if (!$id_account) { $id_account = AxeptaApi::getIdAccountByIdCountryAndIdCurrencyVerifyAllExist($this->context->country->id, $this->context->currency->id); } $account = new AxeptaConfigurationAccount($id_account); $has_one_click = false; if ($account->oneclick) { $has_one_click = true; } $has_recurring = false; if ($account->recurring) { $has_recurring = true; } $this->context->smarty->assign('has_recurring', $has_recurring); $this->context->smarty->assign('has_one_click', $has_one_click); $this->context->smarty->assign('module_dir', $this->_path); return $this->display(__FILE__, 'my-account.tpl'); } public function hookPaymentOptions($params) { $operation = 'payment'; $available_payments = $this->getAvailablePayments($params, $operation); if (!$available_payments) { return false; } if (!$this->canDisplayPayment($params)) { return false; } $payments = array(); $payment_recurring = false; $id_account = AxeptaApi::getIdAccountAndIdCurrency($this->context->country->id, $this->context->currency->id); if (!$id_account) { $id_account = AxeptaApi::getIdAccountByIdCountryAndIdCurrencyVerifyAllExist($this->context->country->id, $this->context->currency->id); } $merchant = new AxeptaConfigurationAccount($id_account); $this->context->smarty->assign('oneclick_ok', $merchant->oneclick); $use_iframe = false; $is_logged = false; if ($merchant->mode_view == 2) { $use_iframe = true; } if ($this->context->customer->isLogged()) { $is_logged = true; } if ($this->canDisplayPaymentRecurring() && $merchant->recurring) { $operation = 'recurring'; $payment_recurring = true; $available_payments_reccuring = $this->getAvailablePayments($params, $operation); } $axepta_api = new AxeptaCustomerOneClickPaymentCard(); $this->context->smarty->assign('axepta_api', $axepta_api); $this->context->smarty->assign('use_iframe', $use_iframe); $this->context->smarty->assign('is_logged', $is_logged); $link = new Link(); $this->context->smarty->assign('axeptaLink', $link); if (!$payment_recurring) { $this->context->smarty->assign('payment_recurring', false); $register_cards = AxeptaCustomerOneClickPaymentCard::getRegistersCard($this->context->customer->id); $this->context->smarty->assign('id_account', $id_account); foreach ($register_cards as $index => $card) { $register_cards[$index]['trigram'] = AxeptaApi::getTrigramByCcbrand($card['ccbrand']); $register_cards[$index]['pcnr'] = Tools::substr($card['pcnr'], -3); } $this->context->smarty->assign('register_cards', $register_cards); foreach ($available_payments as $payment) { $front_label = $payment['axepta_configuration_account']['front_label']; // Create the payment $axepta_payment = new PaymentOption(); $axepta_payment->setCallToActionText($front_label != '' ? $front_label : $this->l('Pay with Axepta Online BNP Paribas.')); $axepta_payment->setAction($this->context->link->getModuleLink($this->name, 'redirect', array( ), true)); foreach ($payment['paygates'] as $value => $p) { if ($p['trigram'] == 'PAY' && !$this->context->customer->isLogged()) { unset($payment['paygates'][$value]); continue; } if ($p['trigram'] == 'FC3' || $p['trigram'] == 'FC4') { $total = $this->context->cart->getOrderTotal(); if ($total > AxeptaApi::MAX_CETELEM_AMOUNT || $total < AxeptaApi::MIN_CETELEM_AMOUNT) { unset($payment['paygates'][$value]); continue; } } if ($p['trigram'] == 'PRE') { $total = $this->context->cart->getOrderTotal(); if ($total > AxeptaApi::MAX_CETELEM_PRESTO_AMOUNT || $total < AxeptaApi::MIN_CETELEM_PRESTO_AMOUNT) { unset($payment['paygates'][$value]); continue; } } if ( $p['trigram'] == 'VIM' && $this->context->country->iso_code == 'FR' || $p['trigram'] == 'CVM' && $this->context->country->iso_code != 'FR' ) { unset($payment['paygates'][$value]); continue; } $merchant = new AxeptaConfigurationAccount($id_account); if ($merchant->oneclick) { $res = AxeptaConfigurationAccountPaygate::getIfOneClickExist($p['id_axepta_configuration_account_paygate']); if ($res) { $payment['paygates'][$value]['is_one_click'] = true; } } } if (!empty($payment['paygates'])) { $this->smarty->assign(array( 'module_axepta_dir' => $this->_path, 'account' => $payment['axepta_configuration_account'], 'paygates' => $this->sortPaygates($payment['paygates']), 'link' => new Link() )); $axepta_payment->setAdditionalInformation($this->fetch('module:axepta/views/templates/hook/payment.tpl')); $payments[] = $axepta_payment; } } } else { $this->context->smarty->assign('payment_recurring', $payment_recurring); foreach ($available_payments_reccuring as $payment) { // Create the payment $axepta_payment = new PaymentOption(); $axepta_payment->setCallToActionText($this->l('Pay with Axepta Online BNP Paribas Recurring')); $axepta_payment->setAction($this->context->link->getModuleLink($this->name, 'redirect', array(), true)); foreach ($payment['paygates'] as $value => $p) { if ( $p['trigram'] == 'VIM' && $this->context->country->iso_code == 'FR' || $p['trigram'] == 'CVM' && $this->context->country->iso_code != 'FR' ) { unset($payment['paygates'][$value]); continue; } } // Add the payment $this->smarty->assign(array( 'module_axepta_dir' => $this->_path, 'account' => $payment['axepta_configuration_account'], 'paygates' => $this->sortPaygates($payment['paygates']), )); $axepta_payment->setAdditionalInformation($this->fetch('module:axepta/views/templates/hook/payment.tpl')); $payments[] = $axepta_payment; } } $this->context->smarty->assign('payment_recurring', $payment_recurring); return $payments; } // Sort Paygates by xml_default private function sortPaygates($paygates) { $paygatesPosition = AxeptaXmlPaygatePosition::getPaygatesPositionByIso($this->context->country->iso_code); if (!$paygatesPosition) { $paygatesPosition = AxeptaXmlPaygatePosition::getPaygatesPositionByDefault(); } $newPaygateOrder = array(); $others = array(); $positions = array(); foreach ($paygatesPosition as $paygatePosition) { $positions[$paygatePosition['trigram']] = $paygatePosition['position']; } foreach ($paygates as $paygate) { if (isset($paygate['trigram']) && isset($positions[$paygate['trigram']])) { $newPaygateOrder[$positions[$paygate['trigram']]] = $paygate; } else { $others[] = $paygate; } } ksort($newPaygateOrder); $newPaygateOrder = array_merge(array_values($newPaygateOrder), $others); return $newPaygateOrder; } public function hookActionAdminControllerSetMedia($params) { $this->context->controller->addCSS($this->_path . 'views/css/back-all.css'); switch (Tools::getValue('controller')) { case 'AdminModules': case 'AdminManageAxeptaConf': case 'AdminOrders': case 'AdminAxeptaTransaction': case 'AdminManageAxeptaConf': case 'AdminProducts': $this->context->controller->addJS($this->_path . 'views/js/back.js'); $this->context->controller->addCSS($this->_path . 'views/css/back.css'); break; } } /** * Available Payments : return a list of available payment * * @param array $params list of specific data * @return array of payment */ public function getAvailablePayments($params, $operation) { if (!$params['cart']) { return false; } // retrieving currency $currency = Currency::getCurrency((int) $params['cart']->id_currency); if (!$currency) { return false; } $id_currency = $currency['id_currency']; // retrieving country $address = Address::getCountryAndState($params['cart']->id_address_invoice); if (!$address) { return false; } $id_country = $address['id_country']; if (!$id_country) { return false; } $id_shop = $params['cart']->id_shop; return AxeptaConfigurationAccount::getAvailablePayments($operation, $id_currency, $id_country, $id_shop); } /** * Available Payments : return a list of available payment * * @param array $params list of specific data * @return array of paymentgetAvailableRecurringPayments */ public function getAvailablePaymentsRecurring($params) { // Check if the payment method can be displayed if (!$params['cart']) { return false; } // retrieving currency $currency = Currency::getCurrency((int) $params['cart']->id_currency); if (!$currency) { return false; } $id_currency = $currency['id_currency']; // retrieving country $address = Address::getCountryAndState($params['cart']->id_address_invoice); if (!$address) { return false; } $id_country = $address['id_country']; if (!$id_country) { return false; } $id_shop = $params['cart']->id_shop; return AxeptaConfigurationAccount::getAvailableRecurringPayments($id_currency, $id_country, $id_shop); } public function canDisplayPayment($params) { if (!$this->active) { return false; } return true; } /** * Check if the payment can be displayed * @return boolean */ public function canDisplayPaymentRecurring() { // Check Key $product = new Product((int) Tools::getValue('id_product')); /*if (!$this->isFeatureActivated('ABO')) { return false; }*/ // Check if one product is in payment recurring $is_recurring = false; foreach ($this->context->cart->getProducts() as $product) { if ($is_recurring == false) { $is_recurring = AxeptaPaymentRecurring::isThisProductPaymentRecurring((int) $product['id_product']); } else { continue; } } if ($is_recurring == false) { return false; } return true; } /** * Decrypt Activation key */ public function isFeatureActivated($feature_list) { if (!is_array($feature_list)) { $feature_list = array( $feature_list); } $merchant_id = AxeptaApi::getIdAccountAndIdCurrency($this->context->country->id, $this->context->currency->id); if (!$merchant_id) { $merchant_id = AxeptaApi::getIdAccountByIdCountryAndIdCurrencyVerifyAllExist($this->context->country->id, $this->context->currency->id); } $merchant = new AxeptaConfigurationAccount($merchant_id); $keys = explode(';', $merchant->activation_key); array_pop($keys); $found = true; foreach ($feature_list as $feature) { if (!in_array($feature, $keys) && !$feature == "ABO" && !$feature == "ONE" && !$feature == "3DS") { $found = false; } } return $found; } }
💾 保存文件
← 返回文件管理器