function pay_update_6004 in Pay 6
Same name and namespace in other branches
- 7 pay.install \pay_update_6004()
Add a "state" column to the pay_transaction table.
File
- ./
pay.install, line 347 - Pay module allows for accepting payments against a node using pluggable payment backends.
Code
function pay_update_6004() {
$ret = array();
$spec = array(
'type' => 'varchar',
'length' => 20,
'not null' => TRUE,
'default' => 'pending',
);
db_add_field($ret, 'pay_transaction', 'state', $spec);
// Set some default values for existing transactions.
// Complete if total == total_paid.
$ret[] = update_sql("UPDATE {pay_transaction}\n SET state = 'complete' WHERE total = total_paid");
// Making a hefty assumption that it's canceled if total_paid = 0.
$ret[] = update_sql("UPDATE {pay_transaction}\n SET state = 'canceled' WHERE total > 0 AND total_paid = 0");
// Setting everything else, AKA partial-payments, to 'active' / in progress.
$ret[] = update_sql("UPDATE {pay_transaction}\n SET state = 'active' WHERE total > 0 AND total_paid > 0 AND total != total_paid");
// Special case - successful transactions (e.g. from CIM) on $0 transactions.
$ret[] = update_sql("UPDATE {pay_transaction} t, {pay_activity} a\n SET state = 'pending'\n WHERE t.pxid = a.pxid AND t.state = 'canceled' AND a.result = '1'");
return $ret;
}