The Payment Provider Gateway documentation uses the Magento 2.3 (now Adobe Commerce and Magento Open Source) of the Braintree module as a reference application. The Braintree module was removed in version 2.4.0. The concepts described in this guide are still applicable to version 2.4.x, but the code samples are not supported.
Configure payment method by area
You can determine if the payment method is available for the storefront and checkout in the payment method configuration in config.xml
:
can_use_checkout
: Determines if payment method is available in storefront checkoutcan_use_internal
: Determines if payment method is available in Admin order creation
If you have a different payment flow for the storefront and the Admin panel, you can use a separate DI configuration for each area:
%Vendor_Module%/etc/adminhtml/di.xml
: DI configuration for the Admin panel%Vendor_Module%/etc/frontend/di.xml
: DI configuration for the storefront
Example
For example, if the storefront 3D Secure verification uses the Braintree payment method, but you don't want it to be available in the Admin panel, then the DI configuration for the authorization request builder for the admin area would be something similar to:
Copied to your clipboard<virtualType name="BraintreeAuthorizeRequest" type="Magento\Payment\Gateway\Request\BuilderComposite"><arguments><argument name="builders" xsi:type="array"><item name="customer" xsi:type="string">Magento\Braintree\Gateway\Request\CustomerDataBuilder</item><item name="payment" xsi:type="string">Magento\Braintree\Gateway\Request\PaymentDataBuilder</item>...</argument></arguments></virtualType>
While the general app/code/Magento/Braintree/etc/di.xml does not have 3D secure verification builder for the Admin panel, you can use a virtual type with the same name (the object will be created according to the context of the area).