Merge pull request #6293 from JoeMurray/patch-1
[civicrm-core.git] / CRM / Financial / Form / Payment.php
index 9d8ad34e6a34b3a7c23534c9745b2c53c497f753..b788fc9be1b2b92dbaed741de0ee6112dcacbea0 100644 (file)
  *
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
  */
 class CRM_Financial_Form_Payment extends CRM_Core_Form {
   /**
    * Set variables up before form is built.
-   *
-   * @return void
    */
   public function preProcess() {
     parent::preProcess();
@@ -45,29 +41,40 @@ class CRM_Financial_Form_Payment extends CRM_Core_Form {
 
     $this->assignBillingType();
 
-    // @todo - round about way to load it - just load as an object using civi\payment\system::getByProcessor
-    $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_paymentProcessorID, 'unused');
+    $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_paymentProcessorID);
     CRM_Core_Payment_ProcessorForm::preProcess($this);
 
-    //@todo - figure out how to deal with payment express.
-    //get payPal express id and make it available to template
-    //$payPalExpressId = ($values['payment_processor_type'] == 'PayPal_Express') ? $values['id'] : 0;
-    // $this->assign('payPalExpressId', $payPalExpressId);
+    self::addCreditCardJs();
+
+    $this->assign('paymentProcessorID', $this->_paymentProcessorID);
+
+    $this->assign('suppressForm', TRUE);
+    $this->controller->_generateQFKey = FALSE;
+  }
+
+  public function buildQuickForm() {
+    CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
+  }
 
-    // Add JS to show icons for the accepted credit cards
+  /**
+   * Set default values for the form.
+   */
+  public function setDefaultValues() {
+    $contactID = $this->getContactID();
+    CRM_Core_Payment_Form::setDefaultValues($this, $contactID);
+    return $this->_defaults;
+  }
 
+  /**
+   * Add JS to show icons for the accepted credit cards
+   */
+  public static function addCreditCardJs() {
     $creditCardTypes = CRM_Core_Payment_Form::getCreditCardCSSNames();
     CRM_Core_Resources::singleton()
       ->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10)
       // workaround for CRM-13634
       // ->addSetting(array('config' => array('creditCardTypes' => $creditCardTypes)));
       ->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';');
-
-    $this->assign('paymentProcessorID', $this->_paymentProcessorID);
-  }
-
-  public function buildQuickForm() {
-    CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
   }
 
 }