Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • areyouahuman
      • auth
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
        • default
      • exchange
        • rates
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • quickbooks
            • invoice
      • json
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • recaptcha
      • reports
        • aging
          • invoices
        • custom
          • report
        • invoice
          • creation
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • form
      • html
      • javascript
      • xml
    • lib
  • None
  • PHP

Classes

  • Accounts
  • ApiKeys
  • CalendarEvents
  • ClientGroups
  • Clients
  • Companies
  • Contacts
  • Countries
  • Coupons
  • CronTasks
  • Currencies
  • EmailGroups
  • Emails
  • Encryption
  • GatewayManager
  • Invoices
  • InvoiceTemplateManager
  • Languages
  • Logs
  • Marketplace
  • ModuleClientMeta
  • ModuleManager
  • Navigation
  • PackageGroups
  • PackageOptionGroups
  • PackageOptions
  • Packages
  • Payments
  • Permissions
  • PluginManager
  • Pricings
  • ReportManager
  • ServiceChanges
  • Services
  • Settings
  • Staff
  • StaffGroups
  • States
  • Taxes
  • Themes
  • Transactions
  • Users

Class Accounts

Accounts contain both ACH and Credit Card account information. Permits accounts to be fetched, added, edited, and deleted. Some accounts may require processing with remote gateways when added or edited. In such instances certain account details are not stored within the system, but only off-site on the remote gateway.

Model
Extended by AppModel
Extended by Accounts
Package: blesta\app\models
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at app/models/accounts.php

Methods summary

public
# __construct( )

Initialize Accounts

Initialize Accounts

Overrides

AppModel::__construct
public mixed
# getListAch( integer $contact_id, string $sortby = "last_name", string $order = "asc" )

Returns a list of all ACH accounts for a given contact

Returns a list of all ACH accounts for a given contact

Parameters

$contact_id
integer
$contact_id The contact to fetch on
$sortby
string
$sortby The field to sort on
$order
string
$order The order to sort (asc, desc)

Returns

mixed
An array of objects containing ACH fields or false if none exist
public mixed
# getListCc( integer $contact_id, string $sortby = "last_name", string $order = "asc" )

Returns a list of all CC accounts for a given contact

Returns a list of all CC accounts for a given contact

Parameters

$contact_id
integer
$contact_id The contact to fetch on
$sortby
string
$sortby The field to sort on
$order
string
$order The order to sort (asc, desc)

Returns

mixed
An array of objects containing CC fields or false if none exist
public mixed
# getAllCc( integer $contact_id )

Retrieves a list of all CC accounts for a given contact

Retrieves a list of all CC accounts for a given contact

Parameters

$contact_id
integer
$contact_id The contact to fetch on

Returns

mixed
An array of objects containing CC account records, or false if none exist
public array
# getAllCcByClient( integer $client_id )

Retrieves a list of all CC accounts for a given client

Retrieves a list of all CC accounts for a given client

Parameters

$client_id
integer
$client_id The client ID to fetch on

Returns

array
An array of objects containing CC account records
public mixed
# getAllAch( integer $contact_id )

Retrieves a list of all ACH accounts for a given contact

Retrieves a list of all ACH accounts for a given contact

Parameters

$contact_id
integer
$contact_id The contact to fetch on

Returns

mixed
An array of objects containing ACH account records, or false if none exist
public array
# getAllAchByClient( integer $client_id )

Retrieves a list of all ACH accounts for a given client

Retrieves a list of all ACH accounts for a given client

Parameters

$client_id
integer
$client_id The client ID to fetch on

Returns

array
An array of objects containing ACH account records
public mixed
# getCc( integer $account_id, boolean $decrypt = false, string $passphrase = null, integer $staff_id = null )

Retrieves a single CC account

Retrieves a single CC account

Parameters

