4

So I understand that you can assign a payment processor any payment method - however - I am trying to create payment methods that replicate the behavior of Credit Card and Check. For example - when manually adding Check or Credit Card contributions - you will then get a field for check number or last 4 digits of the card respectively.

If I make a payment method called credit card - other, I would want those credit card fields to also populate.

Is this hard coded?

1 Answer 1

4

Themak, Nice question. This are hardcoded in core file but you can create your own field for each payment method using buildform hook. Here is the snippet on how to do that

function custom_civicrm_buildForm($formName, &$form) {
  if ($formName == 'CRM_Financial_Form_Payment' && !empty($form->paymentInstrumentID)) {
    if ($form->paymentInstrumentID == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Test')) {
      $form->assign('paymentFields', array('source'));
      $form->add('text', 'source', ts('Source'));
    }
  }
}

Note: The above snippet is not fully tested i have just created blindly, but i am 100% sure it should work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.