Add a payment action
For each payment action available for the payment method, you must implement the following:
- Creating a request with payment details. Described in Get payment information from frontend to backend.
- Request processing using response handler and response validator.
- Specify and configure the gateway command. Described in the Gateway Command topic.
- Add the command to the commands pool, as described in Command Pool.
Configure the command
The gateway command for the payment action must be configured in the di.xml
file of your module. Conventionally, its location must be <your_module_dir>/etc/di.xml
Configure the command as described in Gateway Command.
Example: authorize
payment action for Braintree
Configuring the gateway command and adding it to command pool (app/code/Magento/Braintree/etc/di.xml
):
In the command configuration we see that BraintreeAuthorizeRequest
is specified as requestBuilder
, that is a
Let’s look closer on the requestBuilder
arguments. This argument value is a list of builders, builder composite.
The BraintreeAuthorizeRequest
builder contains the following builders (app/code/Magento/Braintree/etc/di.xml
):
The most important builder in this pool is Magento\Braintree\Gateway\Request\PaymentDataBuilder
, the payment
builder. It is responsible for the payment information part of the request.
Please see the Get payment information from frontend to backend for details about how payment information can be handled.
Related topics
- Add a custom payment method to checkout: how to add a custom payment integration to checkout page.