$account_id
integer
$account_id The ID of the account to get
$decrypt
boolean
$decrypt Whether or not to decrypt the account number
$passphrase
string
$passphrase The passphrase required to decrypt accounts (if set)
$staff_id
integer
$staff_id The ID of the staff member decrypting the account

Returns

mixed
An object containing the CC account fields, or false if none exist
public mixed
# getAch( integer $account_id, boolean $decrypt = false, string $passphrase = null, integer $staff_id = null )

Retrieves a single ACH account

Retrieves a single ACH account

Parameters

$account_id
integer
$account_id The ID of the account to get
$decrypt
boolean
$decrypt Whether or not to decrypt the account number
$passphrase
string
$passphrase The passphrase required to decrypt accounts (if set)
$staff_id
integer
$staff_id The ID of the staff member decrypting the account

Returns

mixed
An object containing the ACH account fields, or false if none exist
public string
# getClientReferenceId( integer $client_id, integer $gateway_id )

Returns the client reference ID previously used for any payment accounts belonging to the client under the given gateway

Returns the client reference ID previously used for any payment accounts belonging to the client under the given gateway

Parameters

$client_id
integer
$client_id The ID of the client to fetch the client reference ID for
$gateway_id
integer
$gateway_id The ID of the gateway to that previous account was set up under

Returns

string
Returns the client reference ID if found, null otherwise
public integer
# addAch( array $vars )

Records an ACH account into the system

Records an ACH account into the system

Parameters

$vars
array
$vars An array of ACH account info including: - contact_id The contact ID tied to this account - first_name The first name on the account - last_name The last name on the account - address1 The address line 1 on the account (optional) - address2 The address line 2 on the account (optional) - city The city on the account (optional) - state The ISO 3166-2 subdivision code on the account (optional) - zip The zip code on the account (optional) - country The ISO 3166-1 2-character country code (optional, defaults to 'US') - account The account number (will be encrypted) (optional) - routing The routing number (will be encrypted) (optional) - last4 The last 4 digits of the account number (will be encrypted) (optional if account is given) - type The type of account, 'checking' or 'savings', (optional, defaults to 'checking') - reference_id The reference ID attached to this account given by the payment processor (optional) - client_reference_id The reference ID for the client this payment account belongs to (optional)

Returns

integer
The ACH account ID for the record just added, void if not added
public integer
# verifyAch( array & $vars )

Verifies ACH account details provided to ensure proper entry into the system

Verifies ACH account details provided to ensure proper entry into the system

Parameters

$vars
array
$vars An array of ACH account info including: - contact_id The contact ID tied to this account - first_name The first name on the account - last_name The last name on the account - address1 The address line 1 on the account (optional) - address2 The address line 2 on the account (optional) - city The city on the account (optional) - state The ISO 3166-2 subdivision code on the account (optional) - zip The zip code on the account (optional) - country The ISO 3166-1 2-character country code (optional, defaults to 'US') - account The account number (will be encrypted) (optional) - routing The routing number (will be encrypted) (optional) - last4 The last 4 digits of the account number (will be encrypted) (optional if account is given) - type The type of account, 'checking' or 'savings', (optional, defaults to 'checking') - reference_id The reference ID attached to this account given by the payment processor (optional) - client_reference_id The reference ID for the client this payment account belongs to (optional)

Returns

integer
The ACH account ID for the record just added, void if not added
public
# editAch( integer $account_id, array $vars )

Updates an ACH account in the system, all fields optional

Updates an ACH account in the system, all fields optional

Parameters

$account_id
integer
$account_id The account ID for this account
$vars
array
$vars An array of ACH account info including: - first_name The first name on the account - last_name The last name on the account - address1 The address line 1 on the account (optional) - address2 The address line 2 on the account (optional) - city The city on the account (optional) - state The ISO 3166-2 subdivision code on the account (optional) - zip The zip code on the account (optional) - country The ISO 3166-1 2-character country code (optional, defaults to 'US') - account The account number (will be encrypted) (optional) - routing The routing number (will be encrypted) (optional) - last4 The last 4 digits of the account number (will be encrypted) (optional if account is given) - type The type of account, 'checking' or 'savings', (optional, defaults to 'checking') - reference_id The reference ID attached to this account given by the payment processor (optional) - client_reference_id The reference ID for the client this payment account belongs to (optional)
public
# deleteAch( integer $account_id )

