Payson payment module gives strange SQL errors in VM3 (Sweden)

Started by loppan, December 27, 2015, 01:34:05 AM

Previous topic - Next topic

loppan

Hi all,

This concerns the Swedish payment module "Payson" only, but I suppose I can't be the only Swedish Virtuemart user in this forum, so I'm curious to hear if anyone else have this issue with Payson's Virtuemart module, and hopefully we can solve this together :). Since this is Payson's own module I'm a little surprised it does not work on my system... So I'm truly grateful for any ideas here.

I downloaded the module from here : https://github.com/PaysonAB/module-payson-virtuemart-3 ,
and followed the instructions given in here :
https://github.com/PaysonAB/module-payson-virtuemart-3/blob/master/Virtuemart%20payson%20installation.pdf

The plugin installation in Joomla returns no error, so as far as I can see, this part works for me.

However, once I try to save any of it's settings in VM, I get the following error :

QuoteAn error has occurred.
1068 Multiple primary key defined SQL=CREATE TABLE IF NOT EXISTS `jos_virtuemart_payment_plg_paysondirect` (`id` int(1) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , `virtuemart_order_id` int(1) UNSIGNED , `order_number` char(64) , `virtuemart_paymentmethod_id` mediumint(1) UNSIGNED , `payment_name` varchar(5000) , `payment_order_total` decimal(15,5) NOT NULL DEFAULT '0.00000' , `payment_currency` char(3) , `cost_per_transaction` decimal(10,2) , `cost_percent_total` decimal(10,2) , `tax_id` smallint(1) , `added` datetime , `updated` datetime , `valid` tinyint(1) NOT NULL , `ipn_status` varchar(65) , `token` varchar(255) , `sender_email` varchar(50) , `tracking_id` varchar(100) , `type` varchar(50) , `purchase_id` varchar(50) , `invoice_status` varchar(50) , `customer` varchar(50) , `shippingAddress_name` varchar(50) , `shippingAddress_street_ddress` varchar(60) , `shippingAddress_postal_code` varchar(20) , `shippingAddress_city` varchar(60) , `shippingAddress_country` varchar(60) , `created_on` datetime NOT NULL default '0000-00-00 00:00:00' , `created_by` int(11) NOT NULL DEFAULT '0' , `modified_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' , `modified_by` int(11) NOT NULL DEFAULT '0' , `locked_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' , `locked_by` int(11) NOT NULL DEFAULT '0' , PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='' AUTO_INCREMENT=1 ;

The settings are however saved, and I see the payment method during checkout, but checking out with it fails with another error message (since the jos_virtuemart_payment_plg_paysondirect-table can't be found).

I would be truly grateful for any ideas on why I get the "1068 Multiple primary key defined" error, and hence why the correct database table won't be created.

Many thanks in advance!

Best regards

Peter

GJC Web Design

just try removing the prim key declare in paysondirect.php

/**
     * Fields to create the payment table
     * @return string SQL Fileds
     */
    function getTableSQLFields() {
        $SQLfields = array(
            'id' => 'int(1) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
            'virtuemart_order_id' => 'int(1) UNSIGNED',
            'order_number' => 'char(64)',
            'virtuemart_paymentmethod_id' => 'mediumint(1) UNSIGNED',
            'payment_name' => 'varchar(5000)',
            'payment_order_total' => 'decimal(15,5) NOT NULL DEFAULT \'0.00000\'',
            'payment_currency' => 'char(3)',
            'cost_per_transaction' => 'decimal(10,2)',
            'cost_percent_total' => 'decimal(10,2)',
            'tax_id' => 'smallint(1)',
            'added' => 'datetime',
            'updated' => 'datetime',
            'valid' => 'tinyint(1) NOT NULL',
            'ipn_status' => 'varchar(65)',
            'token' => 'varchar(255)',
            'sender_email' => 'varchar(50)',
            'tracking_id' => 'varchar(100)',
            'type' => 'varchar(50)',
            'purchase_id' => 'varchar(50)',
            'invoice_status' => 'varchar(50)',
            'customer' => 'varchar(50)',
            'shippingAddress_name' => 'varchar(50)',
            'shippingAddress_street_ddress' => 'varchar(60)',
            'shippingAddress_postal_code' => 'varchar(20)',
            'shippingAddress_city' => 'varchar(60)',
            'shippingAddress_country' => 'varchar(60)',
        );

        return $SQLfields;
    }


change to 

'id' => 'int(1) UNSIGNED NOT NULL AUTO_INCREMENT',

and reinstall the plugin
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

loppan

Alright! I did the change and it seems to work just fine now. Just out of curiosity, I wonder why the "PRIMARY KEY" was there in the first place? Either way... I contacted the developers and suggested this change. I can't be the only one having this problem ;).

GJC Web Design

its wrong.. this is only for the fields

the table creation sql already states the id as the prim key so then there is a double statement which sql doesn't like

their code is wrong
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation