Esempio n. 1
0
 /**
  * Executes the pay request to sofort
  */
 public function paymentRequest()
 {
     $orderId = $this->_getQuote()->getReservedOrderId();
     $this->_sofortSdk->setVersion('magento_3.0');
     $this->_sofortSdk->setAmount(Mage::app()->getStore()->roundPrice($this->_getQuote()->getGrandTotal()));
     $this->_sofortSdk->setCurrencyCode($this->_getQuote()->getBaseCurrencyCode());
     $this->_sofortSdk->setReason($this->_getReasonOne(), $this->_getReasonTwo());
     $this->_sofortSdk->setSuccessUrl(Mage::getUrl('pisofort/payment/success', array('orderId' => $orderId)), true);
     $this->_sofortSdk->setAbortUrl(Mage::getUrl('pisofort/payment/abort', array('orderId' => $orderId)));
     $this->_sofortSdk->setNotificationUrl(Mage::getUrl('pisofort/payment/notification', array('orderId' => $orderId)));
     $this->_sofortSdk->setCustomerprotection((bool) Mage::getStoreConfig('payment/paymentnetwork_pnsofortueberweisung/customer_protection', Mage::app()->getStore()->getStoreId()));
     $this->_sofortSdk->sendRequest();
 }
 public function getUrl()
 {
     $order = $this->getOrder();
     $amount = number_format($order->getGrandTotal(), 2, '.', '');
     $billing = $order->getBillingAddress();
     $security = $this->getSecurityKey();
     $reason1_template = Mage::getStoreConfig('payment/pnsofortueberweisung/reason_1', $order->getStore());
     $reason2_template = Mage::getStoreConfig('payment/pnsofortueberweisung/reason_2', $order->getStore());
     $tmp_orderid = $order->getRealOrderId();
     $address = $order->getBillingAddress();
     $tmp_name = $this->_getFirstname($address) . " " . $this->_getLastname($address);
     $tmp_date = Mage::getModel('core/date')->date('d.m.Y');
     $tmp_storename = Mage::getStoreConfig('general/store_information/name', $order->getStore());
     $reason1 = preg_replace('#\\{\\{ordernr\\}\\}#', $tmp_orderid, $reason1_template);
     $reason2 = preg_replace('#\\{\\{ordernr\\}\\}#', $tmp_orderid, $reason2_template);
     $reason1 = preg_replace('#Order No.:#', Mage::helper('pnsofortueberweisung')->__('Order No.: '), $reason1);
     $reason2 = preg_replace('#Order No.:#', Mage::helper('pnsofortueberweisung')->__('Order No.: '), $reason2);
     $reason1 = preg_replace('#\\{\\{name\\}\\}#', $tmp_name, $reason1);
     $reason2 = preg_replace('#\\{\\{name\\}\\}#', $tmp_name, $reason2);
     $reason1 = preg_replace('#\\{\\{date\\}\\}#', $tmp_date, $reason1);
     $reason2 = preg_replace('#\\{\\{date\\}\\}#', $tmp_date, $reason2);
     $reason1 = preg_replace('#\\{\\{shopname\\}\\}#', $tmp_storename, $reason1);
     $reason2 = preg_replace('#\\{\\{shopname\\}\\}#', $tmp_storename, $reason2);
     $reason1 = preg_replace('#\\{\\{transaction\\}\\}#', '-TRANSACTION-', $reason1);
     $reason2 = preg_replace('#\\{\\{transaction\\}\\}#', '-TRANSACTION-', $reason2);
     $reason1 = preg_replace('#[^a-zA-Z0-9+-\\.,\\s+]#', '', $reason1);
     $reason2 = preg_replace('#[^a-zA-Z0-9+-\\.,\\s+]#', '', $reason2);
     $success_url = Mage::getUrl('pnsofortueberweisung/pnsofortueberweisung/return', array('orderId' => $order->getRealOrderId(), '_store' => $order->getStore()->getId()));
     $cancel_url = Mage::getUrl('pnsofortueberweisung/pnsofortueberweisung/error', array('orderId' => $order->getRealOrderId(), '_store' => $order->getStore()->getId()));
     $notification_url = Mage::getUrl('pnsofortueberweisung/pnsofortueberweisung/returnhttp', array('orderId' => $order->getRealOrderId(), 'transId' => '-TRANSACTION-', 'var1' => '-USER_VARIABLE_1_MD5_PASS-', 'secret' => $security, '_store' => $order->getStore()->getId()));
     $sObj = new SofortLib_SofortueberweisungClassic(Mage::getStoreConfig('payment/pnsofortueberweisung/customer', $order->getStore()), Mage::getStoreConfig('payment/pnsofortueberweisung/project', $order->getStore()), Mage::getStoreConfig('payment/pnsofortueberweisung/project_pswd', $order->getStore()));
     $sObj->setVersion(self::MODULE_VERSION);
     $sObj->setAmount($amount, $this->getOrder()->getOrderCurrencyCode());
     $sObj->setReason($reason1, $reason2);
     $sObj->setSuccessUrl($success_url);
     $sObj->setAbortUrl($cancel_url);
     $sObj->setNotificationUrl($notification_url);
     $sObj->addUserVariable($this->getOrder()->getRealOrderId());
     $sObj->addUserVariable($security);
     $order->getPayment()->setAdditionalInformation('sofort_lastchanged', 0);
     $order->getPayment()->setAdditionalInformation('sofort_secret', $security)->save();
     // all information where decoded in url secured by hash key
     return $sObj->getPaymentUrl();
 }