Removes an ACH account record using the given account ID. Attempts to remove the payment account from the remote gateway (if stored off-site). Deletes sensitive information and marks the record as inactive.

Removes an ACH account record using the given account ID. Attempts to remove the payment account from the remote gateway (if stored off-site). Deletes sensitive information and marks the record as inactive.

Parameters

$account_id
integer
$account_id The account ID for this ACH account
public integer
# addCc( array $vars )

Records a CC account into the system

Records a CC account into the system

Parameters

$vars
array
$vars An array of CC account info including: - contact_id The contact ID tied to this account - first_name The first name on the account - last_name The last name on the account - address1 The address line 1 on the account (optional) - address2 The address line 2 on the account (optional) - city The city on the account (optional) - state The ISO 3166-2 subdivision code on the account (optional) - zip The zip code on the account (optional) - country The ISO 3166-1 2-character country code (optional; required if state is given; defaults to 'US') - number The credit card number (will be encrypted) (optional) - expiration The expiration date in yyyymm format (will be encrypted) - security_code The 3 or 4-digit security code (optional, only used when storing payment account info off-site) - last4 The last 4 digits of the card number (will be encrypted) (optional if number is given) - type The card type (optional, will be determined automatically if not given) - reference_id The reference ID attached to this account given by the payment processor (optional) - client_reference_id The reference ID for the client this payment account belongs to (optional)

Returns

integer
The CC account ID for the record just added, void if not added
public integer
# verifyCc( array & $vars )

Verifies CC account info to ensure proper entry into the system

Verifies CC account info to ensure proper entry into the system

Parameters

$vars
array
$vars An array of CC account info including: - contact_id The contact ID tied to this account - first_name The first name on the account - last_name The last name on the account - address1 The address line 1 on the account (optional) - address2 The address line 2 on the account (optional) - city The city on the account (optional) - state The ISO 3166-2 subdivision code on the account (optional) - zip The zip code on the account (optional) - country The ISO 3166-1 2-character country code (optional; required if state is given; defaults to 'US') - number The credit card number (will be encrypted) (optional) - expiration The expiration date in yyyymm format (will be encrypted) - security_code The 3 or 4-digit security code (optional, only used when storing payment account info off-site) - last4 The last 4 digits of the card number (will be encrypted) (optional if number is given) - type The card type (optional, will be determined automatically if not given) - reference_id The reference ID attached to this account given by the payment processor (optional) - client_reference_id The reference ID for the client this payment account belongs to (optional)

Returns

integer
The CC account ID for the record just added, void if not added
public
# editCc( integer $account_id, array $vars )

Updates a CC account in the system, all fields optional

Updates a CC account in the system, all fields optional

Parameters

$account_id
integer
$account_id The account ID for this account
$vars
array
$vars An array of CC account info including: - first_name The first name on the account - last_name The last name on the account - address1 The address line 1 on the account (optional) - address2 The address line 2 on the account (optional) - city The city on the account (optional) - state The ISO 3166-2 subdivision code on the account (optional) - zip The zip code on the account (optional) - country The ISO 3166-1 2-character country code (optional; required if state is given; defaults to 'US') - number The credit card number (will be encrypted) (optional) - expiration The expiration date in yyyymm format (will be encrypted) (optional) - last4 The last 4 digits of the card number (will be encrypted) (optional if number is given) - type The card type (optional, will be determined automatically if not given) - reference_id The reference ID attached to this account given by the payment processor (optional) - client_reference_id The reference ID for the client this payment account belongs to (optional)
public
# deleteCc( integer $account_id )

