Exemplo n.º 1
0
 public function install()
 {
     if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('displayPaymentEU') || !$this->registerHook('paymentReturn') || !$this->registerHook('shoppingCartExtra') || !$this->registerHook('backBeforePayment') || !$this->registerHook('rightColumn') || !$this->registerHook('cancelProduct') || !$this->registerHook('productFooter') || !$this->registerHook('header') || !$this->registerHook('adminOrder') || !$this->registerHook('backOfficeHeader') || !$this->registerHook('actionPSCleanerGetModulesTables')) {
         return false;
     }
     if (_PS_VERSION_ >= '1.5' && (!$this->registerHook('displayMobileHeader') || !$this->registerHook('displayMobileShoppingCartTop') || !$this->registerHook('displayMobileAddToCartTop'))) {
         return false;
     }
     include_once _PS_MODULE_DIR_ . $this->name . '/paypal_install.php';
     $paypal_install = new PayPalInstall();
     $paypal_install->createTables();
     $paypal_install->updateConfiguration($this->version);
     $paypal_install->createOrderState();
     $paypal_tools = new PayPalTools($this->name);
     $paypal_tools->moveTopPayments(1);
     $paypal_tools->moveRightColumn(3);
     $this->runUpgrades(true);
     return true;
 }
Exemplo n.º 2
0
    public function install()
    {
        /* Install and register on hook */
        if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('paymentReturn') || !$this->registerHook('shoppingCartExtra') || !$this->registerHook('backBeforePayment') || !$this->registerHook('rightColumn') || !$this->registerHook('cancelProduct') || !$this->registerHook('productFooter') || !$this->registerHook('header') || !$this->registerHook('adminOrder') || !$this->registerHook('backOfficeHeader')) {
            return false;
        }
        if (_PS_VERSION_ >= '1.5' && (!$this->registerHook('displayMobileHeader') || !$this->registerHook('displayMobileShoppingCartTop') || !$this->registerHook('displayMobileAddToCartTop'))) {
            return false;
        }
        if (file_exists(_PS_MODULE_DIR_ . $this->name . '/paypal_tools.php')) {
            include_once _PS_MODULE_DIR_ . $this->name . '/paypal_tools.php';
            $paypal_tools = new PayPalTools($this->name);
            $paypal_tools->moveTopPayments(1);
            $paypal_tools->moveRightColumn(3);
        }
        if (file_exists(_PS_MODULE_DIR_ . '/paypalapi/paypalapi.php') && !Configuration::get('PAYPAL_NEW')) {
            include_once _PS_MODULE_DIR_ . '/paypalapi/paypalapi.php';
            new PaypalAPI();
            $this->runUpgrades(true);
        }
        /* Set database */
        if (!Db::getInstance()->Execute('
		CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'paypal_order` (
			`id_order` int(10) unsigned NOT NULL,
			`id_transaction` varchar(255) NOT NULL,
			`id_invoice` varchar(255) DEFAULT NULL,
			`currency` varchar(10) NOT NULL,
			`total_paid` varchar(50) NOT NULL,
			`shipping` varchar(50) NOT NULL,
			`capture` int(2) NOT NULL,
			`payment_date` varchar(50) NOT NULL,
			`payment_method` int(2) unsigned NOT NULL,
			`payment_status` varchar(255) DEFAULT NULL,
			PRIMARY KEY (`id_order`)
		) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8')) {
            return false;
        }
        /* Set database */
        if (!Db::getInstance()->Execute('
		CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'paypal_customer` (
			`id_paypal_customer` int(10) unsigned NOT NULL AUTO_INCREMENT,
			`id_customer` int(10) unsigned NOT NULL,
			`paypal_email` varchar(255) NOT NULL,
			PRIMARY KEY (`id_paypal_customer`)
		) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8 AUTO_INCREMENT=1')) {
            return false;
        }
        /* Set configuration */
        Configuration::updateValue('PAYPAL_SANDBOX', 0);
        Configuration::updateValue('PAYPAL_HEADER', '');
        Configuration::updateValue('PAYPAL_BUSINESS', 0);
        Configuration::updateValue('PAYPAL_BUSINESS_ACCOUNT', '*****@*****.**');
        Configuration::updateValue('PAYPAL_API_USER', '');
        Configuration::updateValue('PAYPAL_API_PASSWORD', '');
        Configuration::updateValue('PAYPAL_API_SIGNATURE', '');
        Configuration::updateValue('PAYPAL_EXPRESS_CHECKOUT', 0);
        Configuration::updateValue('PAYPAL_CAPTURE', 0);
        Configuration::updateValue('PAYPAL_PAYMENT_METHOD', WPS);
        Configuration::updateValue('PAYPAL_NEW', 1);
        Configuration::updateValue('PAYPAL_DEBUG_MODE', 0);
        Configuration::updateValue('PAYPAL_SHIPPING_COST', 20.0);
        Configuration::updateValue('PAYPAL_EXPRESS_CHECKOUT_SHORTCUT', 1);
        Configuration::updateValue('PAYPAL_VERSION', $this->version);
        Configuration::updateValue('PAYPAL_COUNTRY_DEFAULT', (int) Configuration::get('PS_COUNTRY_DEFAULT'));
        if (!Configuration::get('PAYPAL_OS_AUTHORIZATION')) {
            $orderState = new OrderState();
            $orderState->name = array();
            foreach (Language::getLanguages() as $language) {
                if (strtolower($language['iso_code']) == 'fr') {
                    $orderState->name[$language['id_lang']] = 'Autorisation acceptée par PayPal';
                } else {
                    $orderState->name[$language['id_lang']] = 'Authorization accepted from PayPal';
                }
            }
            $orderState->send_email = false;
            $orderState->color = '#DDEEFF';
            $orderState->hidden = false;
            $orderState->delivery = false;
            $orderState->logable = true;
            $orderState->invoice = true;
            if ($orderState->add()) {
                copy(dirname(__FILE__) . '/../../img/os/' . Configuration::get('PS_OS_PAYPAL') . '.gif', dirname(__FILE__) . '/../../img/os/' . (int) $orderState->id . '.gif');
            }
            Configuration::updateValue('PAYPAL_OS_AUTHORIZATION', (int) $orderState->id);
        }
        return true;
    }