public static function fromOrder($order) { $orderContext = new Customweb_SaferpayCw_Model_OrderContext($order->getPayment()->getMethodInstance(), true, $order->getStore()->getStoreId()); $orderContext->setOrder($order); if ($orderContext->useBaseCurrency()) { $orderContext->currencyCode = $order->getBaseCurrencyCode(); } else { $orderContext->currencyCode = $order->getOrderCurrencyCode(); } return $orderContext; }
/** * @param Mage_Sales_Model_Order $order * @param Customweb_SaferpayCw_Model_Transaction $transaction * @param string $backendSuccessUrl * @param string $backendFailUrl * @return Customweb_SaferpayCw_Model_TransactionContext */ public function getMotoTransactionContext(Mage_Sales_Model_Order $order, Customweb_SaferpayCw_Model_Transaction $transaction) { $storeId = $order->getStore()->getId(); $orderContext = Customweb_SaferpayCw_Model_OrderContext::fromOrder($order); $backendSuccessUrl = Mage::getModel('adminhtml/url')->getUrl('adminhtml/motosaferpaycw/success', array('order_id' => $order->getId())); $backendFailUrl = Mage::getModel('adminhtml/url')->getUrl('adminhtml/motosaferpaycw/fail', array('order_id' => $order->getId())); $transactionContext = new Customweb_SaferpayCw_Model_TransactionContext($orderContext, $order->getIncrementId(), $transaction->getId(), $this->getHelper()->getPaymentCustomerContext(), null, $backendSuccessUrl, $backendFailUrl, $storeId); $transactionContext->setMotoTransaction(true); $result = new StdClass(); $result->transactionContext = $transactionContext; Mage::dispatchEvent('customweb_payment_create_transcation_context', array('result' => $result, 'order' => $order)); return $result->transactionContext; }