function onAfterOrderConfirm(&$order, &$methods, $method_id) { parent::onAfterOrderConfirm($order, $methods, $method_id); require_once dirname(__FILE__) . '/library/sofortLib.php'; $viewType = 'end'; if (empty($this->payment_params->return_url)) { $return_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id=' . $order->order_id . $this->url_itemid; } else { $return_url = $this->payment_params->return_url; } $notify_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=checkout&task=notify¬if_payment=' . $this->name . '&tmpl=component&lang=nl'; if (empty($this->payment_params->cancel_url)) { $cancel_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=order&task=cancel_order'; } else { $cancel_url = $this->payment_params->cancel_url; } $configkey = $this->payment_params->user_id . ':' . $this->payment_params->project_id . ':' . $this->payment_params->token; $amount = round($order->cart->full_total->prices[0]->price_value_with_tax, (int) $this->currency->currency_locale['int_frac_digits']); $order_text = "\r\n" . JText::sprintf('betaling Feeen en ridders: order ', $order->order_id); $transactionId = 0; $Sofort = new SofortLib_Multipay($configkey); $Sofort->setSofortueberweisung(); $Sofort->setAmount($amount, $this->currency->currency_code); $Sofort->setReason($order_text); $Sofort->addUserVariable($order->order_id); $Sofort->setSofortrechnungOrderId($order->order_id); $Sofort->addUserVariable($method_id); $Sofort->setSuccessUrl($return_url); $Sofort->setAbortUrl($cancel_url); $Sofort->setTimeoutUrl($cancel_url); $Sofort->setNotificationUrl($notify_url); $Sofort->sendRequest(); if ($Sofort->isError()) { echo $Sofort->getError(); return false; } else { $this->redirect_url = $Sofort->getPaymentUrl(); } return $this->showPage('end'); }
/** * create the connection class and add order info * * @param Mage_Sales_Model_Order_Item $order * @param string $security key for information */ public function createPaymentFromOrder($order, $security = null) { // check if security key is given if ($security === null) { // get existing security key $security = $order->getPayment()->getAdditionalInformation('sofort_secret'); // generate new one if (empty($security)) { $security = $this->getSecurityKey(); } } // create new object $sObj = new SofortLib_Multipay(Mage::getStoreConfig('payment/sofort/configkey')); $sObj->setVersion(self::MODULE_VERSION); // set type $sObj->setSofortrechnung(); // basic information $sObj->addUserVariable($order->getRealOrderId()); $sObj->setEmailCustomer($order->getCustomerEmail()); $sObj->setSofortrechnungCustomerId($order->getCustomerId()); $sObj->setSofortrechnungOrderId($order->getRealOrderId()); // add order number and shop name $reason1 = Mage::helper('pnsofortueberweisung')->__('Order No.: ') . $order->getRealOrderId(); $reason1 = preg_replace('#[^a-zA-Z0-9+-\\.,]#', ' ', $reason1); $reason2 = Mage::getStoreConfig('general/store_information/name'); $reason2 = preg_replace('#[^a-zA-Z0-9+-\\.,]#', ' ', $reason2); $sObj->setReason($reason1, $reason2); // set amount $amount = number_format($order->getGrandTotal(), 2, '.', ''); $sObj->setAmount($amount, $order->getOrderCurrencyCode()); // setup urls $success_url = Mage::getUrl('pnsofortueberweisung/sofort/return', array('orderId' => $order->getRealOrderId(), '_secure' => true)); $cancel_url = Mage::getUrl('pnsofortueberweisung/sofort/error', array('orderId' => $order->getRealOrderId())); $notification_url = Mage::getUrl('pnsofortueberweisung/sofort/notification', array('orderId' => $order->getRealOrderId(), 'secret' => $security)); $sObj->setSuccessUrl($success_url); $sObj->setAbortUrl($cancel_url); $sObj->setNotificationUrl($notification_url); // items, shipping, discount $this->_appendItems($order, $sObj); // invoice address $address = $order->getBillingAddress(); $sObj->setSofortrechnungInvoiceAddress($this->_getFirstname($address), $this->_getLastname($address), $this->_getStreet($address), $this->_getNumber($address), $this->_getPostcode($address), $this->_getCity($address), $this->_getSalutation($address), $this->_getCountry($address), $this->_getNameAdditive($address), $this->_getStreetAdditive($address), $this->_getCompany($address)); // shipping address $address = $order->getShippingAddress(); $sObj->setSofortrechnungShippingAddress($this->_getFirstname($address), $this->_getLastname($address), $this->_getStreet($address), $this->_getNumber($address), $this->_getPostcode($address), $this->_getCity($address), $this->_getSalutation($address), $this->_getCountry($address), $this->_getNameAdditive($address), $this->_getStreetAdditive($address), $this->_getCompany($address)); return $sObj; }