GatewayInterface
- Type
- Interface
- Namespace
- craft\commerce\base
- Extends
- craft\base\SavableComponentInterface (opens new window)
- Implemented by
- craft\commerce\base\Gateway, craft\commerce\base\SubscriptionGateway, craft\commerce\gateways\Dummy, craft\commerce\gateways\Manual, craft\commerce\gateways\MissingGateway
- Since
- 2.0
GatewayInterface defines the common interface to be implemented by gateway classes.
A class implementing this interface should also use \craft\commerce\base\SavableComponentTrait
and craft\commerce\base\GatewayTrait.
View source (opens new window)
# Public Methods
Method | Description |
---|---|
afterDelete() (opens new window) | Performs actions after a component is deleted. |
afterSave() (opens new window) | Performs actions after a component is saved. |
authorize() | Makes an authorize request. |
availableForUseWithOrder() | Returns true if gateway supports payments for the supplied order. |
beforeApplyDelete() (opens new window) | Performs actions before a component delete is applied to the database. |
beforeDelete() (opens new window) | Performs actions before a component is deleted. |
beforeSave() (opens new window) | Performs actions before a component is saved. |
capture() | Makes a capture request. |
completeAuthorize() | Complete the authorization for offsite payments. |
completePurchase() | Complete the purchase for offsite payments. |
createPaymentSource() | Creates a payment source from source data and customer id. |
deletePaymentSource() | Deletes a payment source on the gateway by its token. |
displayName() (opens new window) | Returns the display name of this class. |
extraFields() (opens new window) | Returns the list of additional fields that can be returned by toArray() (opens new window) in addition to those listed in fields() (opens new window). |
fields() (opens new window) | Returns the list of fields that should be returned by default by toArray() (opens new window) when no specific fields are specified. |
getIsNew() (opens new window) | Returns whether the component is new (unsaved). |
getPaymentFormModel() | Returns payment form model to use in payment forms. |
getSettings() (opens new window) | Returns an array of the component’s settings. |
getSettingsHtml() (opens new window) | Returns the component’s settings HTML. |
getTransactionHashFromWebhook() | Retrieves the transaction hash from the webhook data. This could be a query string param or part of the response data. |
instance() (opens new window) | Returns static class instance, which can be used to obtain meta information. |
isSelectable() (opens new window) | Returns whether the component should be selectable in component Type selects. |
processWebHook() | Processes a webhook and return a response |
purchase() | Makes a purchase request. |
refund() | Makes an refund request. |
settingsAttributes() (opens new window) | Returns the list of settings attribute names. |
supportsAuthorize() | Returns true if gateway supports authorize requests. |
supportsCapture() | Returns true if gateway supports capture requests. |
supportsCompleteAuthorize() | Returns true if gateway supports completing authorize requests |
supportsCompletePurchase() | Returns true if gateway supports completing purchase requests |
supportsPartialPayment() | Returns true if gateway supports partial payment requests. |
supportsPartialRefund() | Returns true if gateway supports partial refund requests. |
supportsPaymentSources() | Returns true if gateway supports storing payment sources |
supportsPurchase() | Returns true if gateway supports purchase requests. |
supportsRefund() | Returns true if gateway supports refund requests. |
supportsWebhooks() | Returns true if gateway supports webhooks. |
toArray() (opens new window) | Converts the object into an array. |
# authorize()
Makes an authorize request.
View source (opens new window)
Arguments
$transaction
(craft\commerce\models\Transaction) – The authorize transaction$form
(craft\commerce\models\payments\BasePaymentForm) – A form filled with payment info
# availableForUseWithOrder()
Returns true
if gateway supports payments for the supplied order.
This method is called before a payment is made for the supplied order. It can be used by developers building a checkout and deciding if this gateway should be shown as and option to the customer.
It also can prevent a gateway from being used with a particular order.
An example of this can be found in the manual payment gateway: It has a setting that can limit its use to only be used with orders that are of a zero value amount. See below for an example of how it uses this method to reject the gateway's use on orders that are not $0.00 if the setting is turned on
public function availableForUseWithOrder($order): bool
if ($this->onlyAllowForZeroPriceOrders && $order->getTotalPrice() != 0) {
return false;
}
return true;
}
View source (opens new window)
Arguments
$order
– Order The order this gateway can or can not be available for payment with.
# capture()
Makes a capture request.
View source (opens new window)
Arguments
$transaction
(craft\commerce\models\Transaction) – The capture transaction$reference
(string (opens new window)) – Reference for the transaction being captured.
# completeAuthorize()
Complete the authorization for offsite payments.
View source (opens new window)
Arguments
$transaction
(craft\commerce\models\Transaction) – The transaction
# completePurchase()
Complete the purchase for offsite payments.
View source (opens new window)
Arguments
$transaction
(craft\commerce\models\Transaction) – The transaction
# createPaymentSource()
Creates a payment source from source data and customer id.
View source (opens new window)
Arguments
$sourceData
$customerId
# deletePaymentSource()
Deletes a payment source on the gateway by its token.
View source (opens new window)
Arguments
$token
(string (opens new window))
# getPaymentFormModel()
Returns payment form model to use in payment forms.
View source (opens new window)
# getTransactionHashFromWebhook()
- Since
- 3.1.9
Retrieves the transaction hash from the webhook data. This could be a query string param or part of the response data.
View source (opens new window)
Returns
string (opens new window), null (opens new window)
# processWebHook()
Processes a webhook and return a response
View source (opens new window)
Throws
- Throwable (opens new window)
if something goes wrong
# purchase()
Makes a purchase request.
View source (opens new window)
Arguments
$transaction
(craft\commerce\models\Transaction) – The purchase transaction$form
(craft\commerce\models\payments\BasePaymentForm) – A form filled with payment info
# refund()
Makes an refund request.
View source (opens new window)
Arguments
$transaction
(craft\commerce\models\Transaction) – The refund transaction
# supportsAuthorize()
Returns true if gateway supports authorize requests.
View source (opens new window)
# supportsCapture()
Returns true if gateway supports capture requests.
View source (opens new window)
# supportsCompleteAuthorize()
Returns true if gateway supports completing authorize requests
View source (opens new window)
# supportsCompletePurchase()
Returns true if gateway supports completing purchase requests
View source (opens new window)
# supportsPartialPayment()
Returns true if gateway supports partial payment requests.
View source (opens new window)
# supportsPartialRefund()
Returns true if gateway supports partial refund requests.
View source (opens new window)
# supportsPaymentSources()
Returns true if gateway supports storing payment sources
View source (opens new window)
# supportsPurchase()
Returns true if gateway supports purchase requests.
View source (opens new window)
# supportsRefund()
Returns true if gateway supports refund requests.
View source (opens new window)
# supportsWebhooks()
Returns true if gateway supports webhooks.
If true
is returned, this show the webhook url
to the person setting up your gateway (after the gateway is saved).
This also affects whether the webhook controller should route webhook requests to your
processWebHook()
method in this class.
← Gateway GatewayTrait →