Magento 2 – How complete my payment gateway – redirect user to external website

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:

  1. add items to cart
  2. got to cart
  3. start checkout
  4. select MyCustomPayment (can be selected)
  5. click pay (currently just directing to the success page)

I have the following di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="DischemVodapayApiVodapayInterface" type="DischemVodapayModelApiVodapay"/> <!-- Payment Gateway Facade --> <virtualType name="VodapayFacade" type="MagentoPaymentModelMethodAdapter"> <arguments> <argument name="code" xsi:type="const">DischemVodapayModelPaymentVodapay::METHOD_CODE</argument> <argument name="formBlockType" xsi:type="string">MagentoPaymentBlockForm</argument> <argument name="infoBlockType" xsi:type="string">MagentoPaymentBlockInfo</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="MagentoPaymentGatewayConfigValueHandlerPool"> <arguments> <argument name="handlers" xsi:type="array"> <item name="default" xsi:type="string">VodapayConfigValueHandler</item> </argument> </arguments> </virtualType> <virtualType name="VodapayConfigValueHandler" type="MagentoPaymentGatewayConfigConfigValueHandler"> <arguments> <argument name="configInterface" xsi:type="object">VodapayConfig</argument> </arguments> </virtualType> <!-- Validator Pool --> <virtualType name="VodapayValidatorPool" type="MagentoPaymentGatewayValidatorValidatorPool"> <arguments> <argument name="validators" xsi:type="array"> <item name="country" xsi:type="string">VodapayCountryValidator</item> <item name="availability" xsi:type="string">DischemVodapayGatewayValidatorSessionValidator</item> </argument> </arguments> </virtualType> <virtualType name="VodapayCountryValidator" type="MagentoPaymentGatewayValidatorCountryValidator"> <arguments> <argument name="config" xsi:type="object">VodapayConfig</argument> </arguments> </virtualType> <!-- Command Pool entries --> <virtualType name="VodapayCommandPool" type="MagentoPaymentGatewayCommandCommandPool"> <arguments> <argument name="commands" xsi:type="array"> <item name="authorize" xsi:type="string">DischemVodapayGatewayCommandAuthorize</item> </argument> </arguments> </virtualType> <!-- Multiple use entries --> <virtualType name="VodapayConfig" type="MagentoPaymentGatewayConfigConfig"> <arguments> <argument name="methodCode" xsi:type="const">DischemVodapayModelPaymentVodapay::METHOD_CODE</argument> </arguments> </virtualType> </config> 

and VodapayGatewayCommandAuthorize.php as below

<?php namespace DischemVodapayGatewayCommand; use MagentoPaymentGatewayCommandInterface; 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 // TODO: return redirection link to user } } 

submitted by /u/TheX3R0
[link] [comments]