public function processPaymentAction()
 {
     $session = new Zend_Session_Namespace('referencing_global');
     $params = Zend_Registry::get('params');
     $remotePassword = $params->secpay->get('remotepassword');
     $referenceManager = new Manager_Referencing_Reference();
     $reference = $referenceManager->getReference($session->referenceId);
     $productSelectionManager = new Manager_Referencing_ProductSelection();
     $price = $productSelectionManager->getPrice($reference->productSelection);
     $amount = $price->getValue() * $params->vat->reversed;
     $pageForm = new TenantsInsuranceQuote_Form_Subforms_CreditCard();
     $this->view->secFormUrl = $params->secpay->get('host');
     $this->view->merchant = $params->secpay->get('merchant');
     $this->view->trans_id = $reference->externalId;
     $this->view->refno = $reference->externalId;
     $this->view->amount = $amount;
     $this->view->callback = $params->secpay->reference->get('success_callback') . ";" . $params->secpay->reference->get('failed_callback');
     $this->view->template = $params->secpay->reference->get('template');
     $this->view->repeat = $params->secpay->get('repeat');
     $this->view->test_status = $params->secpay->get('test_status');
     $this->view->test_mpi_status = $params->secpay->get('test_mpi_status');
     $this->view->usage_type = $params->secpay->get('usage_type');
     $this->view->cb_flds = "refno:card_type:policynumber:paymentfrequency";
     $this->view->cb_card_type = "";
     $digestkey = md5($reference->externalId . $amount . $remotePassword);
     $this->view->digest = $digestkey;
     $this->view->confirmationcode = "";
     $this->view->dups = "";
     $this->view->fractionComplete = 100;
     // Clear the session as we're off for payment
     $this->_partiallyClearSession();
 }
 public function saveData()
 {
     $session = new Zend_Session_Namespace('referencing_global');
     $data = $this->getValues();
     $referenceManager = new Manager_Referencing_Reference();
     $reference = $referenceManager->getReference($session->referenceId);
     // Update the completion method (complete now, or email link to tenant).
     $reference->completionMethod = $data['completion_method'];
     // Update the reference subject.
     if (empty($reference->referenceSubject)) {
         $referenceSubjectManager = new Manager_Referencing_ReferenceSubject();
         $reference->referenceSubject = $referenceSubjectManager->insertPlaceholder($session->referenceId);
     }
     // Reference subject name details
     if (empty($reference->referenceSubject->name)) {
         $nameManager = new Manager_Core_Name();
         $reference->referenceSubject->name = $nameManager->createName();
     }
     $reference->referenceSubject->name->title = $data['personal_title'];
     $reference->referenceSubject->name->firstName = $data['first_name'];
     $reference->referenceSubject->name->lastName = $data['last_name'];
     //Reference subject contact details
     if (empty($reference->referenceSubject->contactDetails)) {
         $contactDetailsManager = new Manager_Core_ContactDetails();
         $reference->referenceSubject->contactDetails = $contactDetailsManager->createContactDetails();
     }
     $reference->referenceSubject->contactDetails->email1 = $data['email'];
     //Misc details.
     $reference->referenceSubject->type = Model_Referencing_ReferenceSubjectTypes::TENANT;
     $reference->referenceSubject->shareOfRent = new Zend_Currency(array('value' => $data['share_of_rent'], 'precision' => 0));
     //Product details.
     if (empty($reference->productSelection)) {
         $productSelectionManager = new Manager_Referencing_ProductSelection();
         $reference->productSelection = $productSelectionManager->insertPlaceholder($session->referenceId);
     }
     $productDatasource = new Datasource_Referencing_Product();
     $reference->productSelection->product = $productDatasource->getById($data['product_choice']);
     if (empty($data['product_duration'])) {
         $reference->productSelection->duration = 0;
     } else {
         $reference->productSelection->duration = $data['product_duration'];
     }
     // And update...
     $referenceManager->updateReference($reference);
     // Ensure the product selection by the user is updated in the session, ensuring correct
     // navigations...
     $session->productName = $reference->productSelection->product->key;
 }