function iats_civicrm_buildForm_Contribution_Frontend(&$form) { if (empty($form->_paymentProcessors)) { return; } $acheft = iats_civicrm_processors($form->_paymentProcessors, 'ACHEFT'); $swipe = iats_civicrm_processors($form->_paymentProcessors, 'SWIPE'); $ukdd = iats_civicrm_processors($form->_paymentProcessors, 'UKDD'); // include the required javascripts for available customized selections // TODO: skip this if we're just loading a fragment of the page via ajax // If a form allows ACH/EFT and enables recurring, set recurring to the default if (0 < count($acheft)) { CRM_Core_Resources::singleton()->addScriptFile('com.iatspayments.civicrm', 'js/dd_acheft.js', 10, 'html-header'); // country specific js needs to be loaded here so it's available later CRM_Core_Resources::singleton()->addScriptFile('com.iatspayments.civicrm', 'js/dd_cad.js', 10, 'html-header'); if (isset($form->_elementIndex['is_recur'])) { $form->setDefaults(array('is_recur' => 1)); // make recurring contrib default to true } } if (0 < count($swipe)) { CRM_Core_Resources::singleton()->addScriptFile('com.iatspayments.civicrm', 'js/swipe.js', 10, 'html-header'); } if (0 < count($ukdd)) { CRM_Core_Resources::singleton()->addScriptFile('com.iatspayments.civicrm', 'js/dd_uk.js', 10, 'html-header'); if (isset($form->_elementIndex['is_recur'])) { $form->setDefaults(array('is_recur' => 1)); // make recurring contrib default to true } } /* Mangle (in a currency-dependent way) the ajax-bit of the form if I've just selected an ach/eft option */ if (!empty($acheft[$form->_paymentProcessor['id']])) { iats_acheft_form_customize($form); // watchdog('iats_acheft',kprint_r($form,TRUE)); } /* now something similar for swipe */ if (!empty($swipe[$form->_paymentProcessor['id']]) && !empty($form->_elementIndex['credit_card_exp_date'])) { iats_swipe_form_customize($form); } /* UK Direct debit option */ if (!empty($ukdd[$form->_paymentProcessor['id']])) { iats_ukdd_form_customize($form); // watchdog('iats_acheft',kprint_r($form,TRUE)); } /* and finally, for most frontend forms, use the dpm.js script to use the DirectPost Method override * TODO: provide an admin way to prevent this * TODO: use it for swipe, never for ukdd? */ require_once "CRM/iATS/iATSService.php"; if (iATS_Service_Request::isDPM($form->_paymentProcessor)) { CRM_Core_Region::instance('billing-block')->add(array('template' => 'CRM/iATS/BillingBlockDPM.tpl')); $iats_domain = parse_url($form->_paymentProcessor['url_site'], PHP_URL_HOST); $dpm_url = iATS_Service_Request::dpm_url($iats_domain); _iats_civicrm_varset(array('dpmURL' => $dpm_url)); CRM_Core_Resources::singleton()->addScriptFile('com.iatspayments.civicrm', 'js/dpm.js'); } }