function pay_transaction::update_status in Pay 6
Same name and namespace in other branches
- 7 includes/handlers/pay_transaction.inc \pay_transaction::update_status()
File
- includes/
handlers/ pay_transaction.inc, line 237 - A base class for payment transactions.
Class
- pay_transaction
- @file A base class for payment transactions.
Code
function update_status($state = NULL, $timestamp = NULL) {
if (!$timestamp) {
$timestamp = time();
}
$this->total_paid = db_result(db_query("SELECT SUM(transaction_total)\n FROM {pay_activity} WHERE pxid = %d", $this->pxid));
if ($state == 'complete') {
// Payment has in fact been completed.
if ($this->total == $this->total_paid) {
$this
->set_completed($timestamp);
$this
->drupal_invoke('pay_transaction_complete');
}
else {
$state = 'active';
}
}
// Set the new transaction state if it has changed and is valid.
if ($state != $this
->state() && array_key_exists($state, $this
->states())) {
$this
->set_state($state);
}
$this
->save();
}