CRM-15555 QA fix - ensure email always assigned
[civicrm-core.git] / CRM / Core / Payment / Form.php
index ee191dbc2e72edb96412fc337406768a05386fee..34cff2171afe6a21d28a39a0ccc3d01ee40ecb62 100644 (file)
  */
 class CRM_Core_Payment_Form {
 
-  /**
-   * Add payment fields are depending on payment type
-   * @deprecated  - use the setPaymentFieldsByPaymentType which leverages the processor to determine the fields
-   * @param int $type eg CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT
-   * @param CRM_Core_Form $form
-   */
-  static public function setPaymentFieldsByType($type, &$form) {
-    if ($type & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
-      CRM_Core_Payment_Form::setDirectDebitFields($form);
-    }
-    else {
-      CRM_Core_Payment_Form::setCreditCardFields($form);
-    }
-  }
-
 
   /**
-   * Add payment fields are depending on payment type
+   * Add payment fields are depending on payment processor
    *
-   * @param CRM_Core_Form $form
+   * @param CRM_Contribute_Form_Contribution| CRM_Contribute_Form_Contribution_Main $form
+   * @todo - add other forms specifically to the definition - since we don't have for $form - since we aren't adding the property to
+   * CRM_Core_Form (don't suppose we should?)
    * @param array $processor array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors
    */
   static public function setPaymentFieldsByProcessor(&$form, $processor) {
     $form->billingFieldSets = array();
     $paymentFields = self::getPaymentFields($processor);
-    dpm($paymentFields);
     $paymentTypeName = self::getPaymentTypeName($processor);
     $paymentTypeLabel = self::getPaymentTypeLabel($processor);
     //@todo if we switch to iterating through the fieldsets we won't need to assign these directly
@@ -71,14 +57,18 @@ class CRM_Core_Payment_Form {
     $form->assign('paymentFields', $paymentFields);
     if ($processor['billing_mode'] != 4) {
       //@todo setPaymentFields defines the billing fields - this should be moved to the processor class & renamed getBillingFields
+      // currently we just add the standard lot unless it's an off-site processor (& then add none)
       //also set the billingFieldSet to hold all the details required to render the fieldset so we can iterate through the fieldset - making
       // it easier to re-order. For not the billingFieldSets param is used to determine whether to show the billing pane
       CRM_Core_Payment_Form::_setPaymentFields($form);
       $form->billingFieldSets['billing_name_address-group']['fields'] = array();
     }
   }
+
   /**
-   * create all common fields needed for a credit card or direct debit transaction
+   * add general billing fields
+   * @todo set these like processor fields & let payment processors alter them
+   *
    *
    * @param $form
    *
@@ -176,7 +166,7 @@ class CRM_Core_Payment_Form {
 
   /**
    * create all fields needed for a credit card transaction
-   * @deprecated  - use the setPaymentFieldsByPaymentType which leverages the processor to determine the fields
+   * @deprecated  - use the setPaymentFieldsByProcessor which leverages the processor to determine the fields
    * @param CRM_Core_Form $form
    *
    * @return void
@@ -238,7 +228,7 @@ class CRM_Core_Payment_Form {
    * @param bool $useRequired
    * @param array $paymentFields
    */
-  static function addCommonFields(&$form, $useRequired, $paymentFields) {
+  protected static function addCommonFields(&$form, $useRequired, $paymentFields) {
     foreach ($paymentFields as $name => $field) {
       if (!empty($field['cc_field'])) {
         if ($field['htmlType'] == 'chainSelect') {
@@ -258,7 +248,7 @@ class CRM_Core_Payment_Form {
 
   /**
    * create all fields needed for direct debit transaction
-   * @deprecated  - use the setPaymentFieldsByPaymentType which leverages the processor to determine the fields
+   * @deprecated  - use the setPaymentFieldsByProcessor which leverages the processor to determine the fields
    * @param $form
    *
    * @return void
@@ -356,7 +346,7 @@ class CRM_Core_Payment_Form {
   }
 
   /**
-   * @param CRM_Core_Form $form
+   * @param CRM_Contribute_Form_Contribution| CRM_Contribute_Form_Contribution_Main|CRM_Member_Form_Membership $form
    * @param array $processor array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors
    * @param bool $isBillingDataOptional
    *
@@ -376,7 +366,7 @@ class CRM_Core_Payment_Form {
 
    * @param $paymentFields
    */
-  static function addRules(&$form, $paymentFields) {
+  protected static function addRules(&$form, $paymentFields) {
     foreach ($paymentFields as $paymentField => $fieldSpecs) {
       if (!empty($fieldSpecs['rules'])) {
         foreach ($fieldSpecs['rules'] as $rule) {
@@ -396,7 +386,7 @@ class CRM_Core_Payment_Form {
    *
    * @param $form
    */
-  static function addPaypalExpressCode(&$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);
@@ -465,6 +455,7 @@ class CRM_Core_Payment_Form {
 
   /**
    * Function to add all the direct debit fields
+   * @deprecated use buildPaymentForm
    *
    * @param $form
    * @param bool $useRequired
@@ -607,7 +598,7 @@ class CRM_Core_Payment_Form {
   /**
    * function to get the credit card expiration year
    * The date format for this field should typically be "M Y" (ex: Feb 2011) or "m Y" (02 2011)
-   * This function exists only to make it consistant with getCreditCardExpirationMonth
+   * This function exists only to make it consistent with getCreditCardExpirationMonth
    *
    * @param $src
    *