Gateway uses Container
Abstract class that all Gateways extend through MerchantGateway or NonmerchantGateway
Defines all methods gateways must inherit and provides all methods common between all gateways
Attributes
- #[AllowDynamicProperties]
Table of Contents
Properties
| $config | |
| $staff_id | |
| $gateway_id | |
| $log_group |
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 |
| 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 |
| getFromContainer() | Fetch an item from the container |
| 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. |
| maskValue() | Masks the given value using a set of rules, defaulting to a set of mask rules if no specific rule given |
| translate() | Translate the given str, or passthrough if no translation et |
Properties
$config
protected
stdClass
$config
A stdClass object representing the configuration for this gateway
$staff_id
protected
int
$staff_id
The ID of the staff member using the gateway
$gateway_id
private
int
$gateway_id
The ID of the gateway instance being used
$log_group
private
string
$log_group
The random ID to identify the group of this transaction for logging purposes
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
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
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
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
maskValue()
Masks the given value using a set of rules, defaulting to a set of mask rules if no specific rule given
private
maskValue(string $value, mixed $rule, string $mask_char, int $unmask_length) : mixed
Parameters
- $value : string
-
The value to mask
- $rule : mixed
-
An array of rule setting, or a string to use $mask_char and $unmask_length default values instead. Values include:
- 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
-
The character to use as the mask character if not specificed by $rule
- $unmask_length : int
-
The length and direction of characters to remain unmasked if not specified by $rule
translate()
Translate the given str, or passthrough if no translation et
private
translate(string $str) : string
Parameters
- $str : string
-
The string to translate
Return values
string —The translated string