SparkyRih Posted March 15, 2016 Share Posted March 15, 2016 (edited) I created an payment gateway addon, which works great... But when I tried to add it to the prestashop addons market I received an error... So to solve this I created a new prestashop installation, installed my plugin, configured it... But when I go the the modules page it says: "AfterPay: No name provided", when I click on that link, it brings me to my configuration page (which is filled in correctly)... What am I doing wrong? Edit: Suddenly (literally after doing nothing) the hook on the front end works, so the entire addon does work now, but I'm still left with the error on the module page... I think it's godo to have this solved before I release the addon... <?php if (!defined('_PS_VERSION_')) exit; class AfterPay extends PaymentModule { public function __construct() { $this->name = 'afterpay'; $this->tab = 'payments_gateways'; $this->version = '1.0.2'; $this->author = 'Schattorie Solutions'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); $this->bootstrap = true; $this->module_key = '9e9eb671e3795f7411062d90643ae82e'; parent::__construct(); $this->displayName = $this->l('AfterPay'); $this->description = $this->l('Connect your shop directly with AfterPay.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('MYMODULE_NAME')) $this->warning = $this->l('No name provided'); } public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('paymentReturn') || !Configuration::updateValue('AFTERPAY_MODUS', '') || !Configuration::updateValue('AFTERPAY_MERCHANT_ID', '') || !Configuration::updateValue('AFTERPAY_PORTOFOLIO_ID', '') || !Configuration::updateValue('AFTERPAY_PASSWORD', '') ) return false; return true; } public function uninstall() { if (!parent::uninstall() || !Configuration::deleteByName('AFTERPAY_MODUS') || !Configuration::deleteByName('AFTERPAY_MERCHANT_ID') || !Configuration::deleteByName('AFTERPAY_PORTOFOLIO_ID') || !Configuration::deleteByName('AFTERPAY_PASSWORD') ) return false; return true; } public function hookPayment($params) { global $smarty; $smarty->assign(array( 'my_module_name' => Configuration::get('MYMODULE_NAME'), 'this_path' => $this->_path, 'this_path_ssl' => Configuration::get('PS_FO_PROTOCOL').$_SERVER['HTTP_HOST'].__PS_BASE_URI__."modules/{$this->name}/") ); return $this->display(__FILE__, 'payment.tpl'); } public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $modus = strval(Tools::getValue('AFTERPAY_MODUS')); $merchant_id = strval(Tools::getValue('AFTERPAY_MERCHANT_ID')); $portofolio_id = strval(Tools::getValue('AFTERPAY_PORTOFOLIO_ID')); $password = strval(Tools::getValue('AFTERPAY_PASSWORD')); Configuration::updateValue('AFTERPAY_MODUS', $modus); if (!$merchant_id || empty($merchant_id) || !Validate::isGenericName($merchant_id)) { $output .= $this->displayError($this->l('Merchant id field error')); } elseif (!$portofolio_id || empty($portofolio_id) || !Validate::isGenericName($portofolio_id)) { $output .= $this->displayError($this->l('Portofolio id field error')); } elseif (!$password || empty($password) || !Validate::isGenericName($password)) { $output .= $this->displayError($this->l('Password field error')); } else { Configuration::updateValue('AFTERPAY_MERCHANT_ID', $merchant_id); Configuration::updateValue('AFTERPAY_PORTOFOLIO_ID', $portofolio_id); Configuration::updateValue('AFTERPAY_PASSWORD', $password); $output .= $this->displayConfirmation($this->l('Settings updated')); } } return $output.$this->displayForm(); } public function displayForm() { // Get default language $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); // Init Fields form array $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Settings'), ), 'input' => array( array( 'type' => 'radio', 'label' => $this->l('Production environment'), 'desc'=> $this->l('Set to disabled for simulation.'), 'name' => 'AFTERPAY_MODUS', 'required' => false, 'is_bool' => true, 'values' => array( // $values contains the data itself. array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') // The <label> for this radio button. ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'text', 'label' => $this->l('Merchant ID'), 'name' => 'AFTERPAY_MERCHANT_ID', 'size' => 20, 'required' => true ), array( 'type' => 'text', 'label' => $this->l('Portofolio ID'), 'name' => 'AFTERPAY_PORTOFOLIO_ID', 'size' => 20, 'required' => true ), array( 'type' => 'text', 'label' => $this->l('Password'), 'name' => 'AFTERPAY_PASSWORD', 'size' => 20, 'required' => true ) ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'button' ) ); $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; // Title and toolbar $helper->title = $this->displayName; $helper->show_toolbar = true; // false -> remove toolbar $helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $helper->submit_action = 'submit'.$this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules'), ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); // Load current value $helper->fields_value['AFTERPAY_MODUS'] = Configuration::get('AFTERPAY_MODUS'); $helper->fields_value['AFTERPAY_MERCHANT_ID'] = Configuration::get('AFTERPAY_MERCHANT_ID'); $helper->fields_value['AFTERPAY_PORTOFOLIO_ID'] = Configuration::get('AFTERPAY_PORTOFOLIO_ID'); $helper->fields_value['AFTERPAY_PASSWORD'] = Configuration::get('AFTERPAY_PASSWORD'); return $helper->generateForm($fields_form); } } ?> Edited March 15, 2016 by SparkyRih (see edit history) Link to comment Share on other sites More sharing options...
Wágner Tamás Posted October 4, 2018 Share Posted October 4, 2018 Old thread, but maybe it helps to someone: If your module is not configured (MYMODULE_NAME), Presta will display the message defined in the code below The text can be missleading, I had the same problem, my module needs no configuration, so I removed this two lines, In your case probably configuring your module removed the message too... if (!Configuration::get('MYMODULE_NAME')) $this->warning = $this->l('No name provided'); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now