コード例 #1
0
 /**
  * returns Url to redirect for payment or error
  * 
  * @return string
  */
 public function getUrl()
 {
     // get order
     $order = $this->getOrder();
     // basic setup
     $sofort = new SofortLib_iDealClassic(Mage::getStoreConfig('payment/sofort_ideal/configkey'), Mage::getStoreConfig('payment/sofort_ideal/password'), 'sha1');
     $sofort->setVersion(self::MODULE_VERSION);
     // add amount
     $amount = number_format($order->getGrandTotal(), 2, '.', '');
     $sofort->setAmount($amount, $order->getOrderCurrencyCode());
     // add reason
     $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);
     $sofort->setReason($reason1, $reason2);
     // setup urls
     $success_url = Mage::getUrl('pnsofortueberweisung/sofort/return', array('orderId' => $order->getRealOrderId(), '_secure' => true));
     $success_url = preg_replace('/^http(s?):\\/\\//', '', $success_url);
     $cancel_url = Mage::getUrl('pnsofortueberweisung/sofort/error', array('orderId' => $order->getRealOrderId()));
     $cancel_url = preg_replace('/^http(s?):\\/\\//', '', $cancel_url);
     $notification_url = Mage::getUrl('pnsofortueberweisung/sofort/notificationIdeal', array('orderId' => $order->getRealOrderId()));
     $notification_url = preg_replace('/^http(s?):\\/\\//', '', $notification_url);
     $sofort->setSuccessUrl($success_url);
     $sofort->setAbortUrl($cancel_url);
     $sofort->setNotificationUrl($notification_url);
     // setup bank information
     $sofort->setSenderCountryId('NL');
     $sofort->setSenderBankCode(Mage::getSingleton('core/session')->getIdealBankCode());
     $sofort->setSenderHolder(Mage::getSingleton('core/session')->getIdealHolder());
     $sofort->setSenderAccountNumber(Mage::getSingleton('core/session')->getIdealAccountNumber());
     return $sofort->getPaymentUrl();
 }