_order) { $this->_order = $this->getInfoInstance()->getOrder(); } return $this->_order; } /** * Return url for redirection after order placed * @return string */ public function getOrderPlaceRedirectUrl() { return Mage::getUrl('moneybookers/processing/payment'); } /** * Capture payment through Moneybookers api * * @param Varien_Object $payment * @param decimal $amount * @return Phoenix_Moneybookers_Model_Abstract */ public function capture(Varien_Object $payment, $amount) { $payment->setStatus(self::STATUS_APPROVED) ->setTransactionId($this->getTransactionId()) ->setIsTransactionClosed(0); return $this; } /** * Camcel payment * * @param Varien_Object $payment * @return Phoenix_Moneybookers_Model_Abstract */ public function cancel(Varien_Object $payment) { $payment->setStatus(self::STATUS_DECLINED) ->setTransactionId($this->getTransactionId()) ->setIsTransactionClosed(1); return $this; } /** * Return url of payment method * * @return string */ public function getUrl() { return 'https://www.moneybookers.com/app/payment.pl'; } /** * Return url of payment method * * @return string */ public function getLocale() { $locale = explode('_', Mage::app()->getLocale()->getLocaleCode()); if (is_array($locale) && !empty($locale) && in_array($locale[0], $this->_supportedLocales)) { return $locale[0]; } return $this->getDefaultLocale(); } /** * prepare params array to send it to gateway page via POST * * @return array */ public function getFormFields() { $order_id = $this->getOrder()->getRealOrderId(); $billing = $this->getOrder()->getBillingAddress(); if ($this->getOrder()->getBillingAddress()->getEmail()) { $email = $this->getOrder()->getBillingAddress()->getEmail(); } else { $email = $this->getOrder()->getCustomerEmail(); } $params = array( 'merchant_fields' => 'partner', 'partner' => 'magento', 'pay_to_email' => Mage::getStoreConfig(Phoenix_Moneybookers_Helper_Data::XML_PATH_EMAIL), 'transaction_id' => $order_id, 'return_url' => Mage::getUrl('moneybookers/processing/success', array('transaction_id' => $order_id)), 'cancel_url' => Mage::getUrl('moneybookers/processing/cancel', array('transaction_id' => $order_id)), 'status_url' => Mage::getUrl('moneybookers/processing/status'), 'language' => $this->getLocale(), 'amount' => round($this->getOrder()->getGrandTotal(), 2), 'currency' => $this->getOrder()->getOrderCurrencyCode(), 'recipient_description' => $this->getOrder()->getStore()->getWebsite()->getName(), 'firstname' => $billing->getFirstname(), 'lastname' => $billing->getLastname(), 'address' => $billing->getStreet(-1), 'postal_code' => $billing->getPostcode(), 'city' => $billing->getCity(), 'country' => $billing->getCountryModel()->getIso3Code(), 'pay_from_email' => $email, 'phone_number' => $billing->getTelephone(), 'detail1_description' => Mage::helper('moneybookers')->__('Order ID'), 'detail1_text' => $order_id, 'payment_methods' => $this->_paymentMethod, 'hide_login' => $this->_hidelogin, 'new_window_redirect' => '1' ); // add optional day of birth if ($billing->getDob()) { $params['date_of_birth'] = Mage::app()->getLocale()->date($billing->getDob(), null, null, false)->toString('dmY'); } return $params; } /** * Get initialized flag status * @return true */ public function isInitializeNeeded() { return true; } /** * Instantiate state and set it to state onject * //@param * //@param */ public function initialize($paymentAction, $stateObject) { $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT; $stateObject->setState($state); $stateObject->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT); $stateObject->setIsNotified(false); } /** * Get config action to process initialization * * @return string */ public function getConfigPaymentAction() { $paymentAction = $this->getConfigData('payment_action'); return empty($paymentAction) ? true : $paymentAction; } }