Blesta Source Documentation

Accounts extends AppModel

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.

Table of Contents

Methods

__construct() Initialize Accounts
addAch() Records an ACH account into the system
addCc() Records a CC account into the system
creditCardType() Returns the card type based on the given card number (card numbers are ISO 7812 numbers)
deleteAch() 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.
deleteCc() 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.
editAch() Updates an ACH account in the system, all fields optional
editCc() Updates a CC account in the system, all fields optional
formatNumber() Formats a given string into an integer string
getAch() Retrieves a single ACH account
getAchTypes() Returns a list of credit card account types
getAllAch() Retrieves a list of all ACH accounts for a given contact
getAllAchByClient() Retrieves a list of all ACH accounts for a given client
getAllCc() Retrieves a list of all CC accounts for a given contact
getAllCcByClient() Retrieves a list of all CC accounts for a given client
getCardsExpireSoon() Returns the accounts for all active clients with credit card payment accounts set to expire in the month given by $date
getCc() Retrieves a single CC account
getCcTypes() Returns a list of credit card account types
getClientReferenceId() Returns the client reference ID previously used for any payment accounts belonging to the client under the given gateway
getListAch() Returns a list of all ACH accounts for a given contact
getListCc() Returns a list of all CC accounts for a given contact
getTypes() Returns a list of account types
luhnValid() Performs the Luhn Algorithm on the given card number to verify that the card is valid.
validateAchType() Validates the ACH 'type' field
validateCcType() Validates the CC 'type' field
verifyAch() Verifies ACH account details provided to ensure proper entry into the system
verifyAchDeposits() Verifies an ACH account with the gateway
verifyCc() Verifies CC account info to ensure proper entry into the system
accountDecrypt() Performs an asymetric decryption on the given data for the current company using RSA.
accountEncrypt() Performs an asymetric encryption on the given data for the current company using RSA.
addDebitAccount() Adds the given account as the client's debit account if none are currently set.
getAddAchRules() Returns the partial rule set for adding/editing ACH records
getAddCcRules() Returns the partial rule set for adding/editing CC records
getRules() Returns the partial rule set common between ACH/CC records for adding/editing ACH/CC records
Methods

__construct()

Initialize Accounts

public __construct() : mixed

addAch()

Records an ACH account into the system

public addAch(array<string|int, mixed> $vars) : int
Parameters
$vars : array<string|int, mixed>

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)
  • currency The currency in which is denominated the account (optional)
Return values
int

The ACH account ID for the record just added, void if not added

addCc()

Records a CC account into the system

public addCc(array<string|int, mixed> $vars) : int
Parameters
$vars : array<string|int, mixed>

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)
  • currency The currency in which is denominated the account (optional)
Return values
int

The CC account ID for the record just added, void if not added

creditCardType()

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

public creditCardType(string $card_number) : string
Parameters
$card_number : string

The card number to evaluate

Return values
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

deleteAch()

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.

public deleteAch(int $account_id[, bool $soft_delete = true ]) : mixed
Parameters
$account_id : int

The account ID for this ACH account

$soft_delete : bool = true

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

deleteCc()

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.

public deleteCc(int $account_id[, bool $soft_delete = true ]) : mixed
Parameters
$account_id : int

The account ID for this ACH account

$soft_delete : bool = true

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

editAch()

Updates an ACH account in the system, all fields optional

public editAch(int $account_id, array<string|int, mixed> $vars) : mixed
Parameters
$account_id : int

The account ID for this account

$vars : array<string|int, mixed>

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)
  • currency The currency in which is denominated the account (optional)

editCc()

Updates a CC account in the system, all fields optional

public editCc(int $account_id, array<string|int, mixed> $vars) : mixed
Parameters
$account_id : int

The account ID for this account

$vars : array<string|int, mixed>

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)
  • currency The currency in which is denominated the account (optional)

formatNumber()

Formats a given string into an integer string

