class pay_activity in Pay 6
Same name and namespace in other branches
- 7 includes/handlers/pay_activity.inc \pay_activity
@file A base class for payment activities.
Hierarchy
- class \pay
- class \pay_activity
Expanded class hierarchy of pay_activity
4 string references to 'pay_activity'
- pay_activity_load in ./
pay.module - API Function: Load a payment activity object.
- pay_load in ./
pay.module - API Function: Load a payment class.
- pay_transaction::activity in includes/
handlers/ pay_transaction.inc - pay_update_6005 in ./
pay.install - Rename 'activity' to 'action' in pay_activity table.
File
- includes/
handlers/ pay_activity.inc, line 8 - A base class for payment activities.
View source
class pay_activity extends pay {
var $paid;
var $pxid;
var $pmid;
var $uid;
var $result;
var $action;
var $payment_type;
var $total;
var $transaction_total;
var $timestamp;
var $hostname;
var $data = array();
var $identifier;
var $table = 'pay_activity';
var $key = 'paid';
function set_pay_method($pay_method) {
$this->pay_method = $pay_method;
$this->pmid = $pay_method->pmid;
$this->payment_type = $this
->pay_method()->payment_type;
}
function set_transaction($transaction) {
$this->pay_transaction = $transaction;
$this->pxid = $transaction->pxid;
}
function set_action($action) {
$this->action = check_plain($action);
}
function set_transaction_total($val = 0) {
$this->transaction_total = (double) $val;
}
/**
* Set the $data value, which is stored as a serialized value in the database.
*/
function set_data($value = NULL) {
if (!empty($value) && is_scalar($value)) {
$this->data = unserialize($value);
}
else {
$this->data = $value;
}
}
function currency() {
return $this
->pay_transaction()
->currency();
}
/**
* Effect a payment action using the currently-selected payment method.
*
* The action must be defined in valid_actions() and the that action's
* callback must exist for this payment method. Empty actions use a pseudo-
* action of 'pending'.
*/
function do_activity($action = NULL, $values = array()) {
// No action defined: Ensure that this transaction gets logged as 'pending'
if (!$action || $action == 'pending') {
$action = 'pending';
$func = 'pending_action';
}
else {
$info = $this
->pay_transaction()
->valid_actions($action);
$func = $info['callback'];
}
$this
->set_action($action);
// If the payment method has a function to handle this action, call it!
if (method_exists($this
->pay_method(), $func)) {
$this
->pay_method()->activity = $this;
$state = $this
->pay_method()
->{$func}($values);
}
// Save any new/changed data for this activity.
$this
->save();
// Update this activity's transaction.
$this
->pay_transaction()
->update_status($state, $this->timestamp);
// Return boolean result.
return $this->result;
}
/**
* The transaction balance as of this payment's completion.
*/
function balance() {
return (double) db_result(db_query("SELECT t.total - SUM(a.transaction_total)\n FROM {pay_activity} a\n INNER JOIN {pay_transaction} t USING (pxid)\n WHERE t.pxid = %d AND a.paid <= %d", $this->pxid, $this->paid));
}
/**
* Return the payment method related to this activity.
*/
function pay_method() {
if (!isset($this->pay_method)) {
$this->pay_method = pay_method_load($this->pmid);
}
return $this->pay_method;
}
/**
* Return the transaction related to this activity.
*/
function pay_transaction() {
if (!isset($this->pay_transaction)) {
$this->pay_transaction = pay_transaction_load($this->pxid);
}
return $this->pay_transaction;
}
/**
* Return a history of all payment activities related to this activity.
* This is any activity for the current transaction that's using the same
* payment method.
*/
function history() {
if (!isset($this->history)) {
$history = $this
->pay_transaction()
->pay_method_activities($this->pmid);
$this->history = is_array($history) ? $history : array();
}
return $this->history;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
pay:: |
property | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | Execute an named Drupal hook function, passing $this as the first parameter. | ||
pay:: |
function | |||
pay:: |
function | 3 | ||
pay:: |
function | |||
pay:: |
function | 2 | ||
pay:: |
function | 1 | ||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | 1 | ||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | 2 | ||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | Do not allow this value to be automatically set. | ||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | Do not allow this value to be automatically set. | ||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | 2 | ||
pay:: |
function | 1 | ||
pay:: |
function | |||
pay:: |
function | |||
pay:: |
function | |||
pay_activity:: |
property | |||
pay_activity:: |
property | |||
pay_activity:: |
property | |||
pay_activity:: |
property | |||
pay_activity:: |
property |
Overrides pay:: |
||
pay_activity:: |
property | |||
pay_activity:: |
property | |||
pay_activity:: |
property | |||
pay_activity:: |
property | |||
pay_activity:: |
property | |||
pay_activity:: |
property |
Overrides pay:: |
||
pay_activity:: |
property | |||
pay_activity:: |
property | |||
pay_activity:: |
property | |||
pay_activity:: |
property | |||
pay_activity:: |
function | The transaction balance as of this payment's completion. | ||
pay_activity:: |
function | |||
pay_activity:: |
function | Effect a payment action using the currently-selected payment method. | ||
pay_activity:: |
function | Return a history of all payment activities related to this activity. This is any activity for the current transaction that's using the same payment method. | ||
pay_activity:: |
function | Return the payment method related to this activity. | ||
pay_activity:: |
function |
Return the transaction related to this activity. Overrides pay:: |
||
pay_activity:: |
function | |||
pay_activity:: |
function | Set the $data value, which is stored as a serialized value in the database. | ||
pay_activity:: |
function | |||
pay_activity:: |
function | |||
pay_activity:: |
function |