/** * @param CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main|CRM_Core_Payment_ProcessorForm|CRM_Contribute_Form_UpdateBilling $form * @param array $processor * Array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors. * @param int|string $billing_profile_id * Id of a profile to be passed to the processor for the processor to merge with it's required fields. * (currently only implemented by manual/ pay-later processor) * * @param bool $isBackOffice * Is this a backoffice form. This could affect the display of the cvn or whether some processors show, * although the distinction is losing it's meaning as front end forms are used for back office and a permission * for the 'enter without cvn' is probably more appropriate. Paypal std does not support another user * entering details but once again the issue is not back office but 'another user'. * * @return bool */ public static function buildPaymentForm(&$form, $processor, $billing_profile_id, $isBackOffice) { //if the form has address fields assign to the template so the js can decide what billing fields to show $profileAddressFields = $form->get('profileAddressFields'); if (!empty($profileAddressFields)) { $form->assign('profileAddressFields', $profileAddressFields); } if (!empty($processor['object']) && $processor['object']->buildForm($form)) { return NULL; } self::setPaymentFieldsByProcessor($form, $processor, $billing_profile_id, $isBackOffice); self::addCommonFields($form, $form->_paymentFields); self::addRules($form, $form->_paymentFields); return !empty($form->_paymentFields); }
/** * Add the discount button immediately before the price set. * * @param CRM_Contribute_Form_Contribution_Main $form */ function _cividiscount_add_button_before_priceSet(&$form) { CRM_Core_Region::instance('price-set-1')->add(array('template' => 'CRM/CiviDiscount/discountButton.tpl', 'weight' => -1, 'type' => 'template', 'name' => 'discount_code')); $form->add('text', 'discountcode', ts('If you have a discount code, enter it here'), array('class' => 'description')); $errorMessage = $form->get('discountCodeErrorMsg'); if ($errorMessage) { $form->setElementError('discountcode', $errorMessage); } $form->set('discountCodeErrorMsg', null); $buttonName = $form->getButtonName('reload'); $form->addElement('submit', $buttonName, ts('Apply'), array('formnovalidate' => 1)); $form->assign('discountElements', array('discountcode', $buttonName)); }
/** * @param CRM_Contribute_Form_AbstractEditPayment|CRM_Contribute_Form_Contribution_Main|CRM_Core_Payment_ProcessorForm|CRM_Contribute_Form_UpdateBilling $form * @param array $processor * Array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors. * @param bool $isBillingDataOptional * This manifests for 'NULL' (pay later) payment processor as the addition of billing fields to the form and. * for payment processors that gather payment data on site as rendering the fields as not being required. (not entirely sure why but this * is implemented for back office forms) * * @return bool */ public static function buildPaymentForm(&$form, $processor, $isBillingDataOptional) { //if the form has address fields assign to the template so the js can decide what billing fields to show $profileAddressFields = $form->get('profileAddressFields'); if (!empty($profileAddressFields)) { $form->assign('profileAddressFields', $profileAddressFields); } // $processor->buildForm appears to be an undocumented (possibly unused) option for payment processors // which was previously available only in some form flows if (!empty($form->_paymentProcessor) && !empty($form->_paymentProcessor['object']) && $form->_paymentProcessor['object']->isSupported('buildForm')) { $form->_paymentProcessor['object']->buildForm($form); return NULL; } self::setPaymentFieldsByProcessor($form, $processor, empty($isBillingDataOptional)); self::addCommonFields($form, !$isBillingDataOptional, $form->_paymentFields); self::addRules($form, $form->_paymentFields); self::addPaypalExpressCode($form); return !empty($form->_paymentFields); }
/** * Implement buildForm hook to remove billing fields if elsewhere on the form. * * @param string $formName * @param CRM_Contribute_Form_Contribution_Main|CRM_Event_Form_Registration_Register $form */ function omnipaymultiprocessor_civicrm_buildForm($formName, &$form) { if ($formName == 'CRM_Admin_Form_PaymentProcessor') { foreach (array('signature', 'test_signature') as $fieldName) { if ($form->elementExists($fieldName)) { $label = $form->_elements[$form->_elementIndex[$fieldName]]->_label; $form->removeElement($fieldName); $form->add('textarea', $fieldName, $label, array('rows' => 4, 'cols' => 40)); } } } if (omnipaymultiprocessor__versionAtLeast(4.6)) { return; } if (!omnipaymultiprocessor_is_credit_card_form($formName) || $form->_paymentProcessor['class_name'] != 'Payment_OmnipayMultiProcessor') { return; } $paymentType = civicrm_api3('option_value', 'getsingle', array('value' => $form->_paymentProcessor['payment_type'], 'option_group_id' => 'payment_type')); $form->assign('paymentTypeName', $paymentType['name']); $paymentFields = omnipaymultiprocessor_get_valid_form_payment_fields($formName == 'CRM_Contribute_Form_Contribution_Main' ? 'contribute' : 'event', $form->_paymentProcessor, empty($form->_paymentFields) ? array() : $form->_paymentFields); if (!empty($paymentFields)) { $form->assign('paymentFields', $paymentFields); $form->assign('paymentTypeLabel', ts($paymentType['label'] . ' Information')); } else { $form->assign('paymentFields', NULL); $form->assign('paymentTypeLabel', NULL); } $billingDetailsFields = omnipaymultiprocessor_getBillingPersonalDetailsFields($form->_paymentProcessor); //we trick CiviCRM into adding the credit card form so we can remove the parts we don't want (the credit card fields) //for a transparent redirect like Cybersource $billingMode = $form->_paymentProcessor['billing_mode']; $form->_paymentProcessor['billing_mode'] = CRM_Core_Payment::BILLING_MODE_FORM; CRM_Core_Payment_Form::buildCreditCard($form); $form->_paymentProcessor['billing_mode'] = $billingMode; //CiviCRM assumes that if it is Not a credit card it MUST be a direct debit & makes those required $suppressedFields = omnipaymultiprocessor_get_suppressed_billing_fields((array) $billingDetailsFields, (array) $paymentFields, (array) $form->_paymentFields); foreach ($suppressedFields as $suppressedField) { $form->_paymentFields[$suppressedField]['is_required'] = FALSE; } $form->assign('suppressedFields', $suppressedFields); $form->assign('billingDetailsFields', $billingDetailsFields); CRM_Core_Region::instance('billing-block')->update('default', array('disabled' => TRUE)); CRM_Core_Region::instance('billing-block')->add(array('template' => 'SubstituteBillingBlock.tpl')); }