* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6844 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_PS_VERSION_')) exit; class authorizeAIM extends PaymentModule { public function __construct() { $this->name = 'authorizeaim'; $this->tab = 'payments_gateways'; $this->version = '1.2.1'; $this->author = 'PrestaShop'; $this->limited_countries = array('us'); $this->need_instance = 0; parent::__construct(); $this->displayName = 'Authorize.net AIM (Advanced Integration Method)'; $this->description = $this->l('Receive payment with Authorize.net'); /* For 1.4.3 and less compatibility */ $updateConfig = array('PS_OS_CHEQUE', 'PS_OS_PAYMENT', 'PS_OS_PREPARATION', 'PS_OS_SHIPPING', 'PS_OS_CANCELED', 'PS_OS_REFUND', 'PS_OS_ERROR', 'PS_OS_OUTOFSTOCK', 'PS_OS_BANKWIRE', 'PS_OS_PAYPAL', 'PS_OS_WS_PAYMENT'); if (!Configuration::get('PS_OS_PAYMENT')) foreach ($updateConfig as $u) if (!Configuration::get($u) && defined('_'.$u.'_')) Configuration::updateValue($u, constant('_'.$u.'_')); } public function install() { return (parent::install() AND $this->registerHook('orderConfirmation') AND $this->registerHook('payment') AND Configuration::updateValue('AUTHORIZE_AIM_DEMO', 1)); } public function uninstall() { Configuration::deleteByName('AUTHORIZE_AIM_LOGIN_ID'); Configuration::deleteByName('AUTHORIZE_AIM_KEY'); Configuration::deleteByName('AUTHORIZE_AIM_DEMO'); Configuration::deleteByName('AUTHORIZE_AIM_CARD_VISA'); Configuration::deleteByName('AUTHORIZE_AIM_CARD_MASTERCARD'); Configuration::deleteByName('AUTHORIZE_AIM_CARD_DISCOVER'); Configuration::deleteByName('AUTHORIZE_AIM_CARD_AX'); return parent::uninstall(); } public function hookOrderConfirmation($params) { if ($params['objOrder']->module != $this->name) return; if ($params['objOrder']->getCurrentState() != Configuration::get('PS_OS_ERROR')) $this->context->smarty->assign(array('status' => 'ok', 'id_order' => intval($params['objOrder']->id))); else $this->context->smarty->assign('status', 'failed'); return $this->display(__FILE__, 'hookorderconfirmation.tpl'); } public function getContent() { if (Tools::isSubmit('submitModule')) { Configuration::updateValue('AUTHORIZE_AIM_LOGIN_ID', Tools::getvalue('authorizeaim_login_id')); Configuration::updateValue('AUTHORIZE_AIM_KEY', Tools::getvalue('authorizeaim_key')); Configuration::updateValue('AUTHORIZE_AIM_DEMO', Tools::getvalue('authorizeaim_demo_mode')); Configuration::updateValue('AUTHORIZE_AIM_CARD_VISA', Tools::getvalue('authorizeaim_card_visa')); Configuration::updateValue('AUTHORIZE_AIM_CARD_MASTERCARD', Tools::getvalue('authorizeaim_card_mastercard')); Configuration::updateValue('AUTHORIZE_AIM_CARD_DISCOVER', Tools::getvalue('authorizeaim_card_discover')); Configuration::updateValue('AUTHORIZE_AIM_CARD_AX', Tools::getvalue('authorizeaim_card_ax')); echo $this->displayConfirmation($this->l('Configuration updated')); } return '