Removes a CC account record using the givent account ID. Attempts to remove the payment account from the remote gateway (if stored off-site). Deletes sensitive information and marks the record as inactive.

Removes a CC account record using the givent account ID. Attempts to remove the payment account from the remote gateway (if stored off-site). Deletes sensitive information and marks the record as inactive.

Parameters

$account_id
integer
$account_id The account ID for this ACH account
public array
# getCardsExpireSoon( string $date )

Returns the accounts for all active clients with credit card payment accounts set to expire in the month given by $date

Returns the accounts for all active clients with credit card payment accounts set to expire in the month given by $date

Parameters

$date
string
$date The date to fetch card expirations for, will be converted to Ym format (e.g. 201003 = March, 2010)

Returns

array
An array of stdClass objects representing the accounts whose cards expire in the month given
public array
# getTypes( )

Returns a list of account types

Returns a list of account types

Returns

array
Key=>value pairs of account types
public array
# getAchTypes( )

Returns a list of credit card account types

Returns a list of credit card account types

Returns

array
Key=>value pairs of CC account types
public array
# getCcTypes( )

Returns a list of credit card account types

Returns a list of credit card account types

Returns

array
Key=>value pairs of CC account types
public string
# formatNumber( string $value )

Formats a given string into an integer string

Formats a given string into an integer string

Parameters

$value
string
$value The value to format

Returns

string
The formatted $value with all non-integer characters removed
public boolean
# validateAchType( string $type )

Validates the ACH 'type' field

Validates the ACH 'type' field

Parameters

$type
string
$type The ACH type

Returns

boolean
True if validated, false otherwise
public boolean
# validateCcType( string $type )

Validates the CC 'type' field

Validates the CC 'type' field

Parameters

$type
string
$type The CC type

Returns

boolean
True if validated, false otherwise
public string
# creditCardType( string $card_number )

Returns the card type based on the given card number (card numbers are ISO 7812 numbers)

Returns the card type based on the given card number (card numbers are ISO 7812 numbers)

Parameters

$card_number
string
$card_number The card number to evaluate

Returns

string
The card type detected, null if the card is invalid or is otherwise not recognized. Values include: 'amex' - American Express, 'bc' - Bankcard, 'cup' - China Union Pay, 'dc-cb' - Diners Club Carte Blanche, 'dc-er' - Diners Club EnRoute, 'dc-int' - Diners Club International, 'dc-uc' - Diners Club US and Canada, 'disc' - Discover, 'ipi' - InstaPayment, 'jcb' - Japan Credit Bureau, 'lasr' - Laser, 'maes' - Maestro, 'mc' - Master Card, 'solo' - Solo, 'switch' - Switch, 'visa' - Visa
public boolean
# luhnValid( string $card_number )

Performs the Luhn Algorithm on the given card number to verify that the card is valid.

Performs the Luhn Algorithm on the given card number to verify that the card is valid.

Parameters

$card_number
string
$card_number The card number to validate

Returns

boolean
Returns true if the card was successfully validated against the Luhn algorithm (e.g. is valid), false otherwise

Methods inherited from AppModel

_(), boolToInt(), currencyToDecimal(), dateToUtc(), errors(), getPerPage(), ifSet(), loadCrypto(), setDefaultIfEmpty(), setPerPage(), setRulesIfSet(), strToBool(), systemDecrypt(), systemEncrypt(), systemHash(), truncateDecimal(), validateExists(), validateStateCountry()

Methods inherited from Model

affectedRows(), begin(), commit(), getConnection(), lastInsertId(), makeDSN(), prepare(), query(), rollBack(), setAttribute(), setFetchMode()

Magic methods summary

Properties summary

Properties inherited from AppModel

$replacement_keys

Blesta API documentation generated by ApiGen 2.8.0