Пример #1
0
 /**
  * Get or create a transaction for the given order.
  *
  * @param Mage_Sales_Model_Order $order
  * @return Object
  */
 private function createTransaction(Mage_Sales_Model_Order $order)
 {
     $payment = new Customweb_Subscription_Model_Method($order->getPayment()->getMethodInstance(), $this->getSubscription());
     try {
         $transaction = $payment->getHelper()->loadTransactionByOrder($order->getId());
     } catch (Exception $e) {
         $transaction = $payment->createTransaction($order);
     }
     return $transaction;
 }
Пример #2
0
 /**
  * Update subscription after the payment is processed.
  *
  * @param Varien_Event_Observer $observer
  */
 public function onAfterProcess(Varien_Event_Observer $observer)
 {
     $order = $observer->getEvent()->getOrder();
     $parameters = $observer->getEvent()->getParameters();
     if (isset($parameters['cwsubscriptionid'])) {
         $subscription = Mage::getModel('customweb_subscription/subscription')->load($parameters['cwsubscriptionid']);
         $payment = new Customweb_Subscription_Model_Method($order->getPayment()->getMethodInstance(), $subscription);
         $payment->afterProcess($order, $parameters);
     }
 }
 /**
  * Redirect the customer to the widget page.
  */
 public function widgetAction()
 {
     if (!$this->_loadValidSubscription()) {
         return;
     }
     $subscription = Mage::registry('current_subscription');
     $transaction = $this->createOrder($subscription);
     $payment = new Customweb_Subscription_Model_Method($subscription->getMethodInstance(), $subscription);
     $this->loadLayout();
     $this->getLayout()->getBlock('head')->addCss('css/customweb.css');
     $this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
     $widgetBlock = $this->getLayout()->createBlock('Mage_Core_Block_Template', 'widget', array('template' => 'customweb/subscription/payment/widget.phtml'));
     $widgetBlock->setWidgetHtml($payment->getWidgetHtml($transaction, $_REQUEST));
     $this->getLayout()->getBlock('content')->append($widgetBlock);
     $this->renderLayout();
 }