function pay_transaction::update_status in Pay 7
Same name and namespace in other branches
- 6 includes/handlers/pay_transaction.inc \pay_transaction::update_status()
File
- includes/
handlers/ pay_transaction.inc, line 266 - 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 = REQUEST_TIME;
}
$this->total_paid = db_query("SELECT SUM(transaction_total)\n FROM {pay_activity} WHERE pxid = :pxid", array(
':pxid' => $this->pxid,
))
->fetchField();
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();
}