0

What am I doing wrong? This is what I have in commerce_xpay.install.

function commerce_xpay_schema() {
    $schema = array();

    $schema['commerce_xpay_ipn'] = array(
            'description' => 'Stores processed IPNs.',
            'fields' => array(
                    'ipn_id' => array(
                            'description' => 'Serial numeric ID of the IPN in the local database.',
                            'type' => 'serial',
                            'unsigned' => TRUE,
                            'not null' => TRUE,
                    ),
                    'transaction_id' => array(
                            'description' => 'The X-Pay transaction ID.',
                            'type' => 'varchar',
                            'length' => 255,
                            'not null' => TRUE,
                            'default' => '',
                    ),
                    'terminal_id' => array(
                            'description' => 'The X-Pay terminal id',
                            'type' => 'varchar',
                            'length' => 255,
                            'not null' => TRUE,
                            'default' => '',
                    ),
                    'response' => array(
                            'description' => 'The response of the server',
                            'type' => 'varchar',
                            'length' => 255,
                            'not null' => TRUE,
                            'default' => '',
                    ),
                    'payer_email' => array(
                            'description' => 'The e-mail of the payer.',
                            'type' => 'varchar',
                            'length' => 255,
                            'not null' => TRUE,
                            'default' => '',
                    ),
                    'transaction_date' => array(
                            'description' => 'The date of the transaction.',
                            'type' => 'date',
                            'not null' => TRUE,
                    ),
                    'card_type' => array(
                            'description' => 'The type of the card used in the transaction.',
                            'type' => 'varchar',
                            'length' => 255,
                            'not null' => TRUE,
                            'default' => '',
                    ),
                    'amount' => array(
                            'description' => 'The amount of the transaction.',
                            'type' => 'varchar',
                            'length' => 255,
                            'not null' => TRUE,
                            'default' => '',
                    ),
                    'transaction_type' => array(
                            'description' => 'The type of the transaction.',
                            'type' => 'varchar',
                            'length' => 255,
                            'not null' => TRUE,
                            'default' => '',
                    ),
                    'mac' => array(
                            'description' => 'The amount of the transaction.',
                            'type' => 'varchar',
                            'length' => 255,
                            'not null' => TRUE,
                            'default' => '',
                    ),
                    'currency' => array(
                            'description' => 'The currency used for the transaction.',
                            'type' => 'varchar',
                            'length' => 255,
                            'not null' => TRUE,
                            'default' => '',
                    ),
                    'order_id' => array(
                            'description' => 'The order ID the payment belongs to.',
                            'type' => 'int',
                            'unsigned' => TRUE,
                            'not null' => TRUE,
                            'default' => 0,
                    ),
                    'txn_id' => array(
                            'description' => 'The payment transaction ID the payment belongs to.',
                            'type' => 'int',
                            'unsigned' => TRUE,
                            'not null' => TRUE,
                            'default' => 0,
                    ),
                    'created' => array(
                            'description' => 'The Unix timestamp when the IPN was received.',
                            'type' => 'int',
                            'not null' => TRUE,
                            'default' => 0,
                    ),
                    'changed' => array(
                            'description' => 'The Unix timestamp when the IPN was last updated.',
                            'type' => 'int',
                            'not null' => TRUE,
                            'default' => 0,
                    ),
                    'test_ipn' => array(
                            'description' => 'Boolean indicating whether or not this was a test IPN sent by the Sandbox.',
                            'type' => 'int',
                            'size' => 'tiny',
                            'not null' => TRUE,
                            'default' => 0,
                    ),
            ),
            'primary key' => array('ipn_id'),
            'foreign keys' => array(
                    'order_id' => array(
                            'table' => 'commerce_order',
                            'columns'=> array('order_id' => 'order_id'),
                    ),
                    'txn_id' => array(
                            'table' => 'commerce_payment_transaction',
                            'columns'=> array('payment_id' => 'payment_id'),
                    ),
            ),
            'indexes' => array(
                    'transaction_id' => array('transaction_id'),
            ),
    );

    return $schema;
}
  • 2
    Do you completely disable and uninstall the module between your attempts? Your schema definition will not be called again once your module has been installed. – marcvangend Mar 26 '12 at 13:11
  • @marcvangend i simply disable the module withouth uninstalling it, so this might be the issue. Since i'm developing a custom module, to simulate an install i need to package the module and install it through the interface? – Nicola Peluchetti Mar 26 '12 at 13:13
3

It's hard to know without seeing an error message, but at first glance I'd guess it's because of the transaction_date column.

date is not a valid data type in Drupal 7 (see Data Types). You can either use an int column and store a UNIX timestamp, or use the mysql_type property instead of type, and set that datetime.

| improve this answer | |
  • This is true, there is no error message but that is because i wasn't uninstalling the module before re-installing it i'm afraid – Nicola Peluchetti Mar 26 '12 at 13:16
  • Ah ok! I'd advise installing the Devel module...then you can go to mysite.com/devel/reinstall and get your module re-installed automatically – Clive Mar 26 '12 at 13:22
  • Perfect, everything works correctly. – Nicola Peluchetti Mar 26 '12 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.