Overview

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • auth
        • ldap
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
      • exchange
        • rates
          • currency
            • layer
          • fixer
          • open
            • exchange
              • rates
          • x
            • rates
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • perforated
            • invoice
          • quickbooks
            • invoice
          • templates
            • default
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • reports
        • aging
          • invoices
        • client
          • data
            • portability
        • custom
          • report
        • invoice
          • creation
        • package
          • revenue
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • core
      • Automation
        • Tasks
          • Common
          • Task
        • Type
          • Common
          • Cron
      • Pricing
        • ItemComparator
        • MetaItem
        • Modifier
          • Type
            • Description
              • Type
                • Discount
                • Option
                • Service
                • Tax
            • Discount
            • Price
            • Proration
        • Presenter
          • Build
            • Invoice
            • InvoiceData
            • Options
            • Service
            • ServiceChange
            • ServiceData
          • Collection
          • Format
            • Fields
            • Type
              • Discount
              • Item
              • Option
              • Options
              • Package
              • Pricing
              • Service
              • Tax
          • Items
            • Invoice
            • Service
          • Type
      • ServiceProviders
      • Util
        • Captcha
          • Captchas
          • Common
        • Common
          • Traits
        • Events
          • Common
          • Handlers
          • Observers
        • Filters
          • Common
        • GeoIp
        • Input
          • Fields
            • Common
        • Tax
        • Widgets
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • helpers
      • color
      • data
        • structure
  • None
  • PHP

Classes

  • Accounts
  • Actions
  • ApiKeys
  • Backup
  • CalendarEvents
  • ClientGroups
  • Clients
  • Companies
  • Contacts
  • Countries
  • Coupons
  • CouponTerms
  • CronTasks
  • Currencies
  • EmailGroups
  • Emails
  • EmailVerifications
  • Encryption
  • GatewayManager
  • Invoices
  • InvoiceTemplateManager
  • Languages
  • Logs
  • Marketplace
  • MessageGroups
  • Messages
  • MessengerManager
  • ModuleClientMeta
  • ModuleManager
  • ModuleTypes
  • Navigation
  • PackageGroups
  • PackageOptionGroups
  • PackageOptions
  • Packages
  • Payments
  • Permissions
  • PluginManager
  • Pricings
  • ReportManager
  • ServiceChanges
  • ServiceInvoices
  • Services
  • Settings
  • Staff
  • StaffGroups
  • States
  • SystemEvents
  • Taxes
  • Themes
  • Transactions
  • Users
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated

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 uses Blesta\Core\Util\Common\Traits\Container
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
The contact to fetch on
$sortby
The field to sort on
$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
The contact to fetch on
$sortby
The field to sort on
$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
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
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
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
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
The ID of the account to get
$decrypt
Whether or not to decrypt the account number
$passphrase
The passphrase required to decrypt accounts (if set)
$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
The ID of the account to get
$decrypt
Whether or not to decrypt the account number
$passphrase
The passphrase required to decrypt accounts (if set)
$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, string $status = null, string $type = null )

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
The ID of the client to fetch the client reference ID for
$gateway_id
The ID of the gateway to that previous account was set up under
$status
The payment account status by which to filter (optional) (active or inactive)
$type
The payment account type by which to filter (optional) (cc or ach)

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

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

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
The account ID for this account
$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, boolean $soft_delete = true )

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
The account ID for this ACH account
$soft_delete

True to perform a soft delete, or false to permanently delete the record (optional, default true)

public integer
# addCc( array $vars )

Records a CC account into the system

Records a CC account into the system

Parameters

$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, boolean $require_fields = true )

Verifies CC account info to ensure proper entry into the system

Verifies CC account info to ensure proper entry into the system

Parameters

$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)
$require_fields
Whether to require that the cc fields be set to pass validation

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
The account ID for this account
$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, boolean $soft_delete = true )

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
The account ID for this ACH account
$soft_delete

True to perform a soft delete, or false to permanently delete the record (optional, default true)

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

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
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
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
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
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
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 used from Blesta\Core\Util\Common\Traits\Container
getFromContainer()
Properties inherited from AppModel
$logger, $replacement_keys
Blesta API documentation generated by ApiGen