2

We have created custom payment method. The method contains inputs etc in its form.phtml file. In checkout, we get to Payment methods and our method is checked, but its form is not visible until we check it again. We can click continue, but it throws exception that we need to fill those inputs. However, user does not see them so he'll be confused.

Real situation Expected situation

Do we need to add any property?

Jakub Gruber
  • 745
  • 1
  • 11
  • 27

1 Answers1

0

Solution:

I added JS to form.phtml and it is working now.

var customMethodCheckbox document.getElementById("p_method_custom_method");
var customForm = document.getElementById("payment_form_<?php echo $this->getMethodCode() ?>");

if(customMethodCheckbox.checked){
    customForm.style.display = "";
}

Once form.phtml is loaded, it triggers this JS. If custom payment method is checked as default, it removes display: none attribute from custom form and displays it. And you don't need to worry about changing payment methods etc, because it is solved by Magento.

Jakub Gruber
  • 745
  • 1
  • 11
  • 27