Exemplo n.º 1
0
 protected function _beforeToHtml()
 {
     $container = Mage::helper('SaferpayCw')->createContainer();
     if ($container->hasBean('Customweb_Payment_BackendOperation_Form_IAdapter')) {
         /* @var $adapter Customweb_Payment_BackendOperation_Form_IAdapter */
         $adapter = $container->getBean('Customweb_Payment_BackendOperation_Form_IAdapter');
         foreach ($adapter->getForms() as $form) {
             $form = new Customweb_Payment_BackendOperation_Form($form);
             if ($form->isProcessable()) {
                 $form->setTargetUrl($this->getUrl('*/*/save', array('tab' => $form->getMachineName(), '_current' => true)))->setRequestMethod(Customweb_IForm::REQUEST_METHOD_POST);
             }
             $this->addTab($form->getMachineName(), array('label' => $form->getTitle(), 'title' => $form->getTitle(), 'content' => $this->getLayout()->createBlock('saferpaycw/adminhtml_backendForm_form')->setForm($form)->toHtml()));
         }
     }
     $this->_updateActiveTab();
     return parent::_beforeToHtml();
 }
Exemplo n.º 2
0
 public function generateMotoForm(Mage_Sales_Model_Order $order, Customweb_SaferpayCw_Model_Transaction $transaction, $parameters)
 {
     $adapter = $this->getHelper()->getAuthorizationAdapter(Customweb_Payment_Authorization_Moto_IAdapter::AUTHORIZATION_METHOD_NAME);
     $failedTransaction = $this->loadFailedTransaction();
     $paymentCustomerContext = $this->getHelper()->getPaymentCustomerContext($order->getCustomerId());
     $formFields = $adapter->getVisibleFormFields($transaction->getTransactionObject()->getTransactionContext()->getOrderContext(), null, $failedTransaction, $paymentCustomerContext);
     $formActionUrl = $adapter->getFormActionUrl($transaction->getTransactionObject(), $parameters);
     $hiddenFields = $adapter->getParameters($transaction->getTransactionObject(), $parameters);
     $paymentCustomerContext->persist();
     $transaction->save();
     $form = new Customweb_Payment_BackendOperation_Form();
     $form->setMachineName('moto_form');
     $form->setTargetUrl($formActionUrl);
     $form->setRequestMethod('POST');
     $form->setTitle($this->getHelper()->__('Mail order/telephone order authorization'));
     foreach ($formFields as $formField) {
         $form->addElement($formField);
     }
     foreach ($hiddenFields as $key => $value) {
         if (is_array($value)) {
             foreach ($value as $val) {
                 $form->addElement(new Customweb_Form_HiddenElement(new Customweb_Form_Control_HiddenInput($key . '[]', $val)));
             }
         } else {
             $form->addElement(new Customweb_Form_HiddenElement(new Customweb_Form_Control_HiddenInput($key, $value)));
         }
     }
     $button = new Customweb_Form_Button();
     $button->setMachineName('submit');
     $button->setTitle($this->getHelper()->__('Continue'));
     $form->addButton($button);
     $renderer = new Customweb_SaferpayCw_Model_BackendFormRenderer();
     $renderer->setShowScope(false);
     $result = $renderer->renderForm($form);
     return $result;
 }