--- drupal-6.13/sites/all/modules/uc_ogone/uc_ogone_payment.install.org	2009-08-08 07:22:57.000000000 +0200
+++ drupal-6.13/sites/all/modules/uc_ogone/uc_ogone_payment.install	2009-09-17 09:49:04.000000000 +0200
@@ -1,11 +1,12 @@
 <?php
+// $Id$
 
 /**
  * Implementation of hook_schema().
  */
 function uc_ogone_payment_schema() {
   $schema['uc_payment_ogone'] = array(
-    'description' => t('Table for ogone payments.'),
+    'description' => t('History table for ogone payments.'),
     'fields' => array(
       'order_id' => array(
         'description' => t('Ubercart order id'),
@@ -13,32 +14,62 @@
         'size' => 'medium',
         'not null' => TRUE,
       ),
-      'description' => array(
-        'description' => t('Description'),
+      'timestamp' => array(
+        'description' => t('Timestamp of the callback occurence.'),
+        'type' => 'datetime',
+        'not null' => TRUE,
+      ),
+      'payment_id' => array(
+        'description' => t('Ogone payment id'),
+        'type' => 'int',
+      ),
+      'payment_date' => array(
+        'description' => t('Ogone payment transaction date'),
+        'type' => 'datetime',
+      ),
+      'payment_acceptance' => array(
+        'description' => t('Ogone acceptance code returned by acquirer'),
         'type' => 'varchar',
         'length' => 64,
-        'not null' => TRUE,
       ),
       'payment_method' => array(
         'description' => t('Ogone payment method'),
         'type' => 'varchar',
         'length' => 64,
-        'not null' => TRUE,
       ),
-      'order_status' => array(
+      'payment_status' => array(
         'description' => t('Order payment status'),
         'type' => 'int',
         'size' => 'tiny',
-        'not null' => TRUE,
       ),
-      'sha1_test_succes' => array(
-        'description' => t('Ogone SHA1 test succes'),
-        'type' => 'text',
-        'size' => 'small',
+      'card_brand' => array(
+        'description' => t('Card brand'),
+        'type' => 'varchar',
+        'length' => 20,
+      ),
+      'card_no' => array(
+        'description' => t('Card number'),
+        'type' => 'varchar',
+        'length' => 20,
+      ),
+      'error_code' => array(
+        'description' => t('Order payment error code'),
+        'type' => 'varchar',
+        'length' => 8,
+      ),
+      'error_message' => array(
+        'description' => t('Order payment error message'),
+        'type' => 'varchar',
+        'length' => 255, 
+      ),
+      'sha1_match' => array(
+        'description' => t('Ogone SHA1 signature match'),
+        'type' => 'int',
+        'size' => 'tiny',
         'not null' => TRUE,
       ),
     ),
-    'primary key' => array('order_id'),
+    'primary key' => array('order_id', 'timestamp'),
   );
 
   return $schema;
@@ -50,4 +81,37 @@
 function uc_ogone_payment_install() {
   // Create tables.
   drupal_install_schema('uc_ogone_payment');
+  
+  $insert = "INSERT INTO {uc_order_statuses} (order_status_id, title, state, weight, locked) ";
+  db_query($insert . "VALUES('ogone_invalid', '". 'Payment invalid' ."', 'canceled', -22, 1);");
+  db_query($insert . "VALUES('ogone_declined', '". 'Payment declined' ."', 'canceled', -21, 1);");
+  db_query($insert . "VALUES('ogone_canceled', '". 'Payment canceled by Ogone' ."', 'canceled', -19, 1);");
+  db_query($insert . "VALUES('ogone_deleted', '". 'Payment deleted at Ogone' ."', 'canceled', -18, 1);");
+  db_query($insert . "VALUES('ogone_refund', '". 'Payment refund' ."', 'canceled', -17, 1);");
+  db_query($insert . "VALUES('ogone_auth_expired', '". 'Authorization expired' ."', 'canceled', -16, 1);");
+  db_query($insert . "VALUES('ogone_stored', '". 'Payment pending at Ogone' ."', 'post_checkout', 1, 1);");
+  db_query($insert . "VALUES('ogone_uncertain_auth', '". 'Authorization uncertain' ."', 'post_checkout', 2, 1);");
+  db_query($insert . "VALUES('ogone_uncertain_pay', '". 'Payment uncertain' ."', 'post_checkout', 3, 1);");
+  db_query($insert . "VALUES('ogone_uncertain_cap', '". 'Payment commit uncertain' ."', 'payment_received', 4, 1);");
+  db_query($insert . "VALUES('ogone_authorized', '". 'Payment authorized' ."', 'payment_received', 8, 1);");
+  db_query($insert . "VALUES('ogone_uncertain_cap', '". 'Payment commit uncertain' ."', 'payment_received', 9, 1);");
 }
+
+function uc_ogone_payment_update_1() {
+  drupal_uninstall_schema('uc_ogone_payment');
+  drupal_install_schema('uc_ogone_payment');
+  variable_del('ogone_currency');
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function uc_ogone_payment_uninstall() {
+  drupal_uninstall_schema('uc_ogone_payment');
+
+  /*
+  db_query("UPDATE {uc_order_statuses} SET locked = 0 WHERE order_status_id LIKE 'ogone_%'");
+  db_query("DELETE FROM {variable} WHERE name LIKE 'uc_ogone_payment_%'");
+  */
+
+}
\ No newline at end of file
