I'm trying to make a payment gateway, this gateway is like all others with one exception.
in this gateway, after the user does the following:
add items to cart
got to cart
start checkout
select MyCustomPayment (can be selected)
click pay (currently just directing to the success page)
after clicking pay, i would like to redirect the user to another url, of a payment gateway
<?php namespace Dischem\Vodapay\Gateway\Command; use Magento\Payment\Gateway\CommandInterface; class Authorize implements CommandInterface { public function __construct() { // TODO: Implement contsturutor as needed. } public function execute(array $commandSubject) { // TODO: Get order here // TODO: generate redirection link here for example link could be https://example.com/orderid=1234 // TODO: return redirection link to user } }
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Dischem\Vodapay\Api\VodapayInterface" type="Dischem\Vodapay\Model\Api\Vodapay"/> <!-- Payment Gateway Facade --> <virtualType name="VodapayFacade" type="Magento\Payment\Model\Method\Adapter"> <arguments> <argument name="code" xsi:type="const">Dischem\Vodapay\Model\Payment\Vodapay::METHOD_CODE</argument> <argument name="formBlockType" xsi:type="string">Magento\Payment\Block\Form</argument> <argument name="infoBlockType" xsi:type="string">Magento\Payment\Block\Info</argument> <argument name="valueHandlerPool" xsi:type="object">VodapayValueHandlerPool</argument> <argument name="validatorPool" xsi:type="object">VodapayValidatorPool</argument> <argument name="commandPool" xsi:type="object">VodapayCommandPool</argument> </arguments> </virtualType> <!-- Value Handler Pool entries --> <virtualType name="VodapayValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool"> <arguments> <argument name="handlers" xsi:type="array"> <item name="default" xsi:type="string">VodapayConfigValueHandler</item> </argument> </arguments> </virtualType> <virtualType name="VodapayConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler"> <arguments> <argument name="configInterface" xsi:type="object">VodapayConfig</argument> </arguments> </virtualType> <!-- Validator Pool --> <virtualType name="VodapayValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool"> <arguments> <argument name="validators" xsi:type="array"> <item name="country" xsi:type="string">VodapayCountryValidator</item> <item name="availability" xsi:type="string">Dischem\Vodapay\Gateway\Validator\SessionValidator</item> </argument>
</virtualType>
<virtualType name="VodapayCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
<arguments>
<argument name="config" xsi:type="object">VodapayConfig</argument>
</arguments>
</virtualType>
<!-- Command Pool entries -->
<virtualType name="VodapayCommandPool" type="Magento\Payment\Gateway\Command\CommandPool">
<arguments>
<argument name="commands" xsi:type="array">
<item name="authorize" xsi:type="string">Dischem\Vodapay\Gateway\Command\Authorize</item>
</argument>
</arguments>
</virtualType>
<!-- Multiple use entries -->
<virtualType name="VodapayConfig" type="Magento\Payment\Gateway\Config\Config">
<arguments>
<argument name="methodCode" xsi:type="const">Dischem\Vodapay\Model\Payment\Vodapay::METHOD_CODE</argument>
</arguments>
</virtualType>
</config>
Hello @deanvg90003cdf
To redirect a user to an external website for payment in Magento 2, you will need to create a payment method module and configure it to redirect the user to the external website. Here are the general steps you can follow:
Once you have completed these steps, when a customer selects the payment method you created, they will be redirected to the external payment gateway to complete the payment process. After the payment is completed, the customer will be redirected back to your Magento 2 store.
If you find our reply helpful, please give us kudos.
A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.
WebDesk Solution Support Team
Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Thank You,
WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Location: 150 King St. W. Toronto, ON M5H 1J9