public formatNumber(string $value) : string
Parameters
$value : string

The value to format

Return values
string

The formatted $value with all non-integer characters removed

getAch()

Retrieves a single ACH account

public getAch(int $account_id[, bool $decrypt = false ][, string $passphrase = null ][, int $staff_id = null ]) : mixed
Parameters
$account_id : int

The ID of the account to get

$decrypt : bool = false

Whether or not to decrypt the account number

$passphrase : string = null

The passphrase required to decrypt accounts (if set)

$staff_id : int = null

The ID of the staff member decrypting the account

Return values
mixed

An object containing the ACH account fields, or false if none exist

getAchTypes()

Returns a list of credit card account types

public getAchTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

Key=>value pairs of CC account types

getAllAch()

Retrieves a list of all ACH accounts for a given contact

public getAllAch(int $contact_id[, bool $unverified = false ]) : mixed
Parameters
$contact_id : int

The contact to fetch on

$unverified : bool = false

True to include unverified accounts

Return values
mixed

An array of objects containing ACH account records, or false if none exist

getAllAchByClient()

Retrieves a list of all ACH accounts for a given client

public getAllAchByClient(int $client_id[, bool $unverified = false ]) : array<string|int, mixed>
Parameters
$client_id : int

The client ID to fetch on

$unverified : bool = false

True to include unverified accounts

Return values
array<string|int, mixed>

An array of objects containing ACH account records

getAllCc()

Retrieves a list of all CC accounts for a given contact

public getAllCc(int $contact_id) : mixed
Parameters
$contact_id : int

The contact to fetch on

Return values
mixed

An array of objects containing CC account records, or false if none exist

getAllCcByClient()

Retrieves a list of all CC accounts for a given client

public getAllCcByClient(int $client_id) : array<string|int, mixed>
Parameters
$client_id : int

The client ID to fetch on

Return values
array<string|int, mixed>

An array of objects containing CC account records

getCardsExpireSoon()

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

public getCardsExpireSoon(string $date) : array<string|int, mixed>
Parameters
$date : string

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

Return values
array<string|int, mixed>

An array of stdClass objects representing the accounts whose cards expire in the month given

getCc()

Retrieves a single CC account

public getCc(int $account_id[, bool $decrypt = false ][, string $passphrase = null ][, int $staff_id = null ]) : mixed
Parameters
$account_id : int

The ID of the account to get

$decrypt : bool = false

Whether or not to decrypt the account number

$passphrase : string = null

The passphrase required to decrypt accounts (if set)

$staff_id : int = null

The ID of the staff member decrypting the account

Return values
mixed

An object containing the CC account fields, or false if none exist

getCcTypes()

Returns a list of credit card account types

public getCcTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

Key=>value pairs of CC account types

getClientReferenceId()

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

public getClientReferenceId(int $client_id, int $gateway_id[, string $status = null ][, string $type = null ]) : string
Parameters
$client_id : int

The ID of the client to fetch the client reference ID for

$gateway_id : int

The ID of the gateway to that previous account was set up under

$status : string = null

The payment account status by which to filter (optional) (active or inactive)

$type : string = null

The payment account type by which to filter (optional) (cc or ach)

Return values
string

Returns the client reference ID if found, null otherwise

getListAch()

Returns a list of all ACH accounts for a given contact

public getListAch(int $contact_id[, string $sortby = 'last_name' ][, string $order = 'asc' ]) : mixed
Parameters
$contact_id : int

The contact to fetch on

$sortby : string = 'last_name'

The field to sort on

$order : string = 'asc'

The order to sort (asc, desc)

Return values
mixed

An array of objects containing ACH fields or false if none exist

getListCc()

Returns a list of all CC accounts for a given contact

public getListCc(int $contact_id[, string $sortby = 'last_name' ][, string $order = 'asc' ]) : mixed
Parameters
$contact_id : int

The contact to fetch on

$sortby : string = 'last_name'

