+ * @return bool
+ */
+ static function buildPaymentForm($form, $processor, $isBillingDataOptional){
+ self::setPaymentFieldsByProcessor($form, $processor);
+ self::addCommonFields($form, !$isBillingDataOptional, $form->_paymentFields);
+ self::addRules($form, $form->_paymentFields);
+ self::addPaypalExpressCode($form);
+ return (!empty($form->_paymentFields));
+ }
+
+ /**
+ * @param CRM_Core_Form $form
+ * @param array $paymentFields array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors
+
+ * @param $paymentFields
+ */
+ protected static function addRules(&$form, $paymentFields) {
+ foreach ($paymentFields as $paymentField => $fieldSpecs) {
+ if (!empty($fieldSpecs['rules'])) {
+ foreach ($fieldSpecs['rules'] as $rule) {
+ $form->addRule($paymentField,
+ $rule['rule_message'],
+ $rule['rule_name'],
+ $rule['rule_parameters']
+ );
+ }
+ }
+ }
+ }
+
+ /**
+ * billing mode button is basically synonymous with paypal express - this is probably a good example of 'odds & sods' code we
+ * need to find a way for the payment processor to assign. A tricky aspect is that the payment processor may need to set the order
+ *
+ * @param $form
+ */
+ protected static function addPaypalExpressCode(&$form) {
+ if ($form->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) {
+ $form->_expressButtonName = $form->getButtonName('upload', 'express');
+ $form->assign('expressButtonName', $form->_expressButtonName);
+ $form->add('image',
+ $form->_expressButtonName,
+ $form->_paymentProcessor['url_button'],
+ array('class' => 'crm-form-submit')
+ );
+ }
+ }
+ /**
+ * Function to add all the credit card fields
+ * @deprecated Use BuildPaymentForm