You are here

commerce_worldpay_bg.install in Commerce Worldpay 7

Installs the tables required by Commerce WorldPay.

File

commerce_worldpay_bg.install
View source
<?php

/**
 * @file
 * Installs the tables required by Commerce WorldPay.
 */

/**
 * Implements hook_schema().
 */
function commerce_worldpay_bg_schema() {
  $schema = array();
  $schema['commerce_worldpay_bg_txn'] = array(
    'description' => 'Stores more details on a WorldPay transaction.',
    'fields' => array(
      'txn_id' => array(
        'description' => 'Serial numeric ID of the transaction in the local database.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'txn_md5' => array(
        'description' => 'The WorldPay transaction ID.',
        '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,
      ),
      // transId.
      'wp_txn_id' => array(
        'description' => 'Wolrdpay\'s transaction id.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      // Foreign key.
      'transaction_id' => array(
        'description' => 'The DC payment transaction ID the payment belongs to.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      // authMode - A or E.
      'authmode' => array(
        'description' => 'The authorisation mode used. A = Full auth. E = pre-auth',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      // transStatus - 'pre' is our own status meaning that
      // no comunication has happended with wolrdpay yet.
      'transaction_status' => array(
        'description' => 'The status set by Worldpay (Y or C).',
        'type' => 'varchar',
        'length' => 3,
        'not null' => TRUE,
        'default' => 'pre',
      ),
      'name' => array(
        'description' => 'The buyer name WorldPay sent.',
        'type' => 'varchar',
        'length' => 100,
        'not null' => TRUE,
        'default' => '',
      ),
      'shoppers_email' => array(
        'description' => 'The e-mail the shopper used at Worldpay.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      // companyName.
      'company_name' => array(
        'description' => 'The company name Worldpay sent that corresponds to an installtion.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'currency' => array(
        'description' => 'The currency code of the payment use by Worldpay.',
        'type' => 'varchar',
        'length' => 10,
        'not null' => TRUE,
        'default' => '',
      ),
      'amount' => array(
        'description' => 'The amount of fees collected by Worldpay for this payment.',
        'type' => 'numeric',
        'size' => 'normal',
        'precision' => 10,
        'scale' => 2,
        'not null' => TRUE,
        'default' => 0,
      ),
      // authCurrency.
      'auth_currency' => array(
        'description' => 'The currency code of the payment use by Worldpay.',
        'type' => 'varchar',
        'length' => 10,
        'not null' => TRUE,
        'default' => '',
      ),
      // authAmount.
      'auth_amount' => array(
        'description' => 'Amount that the transaction was authorised for, in the currency given as auth_currency..',
        'type' => 'numeric',
        'size' => 'normal',
        'precision' => 10,
        'scale' => 2,
        'not null' => TRUE,
        'default' => 0,
      ),
      // rawAuthMessage.
      'raw_auth_message' => array(
        'description' => 'The text received from the bank summarising the different states.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      // wafMerchMessage.
      'waf_merch_message' => array(
        'description' => 'Risk managment fraud messages.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      // AVS.
      'avs' => array(
        'description' => 'Risk managment fraud messages.',
        'type' => 'varchar',
        'length' => 5,
        'not null' => TRUE,
        'default' => '',
      ),
      'authentication' => array(
        'description' => 'SecureCode authentication.',
        'type' => 'varchar',
        'length' => 30,
        'not null' => TRUE,
        'default' => '',
      ),
      // The IP address WorldPay thinks the payment came from.
      'ip_address' => array(
        'description' => 'IP address of user accessing WorldPay.',
        'type' => 'varchar',
        'length' => 30,
        'not null' => TRUE,
        'default' => '',
      ),
      'created' => array(
        'description' => 'The Unix timestamp when this row 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,
      ),
      // transTime.
      'transaction_time' => array(
        'description' => 'The Unix timestamp when Worldpay made contact. (transTime)',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'test_mode' => array(
        'description' => 'Boolean indicating whether or not this was a test sent by Worldpays test mode.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'signature_fields' => array(
        'description' => 'The fields used to create the MD5.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'txn_id',
    ),
    'foreign keys' => array(
      'order_id' => array(
        'table' => 'commerce_order',
        'columns' => array(
          'order_id' => 'order_id',
        ),
      ),
      'transaction_id' => array(
        'table' => 'commerce_payment_transaction',
        'columns' => array(
          'transaction_id' => 'transaction_id',
        ),
      ),
    ),
    'indexes' => array(
      'wp_txn_id' => array(
        'wp_txn_id',
      ),
      'txn_md5' => array(
        'txn_md5',
      ),
    ),
  );
  return $schema;
}

Functions

Namesort descending Description
commerce_worldpay_bg_schema Implements hook_schema().