The field to sort on

$order : string = 'asc'

The order to sort (asc, desc)

Return values
mixed

An array of objects containing CC fields or false if none exist

getTypes()

Returns a list of account types

public getTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

Key=>value pairs of account types

luhnValid()

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

public luhnValid(string $card_number) : bool
Parameters
$card_number : string

The card number to validate

Return values
bool

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

validateAchType()

Validates the ACH 'type' field

public validateAchType(string $type) : bool
Parameters
$type : string

The ACH type

Return values
bool

True if validated, false otherwise

validateCcType()

Validates the CC 'type' field

public validateCcType(string $type) : bool
Parameters
$type : string

The CC type

Return values
bool

True if validated, false otherwise

verifyAch()

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

public verifyAch(array<string|int, mixed> &$vars) : int
Parameters
$vars : array<string|int, mixed>

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)
Return values
int

The ACH account ID for the record just added, void if not added

verifyAchDeposits()

Verifies an ACH account with the gateway

public verifyAchDeposits(int $account_id, array<string|int, mixed> $vars) : mixed
Parameters
$account_id : int

The account ID for this account

$vars : array<string|int, mixed>

An array including:

  • first_deposit The first deposit amount
  • second_deposit The second deposit amount

verifyCc()

Verifies CC account info to ensure proper entry into the system

public verifyCc(array<string|int, mixed> &$vars[, bool $require_fields = true ]) : int
Parameters
$vars : array<string|int, mixed>

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 : bool = true

Whether to require that the cc fields be set to pass validation

Return values
int

The CC account ID for the record just added, void if not added

accountDecrypt()

Performs an asymetric decryption on the given data for the current company using RSA.

private accountDecrypt(string $data[, string $passphrase = null ]) : mixed
Parameters
$data : string

The data to decrypt with the asymetric private-key, base64 encoded

$passphrase : string = null

The passphrase required to decrypt the private-key stored in the system (if set)

Return values
mixed

The decrypted text (string) on success, (boolean) false on failure

accountEncrypt()

Performs an asymetric encryption on the given data for the current company using RSA.

private accountEncrypt(string $data) : string
Parameters
$data : string

The data to encrypt with the asymetric public-key

Return values
string

The encrypted text base64 encoded

addDebitAccount()

Adds the given account as the client's debit account if none are currently set.

private addDebitAccount(int $account_id, string $type) : mixed
Parameters
$account_id : int

The ID of the payment account

$type : string

The type of payment account ('cc' or 'ach')

getAddAchRules()

Returns the partial rule set for adding/editing ACH records

private getAddAchRules(array<string|int, mixed> $vars) : array<string|int, mixed>
Parameters
$vars : array<string|int, mixed>

The input vars

Tags
see
Accounts::getRules()
Return values
array<string|int, mixed>

ACH specific rules

getAddCcRules()

Returns the partial rule set for adding/editing CC records

private getAddCcRules(array<string|int, mixed> $vars[, bool $require_fields = true ]) : array<string|int, mixed>
Parameters
$vars : array<string|int, mixed>

The input vars

$require_fields : bool = true

Whether to require that the cc fields be set to pass validation

Tags
see
Accounts::getRules()
Return values
array<string|int, mixed>

CC specific rules

getRules()

Returns the partial rule set common between ACH/CC records for adding/editing ACH/CC records

private getRules(array<string|int, mixed> $vars[, sting $type = 'cc' ][, bool $edit = false ]) : array<string|int, mixed>
Parameters
$vars : array<string|int, mixed>

The input vars

$type : sting = 'cc'

The type of account being validated ('cc' or 'ach') (optional)

$edit : bool = false

Whether the account is being edited (optional)

Tags
see
Accounts::getAddAchRules()
see
Accounts::getAddCcRules()
Return values
array<string|int, mixed>

Common ACH/CC rules

Tags
subpackage

app.models

copyright

Copyright (c) 2010, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results