Methods summary
public
|
#
__construct( )
Initialize Transactions
Overrides
|
public
integer
|
#
add( array $vars )
Adds a transaction to the system
Adds a transaction to the system
Parameters
- $vars
An array of tax info including:
- client_id The client ID this transaction applies to.
- amount The transaction amount
- currency The currency code of this transaction
- type The transaction type (cc, ach, other)
- transaction_type_id The transaction type ID (optional, default NULL)
- account_id The account ID (optional, default NULL)
- gateway_id The gateway ID (optional, default NULL)
- transaction_id The gateway supplied transaction ID (optional, default NULL)
- parent_transaction_id The gateway supplied parent transaction ID (optional, default null)
- reference_id The gateway supplied reference ID (optional, default NULL)
- status The transaction status (optional, default 'approved')
- date_added The date the transaction was received (optional, defaults to current date)
Returns
integer The ID of the transaction created, void on error
|
public
integer
|
#
edit( integer $transaction_id, array $vars, integer $staff_id = null )
Updates a transaction
Parameters
- $transaction_id
- The transaction ID
- $vars
An array of tax info including:
- amount The transaction amount (optional)
- currency The currency code of this transaction (optional)
- type The transaction type (cc, ach, other) (optional)
- transaction_type_id The transaction type ID (optional, default NULL)
- account_id The account ID (optional, default NULL)
- gateway_id The gateway ID (optional, default NULL)
- transaction_id The gateway supplied transaction ID (optional, default NULL)
- parent_transaction_id The gateway supplied parent transaction ID (optional, default null)
- reference_id The reference ID (optional, default NULL)
- status The transaction status (optional, default 'approved')
- date_added The date the transaction was received (optional, defaults to current date)
- $staff_id
- The ID of the staff member that made the edit for logging purposes
Returns
integer The ID of the transaction created, void on error
|
public
|
#
delete( integer $transaction_id )
Permanently removes a transaction from the system
Permanently removes a transaction from the system
Parameters
- $transaction_id
- The transaction ID to remove
|
public
mixed
|
#
get( integer $transaction_id )
Retrieves a transaction and any applied amounts
Retrieves a transaction and any applied amounts
Parameters
- $transaction_id
The ID of the transaction to fetch (that is,
transactions.id NOT transactions.transaction_id)
Returns
mixed A stdClass object representing the transaction, false if it does not exist
See
|
public
mixed
|
#
getByTransactionId( integer $transaction_id, integer $client_id = null, integer $gateway_id = null )
Retrieves a transaction and any applied amounts
Retrieves a transaction and any applied amounts
Parameters
- $transaction_id
The ID of the transaction to fetch (that is,
transactions.transaction_id NOT transactions.id)
- $client_id
- The ID of the client to fetch a transaction for
- $gateway_id
- The ID of the gateway used to process the transaction
Returns
mixed A stdClass object representing the transaction, false if it does not exist
See
|
public
array
|
#
getSimpleList( integer $client_id = null, integer $page = 1 )
Retrieves a list of all transactions in the system
Retrieves a list of all transactions in the system
Parameters
- $client_id
- The ID of the client whose transactions to retrieve (optional)
- $page
- The page to return results for (optional, default 1)
Returns
array An array of stdClass objects representing each transaction
|
public
array
|
#
getList( integer $client_id = null, string $status = 'approved', integer $page = 1, array $order_by = ['date_added' => 'DESC'], array $filters = [] )
Retrieves a list of transactions and any applied amounts for the given client
Retrieves a list of transactions and any applied amounts for the given client
Parameters
- $client_id
- The client ID (optional, default null to get transactions for all clients)
- $status
The status type of the transactions to fetch
(optional, default 'approved') - 'approved', 'declined', 'void', 'error', 'pending', 'returned',
or 'all' for all statuses
- $page
- The page to return results for
- $order_by
- The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)
- $filters
A list of parameters to filter by, including:
- payment_type The payment type on which to filter transactions
- transaction_id The (partial) transaction number on which to filter transactions
- reference_id The (partial) transaction reference on which to filter transactions
- applied_status The applied status on which to filter transactions
- start_date Get the transactions from this start date
- end_date Get the transactions to this end date
- start_amount Get the transactions from this start amount
- end_amount Get the transactions to this end amount
Returns
array An array of stdClass objects representing transactions, or false if none exist
|
public
integer
|
#
getListCount( integer $client_id = null, string $status = 'approved', array $filters = [] )
Returns the total number of transactions for a client, useful
in constructing pagination for the getList() method.
Returns the total number of transactions for a client, useful
in constructing pagination for the getList() method.
Parameters
- $client_id
- The client ID (optional, default null to get transactions for all clients)
- $status
The status type of the transactions to fetch
(optional, default 'approved') - 'approved', 'declined', 'void', 'error', 'pending', 'returned',
or 'all' for all statuses
- $filters
A list of parameters to filter by, including:
- payment_type The payment type on which to filter transactions
- transaction_id The (partial) transaction number on which to filter transactions
- reference_id The (partial) transaction reference on which to filter transactions
- applied_status The applied status on which to filter transactions
- start_date Get the transactions from this start date
- end_date Get the transactions to this end date
- start_amount Get the transactions from this start amount
- end_amount Get the transactions to this end amount
Returns
integer The total number of transactions
See
|
public
array
|
#
search( string $query, integer $page = 1 )
Search transactions
Parameters
- $query
- The value to search transactions for
- $page
- The page number of results to fetch (optional, default 1)
Returns
array An array of transactions that match the search criteria
|
public
|
#
getSearchCount( string $query )
Return the total number of transactions returned from Transactions::search(), useful
in constructing pagination
Return the total number of transactions returned from Transactions::search(), useful
in constructing pagination
Parameters
- $query
- The value to search transactions for
See
|
public
array
|
#
getApplied( integer $transaction_id = null, integer $invoice_id = null )
Returns all invoices that have been applied to this transaction. Must supply
either a transaction ID, invoice ID or both.
Returns all invoices that have been applied to this transaction. Must supply
either a transaction ID, invoice ID or both.
Parameters
- $transaction_id
- The ID of the transaction to fetch
- $invoice_id
- The ID of the invoice to filter applied amounts on
Returns
array An array of stdClass objects representing applied amounts to invoices
|
public
float
|
#
getCreditedAmount( integer $transaction_id )
Returns the amount of payment for the given transaction ID that is currently
available as a credit
Returns the amount of payment for the given transaction ID that is currently
available as a credit
Parameters
- $transaction_id
- The ID of the transaction to fetch a credit value for
Returns
float The amount of the transaction that is currently available as a credit
|
public
array
|
#
getCredits( integer $client_id, string $currency = null )
Returns the amount of payment for the given client ID that is currently
available as a credit for each currency
Returns the amount of payment for the given client ID that is currently
available as a credit for each currency
Parameters
- $client_id
- The ID of the client to fetch a credit value for
- $currency
- The ISO 4217 3-character currency code (optional)
Returns
array A list of credits by currency containing:
- transaction_id The transaction ID that the credit belongs to
- credit The total credit for this transaction
|
public
float
|
#
getTotalCredit( integer $client_id, string $currency )
Retrieves the total credit amount available to the client in the given currency
Retrieves the total credit amount available to the client in the given currency
Parameters
- $client_id
- The ID of the client to fetch a credit value for
- $currency
- The ISO 4217 3-character currency code
Returns
float The total credit available to the client in the given currency
|
public
integer
|
#
getStatusCount( integer $client_id = null, string $status = 'approved', array $filters = [] )
Retrieves the number of transactions given a transaction status type for the given client
Retrieves the number of transactions given a transaction status type for the given client
Parameters
- $client_id
- The client ID (optional, default null to get transactions for all clients)
- $status
- The transaction status type (optional, default 'approved') - 'all' for all statuses
- $filters
A list of parameters to filter by, including:
- payment_type The payment type on which to filter transactions
- transaction_id The (partial) transaction number on which to filter transactions
- reference_id The (partial) transaction reference on which to filter transactions
- applied_status The applied status on which to filter transactions
- start_date Get the transactions from this start date
- end_date Get the transactions to this end date
- start_amount Get the transactions from this start amount
- end_amount Get the transactions to this end amount
Returns
integer The number of transactions of type $status for $client_id
|
public
|
#
apply( integer $transaction_id, array $vars )
Applies a transaction to a list of invoices. Each invoice must be in the transaction's currency to be applied
Applies a transaction to a list of invoices. Each invoice must be in the transaction's currency to be applied
Parameters
- $transaction_id
- The transaction ID
- $vars
An array of transaction info including:
- date The date in local time (Y-m-d H:i:s format) the transaction
was applied (optional, default to current date/time)
- amounts A numerically indexed array of amounts to apply including:
- invoice_id The invoice ID
- amount The amount to apply to this invoice (optional, default 0.00)
|
public
mixed
|
#
applyFromCredits( integer $client_id, string $currency = null, array $amounts = [] )
Applies available client credits in the given currency to all open invoices, starting from the oldest.
If specific amounts are specified, credits will only be applied to the invoices given.
Applies available client credits in the given currency to all open invoices, starting from the oldest.
If specific amounts are specified, credits will only be applied to the invoices given.
Parameters
- $client_id
- The ID of the client whose invoices to apply from credits
- $currency
The ISO 4217 3-character currency code. Must be
set if $amounts are specified (optional, null will apply from all currencies; default null)
- $amounts
A numerically-indexed array of specific amounts to apply to given invoices:
- invoice_id The invoice ID
- amount The amount to apply to this invoice (optional, default 0.00)
Returns
mixed Void, or an array indexed by a credit's transaction ID,
containing the amounts that were actually applied, including:
- invoice_id The invoice ID
- amount The amount that was applied to this invoice
|
public
boolean
|
#
verifyApply( array & $vars, boolean $validate_trans_id = true, float $total = null )
Verifies that transaction can be applied to a list of invoices
Verifies that transaction can be applied to a list of invoices
Parameters
- $vars
An array of transaction info including:
- transaction_id The transaction ID (only evaluated if $validate_trans_id is true)
- date The date in UTC time (Y-m-d H:i:s format) the transaction was
applied (optional, default to current date/time)
- amounts A numerically indexed array of amounts to apply including:
- invoice_id The invoice ID
- amount The amount to apply to this invoice (optional, default 0.00)
- $validate_trans_id
- True to validate the transaction ID in $vars, false otherwise
- $total
The total amount of the transaction used to ensure
that the sum of the apply amounts does not exceed the total transaction
amount. Only used if $validate_trans_id is false (optional)
Returns
boolean True if the transaction can be applied, false otherwise (sets Input errors on failure)
|
public
|
#
unApply( integer $transaction_id, array $invoices = null )
Unapplies a transactions from one or more invoices.
Unapplies a transactions from one or more invoices.
Parameters
- $transaction_id
- The ID of the transaction to unapply
- $invoices
A numerically indexed array of invoice IDs to
unapply this transaction from, or null to unapply this transaction from any and all invoices
|
public
mixed
|
#
getTypes( )
Retrieves a list of all transaction types
Retrieves a list of all transaction types
Returns
mixed An array of stdClass objects representing transaction types, or false if none exist
|
public
mixed
|
#
getType( integer $type_id )
Retrieves a single payment type
Retrieves a single payment type
Parameters
- $type_id
- The payment type ID
Returns
mixed An array of stdClass objects representing a payment type, or false if one does not exist
|
public
array
|
#
getDebitTypes( )
Retrieves a set of key/value pairs representing transaction debit types and language
Retrieves a set of key/value pairs representing transaction debit types and language
Returns
array An array of key/value pairs representing transaction debit types and their names
|
public
array
|
#
transactionTypeNames( )
Retrieves all transaction types and their name in key=>value pairs
Retrieves all transaction types and their name in key=>value pairs
Returns
array An array of key=>value pairs representing transaction types and their names
|
public
array
|
#
transactionStatusNames( )
Retrieves all transaction status values and their name in key/value pairs
Retrieves all transaction status values and their name in key/value pairs
Returns
array An array of key/value pairs representing transaction status values
|
public
integer
|
#
addType( array $vars )
Adds a transaction type
Parameters
- $vars
An array of transaction types including:
- name The transaction type name
- type The transaction debit type ('debit' or 'credit')
- is_lang Whether or not the 'name' parameter is a language definition 1 - yes, 0 - no (optional, default 0)
Returns
integer The transaction type ID created, or void on error
|
public
|
#
editType( integer $type_id, array $vars )
Updates a transaction type
Updates a transaction type
Parameters
- $type_id
- The type ID to update
- $vars
An array of transaction types including:
- name The transaction type name
- type The transaction debit type ('debit' or 'credit')
- is_lang Whether or not the 'name' parameter is a language definition 1 - yes, 0 - no (optional, default 0)
|
public
|
#
deleteType( integer $type_id )
Delete a transaction type and update all affected transactions, setting their type to null
Delete a transaction type and update all affected transactions, setting their type to null
Parameters
- $type_id
- The ID for this transaction type
|
public
boolean
|
#
validateType( string $type )
Validates a transaction's 'type' field
Validates a transaction's 'type' field
Parameters
Returns
boolean True if the type is validated, false otherwise
|
public
boolean
|
#
validateStatus( string $status )
Validates a transaction's 'status' field
Validates a transaction's 'status' field
Parameters
- $status
- The status to check
Returns
boolean True if the status is validated, false otherwise
|
public
boolean
|
#
validateApplyAmounts( array $amounts, float $total = null )
Validates whether the given amounts can be applied to the given invoices, or if the amounts
would exceed the amount due on the invoices. Also ensures the invoices can have amounts applied to them.
Validates whether the given amounts can be applied to the given invoices, or if the amounts
would exceed the amount due on the invoices. Also ensures the invoices can have amounts applied to them.
Parameters
- $amounts
An array of apply amounts including:
- invoice_id The invoice ID
- amount The amount to apply to this invoice (optional, default 0.00)
- $total
The total amount of the transaction used to ensure
that the sum of the apply amounts does not exceed the total transaction amount
Returns
boolean True if the amounts given can can be applied to the
invoices given, false if it exceeds the amount due or the invoice can not receive payments
|
public
boolean
|
#
validateCurrencyAmounts( integer $transaction_id, array $amounts )
Validates whether the invoice amounts being applied are in the transaction's currency
Validates whether the invoice amounts being applied are in the transaction's currency
Parameters
- $transaction_id
- The ID of the transaction
- $amounts
An array of apply amounts including:
- invoice_id The invoice ID
- amount The amount to apply to this invoice (optional)
Returns
boolean True if each invoice is in the transaction's currency, or false otherwise
|
public
boolean
|
#
validatePositiveAmounts( array $amounts )
Validates whether each of the given amounts is greater than or equal to zero
Validates whether each of the given amounts is greater than or equal to zero
Parameters
- $amounts
An array of apply amounts including:
- invoice_id The invoice ID
- amount The amount to apply to this invoice (optional, default 0.00)
Returns
boolean True if all amounts are greater than or equal to zero, false otherwise
|