Magento 2.1 Custom Payment Method – Add HTML

magento-2.1magento2payment-methods

I created a new payment method in Magento 2 using the instructions here

The payment method is created successfully. However, I want to add instructions under the payment method in the red box in attached image.

enter image description here

I checked this link, but It didn't help.

I am using magento 2.1.5 EE

Any help is appreciated.

Best Answer

You can add custom html in payment html file at

app/code/Test/Testpayment/view/frontend/web/template/payment/mypayment.html

You can add your custom html before <div class="actions-toolbar">

<div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}">
    <div class="payment-method-title field choice">
        <input type="radio"
               name="payment[method]"
               class="radio"
               data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"/>
        <label data-bind="attr: {'for': getCode()}" class="label"><span data-bind="text: getTitle()"></span></label>
    </div>
    <div>ADD YOUR HTML HERE</div>
    <div class="payment-method-content">
        <div class="actions-toolbar">
            <div class="primary">
                <button class="action primary checkout"
                        type="submit"
                        data-bind="
                        click: placeOrder,
                        attr: {title: $t('Place Order')},
                        css: {disabled: !isPlaceOrderActionAllowed()},
                        enable: (getCode() == isChecked())
                        "
                        disabled>
                    <span data-bind="i18n: 'Place Order'"></span>
                </button>
            </div>
        </div>
    </div>
</div>

Now remove static payment template file from pub/static/frontend/vendor/theme/en_US/Vendor_Module/template/payment

Flush cache and try....!

OUTPUT:

enter image description here

Related Topic