MerchantGateway extends Gateway
Abstract class that all Merchant Gateways must extend
Table of Contents
Properties
| $config | |
| $Http | |
| $staff_id |
Methods
| editSettings() | Validates the given meta (settings) data to be updated for this gateway |
| encryptableFields() | Returns an array of all fields to encrypt when storing in the database |
| errors() | Return all validation errors encountered |
| getAuthors() | Returns the name and URL for the authors of this gateway |
| getCurrencies() | Return all currencies supported by this gateway |
| getDescription() | Returns the description of this gateway |
| getLogo() | Returns the relative path from this gateway's directory to the logo for this module. Defaults to views/default/images/logo.png |
| getName() | Returns the name of this gateway |
| getSettings() | Create and return the view content required to modify the settings of this gateway |
| getSignupUrl() | Returns the URL to the signup page for this gateway. |
| getVersion() | Returns the version of this gateway |
| install() | Performs any necessary bootstraping actions |
| requiresCustomerPresent() | Used to determine whether this gateway can be configured for autodebiting accounts |
| setCurrency() | Sets the currency code to be used for all subsequent payments |
| setGatewayId() | Sets the ID of the gateway for a particular transaction |
| setMeta() | Sets the meta data for this particular gateway |
| setStaffId() | Sets the ID of the staff member on a particular transaction |
| uninstall() | Performs any necessary cleanup actions |
| upgrade() | Performs migration of data from $current_version (the current installed version) to the given file set version |
| clientIdFromEmail() | Fetch a client ID from the given email address |
| getCommonError() | Fetches an array containing the error response to be set using Input::setErrors() |
| getFromContainer() | Fetch an item from the container |
| httpRequest() | Process a request over HTTP using the supplied method type, url and parameters. |
| ifSet() | Returns $value if $value isset, otherwise returns $alt |
| loadConfig() | Loads a given config file |
| log() | Attempts to log the given info to the gateway log. |
| makeView() | Initializes a View object and returns it |
| maskData() | Masks each field listed in $mask_fields that also appears in $data, such that sensitive information is redacted. |
| maskDataRecursive() | Masks each field listed in $mask_fields that also appears in $data, such that sensitive information is redacted. Will recursively traverse $data looking for keys that match those in $mask_fields. |
Properties
$config
protected
stdClass
$config
A stdClass object representing the configuration for this gateway
$Http
protected
Http
$Http
An Http object, used to make HTTP requests
$staff_id
protected
int
$staff_id
The ID of the staff member using the gateway
Methods
editSettings()
Validates the given meta (settings) data to be updated for this gateway
public
abstract editSettings(array<string|int, mixed> $meta) : array<string|int, mixed>
Parameters
- $meta : array<string|int, mixed>
-
An array of meta (settings) data to be updated for this gateway
Return values
array<string|int, mixed> —The meta data to be updated in the database for this gateway, or reset into the form on failure
encryptableFields()
Returns an array of all fields to encrypt when storing in the database
public
abstract encryptableFields() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of the field names to encrypt when storing in the database
errors()
Return all validation errors encountered
public
errors() : mixed
Return values
mixed —Boolean false if no errors encountered, an array of errors otherwise
getAuthors()
Returns the name and URL for the authors of this gateway
public
getAuthors() : array<string|int, mixed>
Return values
array<string|int, mixed> —The name and URL of the authors of this gateway
getCurrencies()
Return all currencies supported by this gateway
public
getCurrencies() : array<string|int, mixed>
Return values
array<string|int, mixed> —A numerically indexed array containing all currency codes (ISO 4217 format) this gateway supports
getDescription()
Returns the description of this gateway
public
getDescription() : string
Return values
string —The description of this gateway
getLogo()
Returns the relative path from this gateway's directory to the logo for this module. Defaults to views/default/images/logo.png
public
getLogo() : string
Return values
string —The relative path to the gateway's logo
getName()
Returns the name of this gateway
public
getName() : string
Return values
string —The common name of this gateway
getSettings()
Create and return the view content required to modify the settings of this gateway
public
abstract getSettings([array<string|int, mixed> $meta = null ]) : string
Parameters
- $meta : array<string|int, mixed> = null
-
An array of meta (settings) data belonging to this gateway
Return values
string —HTML content containing the fields to update the meta data for this gateway
getSignupUrl()
Returns the URL to the signup page for this gateway.
public
getSignupUrl() : string
Return values
string —The URL to the signup page if one exists, null otherwise
getVersion()
Returns the version of this gateway
public
getVersion() : string
Return values
string —The current version of this gateway
install()
Performs any necessary bootstraping actions
public
install() : mixed
requiresCustomerPresent()
Used to determine whether this gateway can be configured for autodebiting accounts
public
abstract requiresCustomerPresent() : bool
Return values
bool —True if the customer must be present (e.g. in the case of credit card customer must enter security code), false otherwise
setCurrency()
Sets the currency code to be used for all subsequent payments
public
abstract setCurrency(string $currency) : mixed
Parameters
- $currency : string
-
The ISO 4217 currency code to be used for subsequent payments
setGatewayId()
Sets the ID of the gateway for a particular transaction
public
setGatewayId(int $id) : mixed
Parameters
- $id : int
-
The gateway ID
setMeta()
Sets the meta data for this particular gateway
public
abstract setMeta([array<string|int, mixed> $meta = null ]) : mixed
Parameters
- $meta : array<string|int, mixed> = null
-
An array of meta data to set for this gateway
setStaffId()
Sets the ID of the staff member on a particular transaction
public
setStaffId(int $id) : mixed
Parameters
- $id : int
-
The staff ID
uninstall()
Performs any necessary cleanup actions
public
uninstall(int $gateway_id, bool $last_instance) : mixed
Parameters
- $gateway_id : int
-
The ID of the gateway being uninstalled
- $last_instance : bool
-
True if $gateway_id is the last instance across all companies for this gateway, false otherwise
upgrade()
Performs migration of data from $current_version (the current installed version) to the given file set version
public
upgrade(string $current_version) : mixed
Parameters
- $current_version : string
-
The current installed version of this gateway
clientIdFromEmail()
Fetch a client ID from the given email address
protected
clientIdFromEmail(string $email) : mixed
Parameters
- $email : string
-
The email address for the client
Return values
mixed —The client ID if found, null otherwise
getCommonError()
Fetches an array containing the error response to be set using Input::setErrors()
protected
getCommonError(string $type) : mixed
Parameters
- $type : string
-
The type of error to fetch. Values include:
- card_number_invalid
- card_expired
- routing_number_invalid
- account_number_invalid
- duplicate_transaction
- card_not_accepted
- invalid_security_code
- address_verification_failed
- transaction_not_found The transaction was not found on the remote gateway
- unsupported The action is not supported by the gateway
- general A general error occurred
Return values
mixed —An array containing the error to populate using Input::setErrors(), false if the type does not exist
getFromContainer()
Fetch an item from the container
protected
getFromContainer(string $service) : mixed
Parameters
- $service : string
-
The name of the service from the container to fetch
Return values
mixed —The service if found, otherwise null
httpRequest()
Process a request over HTTP using the supplied method type, url and parameters.
protected
httpRequest(string $method[, string $url = null ][, mixed $params = null ]) : mixed
Parameters
- $method : string
-
The method type (e.g. GET, POST)
- $url : string = null
-
The URL to post to
- $params : mixed = null
ifSet()
Returns $value if $value isset, otherwise returns $alt
protected
ifSet(mixed &$value[, mixed $alt = null ]) : mixed
since v5.1.0, use isset() instead
Parameters
- $value : mixed
-
The value to return if $value isset
- $alt : mixed = null
-
The value to return if $value is not set
Return values
mixed —Either $value or $alt
loadConfig()
Loads a given config file
protected
loadConfig(string $file) : mixed
Parameters
- $file : string
-
The full path to the config file to load
log()
Attempts to log the given info to the gateway log.
protected
log(string $url[, string $data = null ][, string $direction = 'input' ][, bool $success = false ]) : string
Parameters
- $url : string
-
The URL contacted for this request
- $data : string = null
-
A string of gateway data sent along with the request (optional)
- $direction : string = 'input'
-
The direction of the log entry (input or output, default input)
- $success : bool = false
-
True if the request was successful, false otherwise
Tags
Return values
string —Returns the 8-character group identifier, used to link log entries together
makeView()
Initializes a View object and returns it
protected
makeView(string $file[, string $view = 'default' ][, string $view_path = null ]) : View
Parameters
- $file : string
-
The view file to load
- $view : string = 'default'
-
The view directory name to find the view file
- $view_path : string = null
-
The path to the $view relative to the root web directory
Return values
View —An instance of the View object
maskData()
Masks each field listed in $mask_fields that also appears in $data, such that sensitive information is redacted.
protected
maskData(array<string|int, mixed> $data, array<string|int, mixed> $mask_fields[, string $mask_char = 'x' ][, int $unmask_length = 0 ]) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
-
An array of key/value pairs
- $mask_fields : array<string|int, mixed>
-
An array of key/value pairs where each key identifies a key in $data and whose value is an array containing:
- char The character to use as the mask
- length The length of the original data to remain unmasked. A negative number will leave that many characters unmasked from the end of the string, while a positive number will leave that many characters unmasked from the beginning of the string, 0 will mask all characters
- $mask_char : string = 'x'
-
The character to use as the mask character if not specificed in $mask_fields array
- $unmask_length : int = 0
-
The length and direction of characters to remain unmasked if not specified in $mask_fields array
Return values
array<string|int, mixed> —The $data array with fields masked as necessary
maskDataRecursive()
Masks each field listed in $mask_fields that also appears in $data, such that sensitive information is redacted. Will recursively traverse $data looking for keys that match those in $mask_fields.
protected
maskDataRecursive(array<string|int, mixed> $data, array<string|int, mixed> $mask_fields[, string $mask_char = 'x' ][, int $unmask_length = 0 ]) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
-
An array of key/value pairs
- $mask_fields : array<string|int, mixed>
-
An array of key/value pairs where each key identifies a key in $data and whose value is an array containing:
- char The character to use as the mask
- length The length of the original data to remain unmasked. A negative number will leave that many characters unmasked from the end of the string, while a positive number will leave that many characters unmasked from the beginning of the string, 0 will mask all characters
- $mask_char : string = 'x'
-
The character to use as the mask character if not specificed in $mask_fields array
- $unmask_length : int = 0
-
The length and direction of characters to remain unmasked if not specified in $mask_fields array
Return values
array<string|int, mixed> —The $data array with fields masked as necessary