Jump to content

Payment Module not creating DB Tables


Recommended Posts

I am developing a module to pass transactions to a bank and then save transaction info to a MySQL table.

During development I stumbled upon 2 critical problems:

  1. My payment module doesn't create a DB Table after installation and yet there are no errors. I can configure it without a problem.
  2. This module is absent from payment methods list in FO. (I have all checkboxes enabled in Payment > Options)

I am including a link to Pastebin showcasing module.php file.

You can ignore createPSign() and checkPSign() functions as they are used for generating a key for bank communication.

Share this post


Link to post
Share on other sites

Try this and execute the query manually:

 

private function installSQL()
    {
        $sql = array();
 
        $sql[] = "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."HIDDEN_transactions` (
           `id` BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
           `id_cart` INT(10) UNSIGNED NOT NULL,
           `id_order` INT(10) UNSIGNED DEFAULT NULL,
           `ammount` DECIMAL(8,2) NOT NULL,
           `currency` VARCHAR(3) NOT NULL,
           `order` VARCHAR(32) NOT NULL,
           `desc` TEXT,
           `merch_name` VARCHAR(64) NOT NULL,
           `merch_url` VARCHAR(64) NOT NULL,
           `merchant` BIGINT(15) NOT NULL,
           `terminal` MEDIUMINT(8) UNSIGNED NOT NULL,
           `email` VARCHAR(64) NOT NULL,
           `merch_address` VARCHAR(64) NOT NULL,
           `trtype` TINYINT(2) UNSIGNED NOT NULL,
           `country` VARCHAR(2) NOT NULL,
           `merch_gmt` VARCHAR(5) NOT NULL,
           `timestamp` BIGINT(14) NOT NULL,
           `nonce` VARCHAR(64) NOT NULL,
           `p_sign` TEXT,
           `lang` VARCHAR(2) NOT NULL,
           `action` ENUM('0','1','2','3') DEFAULT NULL,
           `rc` VARCHAR(3) DEFAULT NULL,
           `approval` VARCHAR(6) DEFAULT NULL,
           `rrn` VARCHAR(12) DEFAULT NULL,
           `int_ref` VARCHAR(32) DEFAULT NULL,
           `eci` ENUM('05','06','07') DEFAULT NULL
       ) ENGINE = "._MYSQL_ENGINE_;
 var_dump($sql);die;
        foreach ($sql as $q) {
            if (!DB::getInstance()->execute($sql)) {
                return false;
            }
        }
    }

 

Share this post


Link to post
Share on other sites
Quote

Try this and execute the query manually:


private function installSQL()
    {
        $sql = array();
 
        $sql[] = "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."HIDDEN_transactions` (
           `id` BIGINT(20) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
           `id_cart` INT(10) UNSIGNED NOT NULL,
           `id_order` INT(10) UNSIGNED DEFAULT NULL,
           `ammount` DECIMAL(8,2) NOT NULL,
           `currency` VARCHAR(3) NOT NULL,
           `order` VARCHAR(32) NOT NULL,
           `desc` TEXT,
           `merch_name` VARCHAR(64) NOT NULL,
           `merch_url` VARCHAR(64) NOT NULL,
           `merchant` BIGINT(15) NOT NULL,
           `terminal` MEDIUMINT(8) UNSIGNED NOT NULL,
           `email` VARCHAR(64) NOT NULL,
           `merch_address` VARCHAR(64) NOT NULL,
           `trtype` TINYINT(2) UNSIGNED NOT NULL,
           `country` VARCHAR(2) NOT NULL,
           `merch_gmt` VARCHAR(5) NOT NULL,
           `timestamp` BIGINT(14) NOT NULL,
           `nonce` VARCHAR(64) NOT NULL,
           `p_sign` TEXT,
           `lang` VARCHAR(2) NOT NULL,
           `action` ENUM('0','1','2','3') DEFAULT NULL,
           `rc` VARCHAR(3) DEFAULT NULL,
           `approval` VARCHAR(6) DEFAULT NULL,
           `rrn` VARCHAR(12) DEFAULT NULL,
           `int_ref` VARCHAR(32) DEFAULT NULL,
           `eci` ENUM('05','06','07') DEFAULT NULL
       ) ENGINE = "._MYSQL_ENGINE_;
 var_dump($sql);die;
        foreach ($sql as $q) {
            if (!DB::getInstance()->execute($sql)) {
                return false;
            }
        }
    }

 

 

The database itself is not of that much importance. Creating a table manually doesn't solve the problem.

As for: 

var_dump($sql);die;

Module is installed without a problem. As if installSQL function is not triggered.

To test it I added following line at the start of installSQL function:

PrestaShopLogger::addLog('Executing IntsallSQL', 1);

No log was created.

Share this post


Link to post
Share on other sites
  • 2 weeks later...

Unfortunately, I did not solve this problem. But I might have found the cause. At the moment of bug, I had nginx with PHP 7.3, so I switched to apache and downgraded to PHP 7.2. After that, I installed a fresh copy of Prestashop 1.7.5.1.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More