You are here

uc_paypal.install in Ubercart 5

File

payment/uc_paypal/uc_paypal.install
View source
<?php

/**
 * Implementation of hook_install().
 */
function uc_paypal_install() {
  $t = get_t();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {uc_payment_paypal_ipn} (\n        order_id int(11) NOT NULL,\n        txn_id varchar(255) NOT NULL,\n        txn_type varchar(255) NOT NULL,\n        mc_gross varchar(255) NOT NULL,\n        status varchar(255) NOT NULL,\n        receiver_email varchar(255) NOT NULL,\n        payer_email varchar(255) NOT NULL,\n        received int(11) NOT NULL,\n        KEY order_id (order_id)\n      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
      db_query("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES ('paypal_pending', '" . $t('PayPal pending') . "', 'payment_received', 7, 1);");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {uc_payment_paypal_ipn} (\n        order_id integer NOT NULL,\n        txn_id varchar(255) NOT NULL,\n        txn_type varchar(255) NOT NULL,\n        mc_gross varchar(255) NOT NULL,\n        status varchar(255) NOT NULL,\n        receiver_email varchar(255) NOT NULL,\n        payer_email varchar(255) NOT NULL,\n        received integer NOT NULL\n      );");
      db_query("CREATE INDEX {uc_payment_paypal_ipn}_order_id ON {uc_payment_paypal_ipn} (order_id)");
      db_query("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES ('paypal_pending', '" . $t('PayPal pending') . "', 'payment_received', 7, 1);");
      break;
  }
}

/**
 * Implementation of hook_uninstall().
 */
function uc_paypal_uninstall() {
  db_query("DROP TABLE {uc_payment_paypal_ipn}");
}
function uc_paypal_update_1() {

  // Clean out the old order status table and redefine its structure.
  if ($_SESSION['statuses'] !== TRUE) {
    $ret[] = update_sql("ALTER TABLE {uc_order_statuses} CHANGE order_status_id order_status_id VARCHAR(32) CHARACTER SET utf8 NOT NULL default ''");
    $ret[] = update_sql("ALTER TABLE {uc_order_statuses} CHANGE title title VARCHAR(48) CHARACTER SET utf8 NOT NULL default ''");
    $ret[] = update_sql("ALTER TABLE {uc_order_statuses} CHANGE notify state VARCHAR(32) CHARACTER SET utf8 NOT NULL default ''");
    $ret[] = update_sql("ALTER TABLE {uc_order_statuses} ADD weight MEDIUMINT(9) NOT NULL");
    $ret[] = update_sql("ALTER TABLE {uc_order_statuses} ADD locked TINYINT NOT NULL DEFAULT '0'");
    $ret[] = update_sql("DELETE FROM {uc_order_statuses} WHERE order_status_id LIKE '_'");
    $_SESSION['statuses'] = TRUE;
  }
  $t = get_t();
  $ret[] = update_sql("INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) VALUES ('paypal_pending', '" . $t('PayPal pending') . "', 'payment_received', 7, 1);");
  return $ret;
}
function uc_paypal_update_2() {

  // Change the variable used to define the default transaction type.
  if (variable_get('uc_paypal_wpp_payment_action', 'Sale') == 'Sale') {
    variable_set('uc_pg_paypal_wpp_cc_txn_type', UC_CREDIT_AUTH_CAPTURE);
  }
  else {
    variable_set('uc_pg_paypal_wpp_cc_txn_type', UC_CREDIT_AUTH_ONLY);
  }
  variable_del('uc_paypal_wpp_payment_action');

  // Fix a bug in a variable name.
  variable_set('uc_paypal_wps_submit_method', variable_get('uc_paypal_wbs_submit_method', 'single'));
  variable_del('uc_paypal_wbs_submit_method');
  return array();
}

Functions