Gateways
- Type
- Class
- Namespace
- craft\commerce\services
- Inherits
- craft\commerce\services\Gateways » yii\base\Component (opens new window) » yii\base\BaseObject (opens new window)
- Implements
- yii\base\Configurable (opens new window)
- Since
- 2.0
Gateway service.
View source (opens new window)
# Public Properties
Property | Description |
---|---|
allCustomerEnabledGateways | craft\commerce\base\GatewayInterface[] – All gateways that are enabled for frontend |
allFrontEndGateways | craft\commerce\base\GatewayInterface[] – All gateways that are enabled for frontend |
allGatewayTypes | string (opens new window)[] |
allGateways | craft\commerce\base\GatewayInterface[] – All gateways |
allSubscriptionGateways | array (opens new window) |
behaviors (opens new window) | yii\base\Behavior (opens new window) – List of behaviors attached to this component |
# allCustomerEnabledGateways
- Type
- craft\commerce\base\GatewayInterface[]
- Access
- Read-only
All gateways that are enabled for frontend
View source (opens new window)
# allFrontEndGateways
- Type
- craft\commerce\base\GatewayInterface[]
- Access
- Read-only
All gateways that are enabled for frontend
View source (opens new window)
# allGatewayTypes
- Type
- string (opens new window)[]
- Access
- Read-only
View source (opens new window)
# allGateways
- Type
- craft\commerce\base\GatewayInterface[]
- Access
- Read-only
All gateways
View source (opens new window)
# allSubscriptionGateways
- Type
- array (opens new window)
- Access
- Read-only
View source (opens new window)
# Public Methods
Method | Description |
---|---|
__call() (opens new window) | Calls the named method which is not a class method. |
__clone() (opens new window) | This method is called after the object is created by cloning an existing one. |
__construct() (opens new window) | Constructor. |
__get() (opens new window) | Returns the value of an object property. |
__isset() (opens new window) | Checks if a property is set, i.e. defined and not null. |
__set() (opens new window) | Sets value of an object property. |
__unset() (opens new window) | Sets an object property to null. |
archiveGatewayById() | Archives a gateway by its ID. |
attachBehavior() (opens new window) | Attaches a behavior to this component. |
attachBehaviors() (opens new window) | Attaches a list of behaviors to the component. |
behaviors() (opens new window) | Returns a list of behaviors that this component should behave as. |
canGetProperty() (opens new window) | Returns a value indicating whether a property can be read. |
canSetProperty() (opens new window) | Returns a value indicating whether a property can be set. |
className() (opens new window) | Returns the fully qualified name of this class. |
createGateway() | Creates a gateway with a given config |
detachBehavior() (opens new window) | Detaches a behavior from the component. |
detachBehaviors() (opens new window) | Detaches all behaviors from the component. |
ensureBehaviors() (opens new window) | Makes sure that the behaviors declared in behaviors() (opens new window) are attached to this component. |
getAllCustomerEnabledGateways() | Returns all customer enabled gateways. |
getAllFrontEndGateways() | Returns all frontend enabled gateways. |
getAllGatewayTypes() | Returns all registered gateway types. |
getAllGateways() | Returns all gateways |
getAllSubscriptionGateways() | Returns all subscription gateways. |
getBehavior() (opens new window) | Returns the named behavior object. |
getBehaviors() (opens new window) | Returns all behaviors attached to this component. |
getGatewayByHandle() | Returns a gateway by its handle. |
getGatewayById() | Returns a gateway by its ID. |
getGatewayOverrides() | Returns any custom gateway settings form config file. |
handleArchivedGateway() | Handle gateway being archived |
handleChangedGateway() | Handle gateway change |
hasEventHandlers() (opens new window) | Returns a value indicating whether there is any handler attached to the named event. |
hasMethod() (opens new window) | Returns a value indicating whether a method is defined. |
hasProperty() (opens new window) | Returns a value indicating whether a property is defined. |
init() (opens new window) | Initializes the object. |
off() (opens new window) | Detaches an existing event handler from this component. |
on() (opens new window) | Attaches an event handler to an event. |
reorderGateways() | Reorders gateways by ids. |
saveGateway() | Saves a gateway. |
trigger() (opens new window) | Triggers an event. |
# archiveGatewayById()
Archives a gateway by its ID.
View source (opens new window)
Arguments
$id
(integer (opens new window)) – Gateway ID
Returns
boolean (opens new window) – Whether the archiving was successful or not
# createGateway()
Creates a gateway with a given config
View source (opens new window)
Arguments
$config
(mixed
) – The gateway’s class name, or its config, with atype
value and optionally asettings
value
Returns
craft\commerce\base\GatewayInterface – The gateway
# getAllCustomerEnabledGateways()
Returns all customer enabled gateways.
View source (opens new window)
Returns
craft\commerce\base\GatewayInterface[] – All gateways that are enabled for frontend
# getAllFrontEndGateways()
DEPRECATED
Deprecated as of 2.0
Returns all frontend enabled gateways.
View source (opens new window)
Returns
craft\commerce\base\GatewayInterface[] – All gateways that are enabled for frontend
# getAllGatewayTypes()
Returns all registered gateway types.
View source (opens new window)
Returns
# getAllGateways()
Returns all gateways
View source (opens new window)
Returns
craft\commerce\base\GatewayInterface[] – All gateways
# getAllSubscriptionGateways()
Returns all subscription gateways.
View source (opens new window)
Returns
# getGatewayByHandle()
Returns a gateway by its handle.
View source (opens new window)
Arguments
$handle
(string (opens new window))
Returns
craft\commerce\base\Gateway, craft\commerce\base\GatewayInterface, null (opens new window) – The gateway or null if not found.
# getGatewayById()
Returns a gateway by its ID.
View source (opens new window)
Arguments
Returns
craft\commerce\base\GatewayInterface, null (opens new window) – The gateway or null if not found.
# getGatewayOverrides()
Returns any custom gateway settings form config file.
View source (opens new window)
Arguments
$handle
(string (opens new window)) – The gateway handle
Returns
array (opens new window), null (opens new window)
# handleArchivedGateway()
Handle gateway being archived
View source (opens new window)
Arguments
Returns
void
Throws
- Throwable (opens new window)
if reasons
# handleChangedGateway()
Handle gateway change
View source (opens new window)
Arguments
Returns
void
Throws
- Throwable (opens new window)
if reasons
# reorderGateways()
Reorders gateways by ids.
View source (opens new window)
Arguments
$ids
(array (opens new window)) – Array of gateways.
Returns
boolean (opens new window) – Always true.
# saveGateway()
Saves a gateway.
View source (opens new window)
Arguments
$gateway
(craft\commerce\base\Gateway) – The gateway to be saved.$runValidation
(boolean (opens new window)) – Whether the gateway should be validated
Returns
boolean (opens new window) – Whether the gateway was saved successfully or not.
Throws
# Constants
Constant | Description |
---|---|
CONFIG_GATEWAY_KEY |
# Events
# EVENT_REGISTER_GATEWAY_TYPES
The event that is triggered when registering gateways.
Plugins can register their own gateways.
use craft\events\RegisterComponentTypesEvent;
use craft\commerce\services\Purchasables;
use yii\base\Event;
Event::on(Gateways::class, Gateways::EVENT_REGISTER_GATEWAY_TYPES, function(RegisterComponentTypesEvent $e) {
$e->types[] = MyGateway::class;
});