cancel
Showing results for 
Search instead for 
Did you mean: 

Custom payment not showing on checkout (frontend)

Custom payment not showing on checkout (frontend)

I'm developing a custom module in magento 2.1.7 for deployment of a custom payment checkout. The admin panel is working however when proceeding to checkout the deployed custom payment is absent. 

Bellow is a list of all code. Any help is greatly appeciated.

 

etc/adminhtml/system.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Magento/Config/etc/system_file.xsd">
    <system>
        <section id="payment">
            <group id="Multibanco" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Multibanco</label>
                <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Enabled</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Title</label>
                </field>

                <field id="api_key" translate="label" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Api Key</label>
                    <comment>Se ainda não tiver uma chave <![CDATA[ <a target="_blank" href="https://eupago.pt/registo?magento#registo_form">registe-se aqui</a> ]]></comment>
                    <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
                </field>

                <field id="send_invoice_email" translate="label" type="select" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Send Invoice email</label>
                    <comment>Envia o email de confirmação de pagamento (invoice email)</comment>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="mostra_icon" translate="label" type="select" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Icon multibanco</label>
                    <comment>Mostra icon do multibanco na listagem de metodos de pagamento antes do titulo</comment>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
<!--
                <field id="frontend_template" translate="label" type="select" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Frontend Template</label>
                    <comment>Selecione o tema e defina como os seus clientes vêm este método de pagamento</comment>
                    <source_model>EuPago\multibanco\Model\System\Config\Template</source_model>
                </field>
!-->
                <field id="specificcountry" translate="label" type="multiselect" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="0">
                    <label>Allow specific countries</label>
                    <source_model>Magento\Directory\Model\Config\Source\Country</source_model>
                    <can_be_empty>1</can_be_empty>
                    <depends><field id="active">1</field></depends>
                </field>

                <field id="per_dup" translate="label" type="select" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Allow duplicated payments</label>
                    <comment>Escolha sim se pretende que apenas seja possivel pagar uma referência várias vezes</comment>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>

                <field id="payment_deadline" translate="label" type="text" sortOrder="8" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Payment Deadline</label>
                    <comment>Se pretender que a referência tenha uma validade, preencha o número de dias que a referência está disponível para pagamento</comment>
                </field>

            </group>
        </section>
    </system>
</config>

etc/config.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <payment>
            <multibanco>
                <active>1</active>
                <model>Eupago\Multibanco\Model\Multibanco</model>
                <order_status>1</order_status>
                <order_status>pending</order_status>
                <title>Eupago Multibanco</title>
                <cgi_url>https://seguro.eupago.pt/eupagov8.wsdl</cgi_url>
                <debug>1</debug>
                <payment_action>order</payment_action>
            </multibanco>
        </payment>
    </default>
</config>

etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Eupago_Multibanco" setup_version="2.1.0">
    <sequence>
        <module name="Magento_Sales" />
        <module name="Magento_Payment" />
        <module name="Magento_Directory" />
        <module name="Magento_Config" />
    </sequence>
</module>


</config>

etc/payment.xml

<payment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Payment:etc/payment.xsd">
    <methods>
        <method name="multibanco">
            <allow_multiple_address>1</allow_multiple_address>
        </method>
    </methods>
</payment>

etc/frontend/routes.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="multibanco" frontName="Eupago_Multibanco">
<module name="Eupago_Multibanco" />
</route>
</router>
</config>

view/web/js/view/payment/multibanco.js

/*browser:true*/
/*global define*/
define(
    [
        'uiComponent',
        'Magento_Checkout/js/model/payment/renderer-list'
    ],
    function (
        Component,
        rendererList
    ) {
        'use strict';
        rendererList.push(
            {
                type: 'Eupago_Multibanco',
                component: 'Eupago_Multibanco/payment/method-renderer/multibanco'
            }
        );
        //console.log(Component.extend);
        /** Add view logic here if needed */
        return Component.extend({});
    }
);

view/web/js/view/payment/method-renderer/multibanco.js

/*browser:true*/
/*global define*/
console.log("method");
define(
    [
        'Magento_Checkout/js/view/payment/default'
    ],
    function (Component, $) {
        'use strict';

        return Component.extend({
            defaults: {
                template: 'Eupago_Multibanco/payment/eupago_multibanco-form'
            },

            getCode: function() {
                return 'eupago_multibanco';
            },

            isActive: function() {
                return true;
            },

            validate: function() {
                var $form = $('#' + this.getCode() + '-form');
                return $form.validation() && $form.validation('isValid');
            }
        });
    }
);

model/multibanco.php (partial file)

namespace Eupago\Multibanco\Model;

class Multibanco extends \Magento\Payment\Model\Method\AbstractMethod //Mage_Payment_Model_Method_Abstract
{
    
    protected $_code = 'multibanco';

Controller/CallBackController.php (partial file)

<?php

namespace Eupago\Multibanco\Controller\Callback;

use Magento\Framework\App\Action\Context;

abstract class Callback extends \Magento\Framework\App\Action\Action {

// valida todos os metodos de pagamento
public function allAction(){

 

2 REPLIES 2

Re: Custom payment not showing on checkout (frontend)

almost forgot: File view/web/js/view/payment/method-renderer/multibanco.js is not loaded upon page load

Re: Custom payment not showing on checkout (frontend)

in config.xml you should add this line 

<can_use_checkout>1</can_use_checkout>