Beispiel #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();
 }
Beispiel #2
0
 /**
  * @param $cart
  * @param $order
  * @return bool','null
  */
 function plgVmConfirmedOrder($cart, $order)
 {
     if (!($method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return FALSE;
     }
     $this->setInConfirmOrder($cart);
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $this->_debug = $method->debug;
     $this->logInfo('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
     vmdebug('SOFORT plgVmConfirmedOrder');
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
     }
     if (!class_exists('TableVendors')) {
         require VMPATH_ADMIN . DS . 'tables' . DS . 'vendors.php';
     }
     $currency_code_3 = self::PAYMENT_CURRENCY_CODE_3;
     //
     $currency_id = shopFunctions::getCurrencyIDByName($currency_code_3);
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $currency_id);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     $address = isset($order['details']['ST']) ? $order['details']['ST'] : $order['details']['BT'];
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     if ($totalInPaymentCurrency <= 0) {
         vmInfo(vmText::sprintf('VMPAYMENT_SOFORT_AMOUNT_INCORRECT', $order['details']['BT']->order_total, $totalInPaymentCurrency['value'], $currency_code_3));
         return FALSE;
     }
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['payment_name'] = $this->renderPluginName($method, 'order');
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['cost_per_transaction'] = $method->cost_per_transaction;
     $dbValues['cost_percent_total'] = $method->cost_percent_total;
     $dbValues['payment_currency'] = $currency_id;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['tax_id'] = $method->tax_id;
     $dbValues['sofort_custom'] = $return_context;
     $this->storePSPluginInternalData($dbValues);
     if (!class_exists('SofortLib')) {
         require VMPATH_ROOT . DS . 'plugins' . DS . 'vmpayment' . DS . 'sofort' . DS . 'sofort' . DS . 'library' . DS . 'sofortLib.php';
     }
     if (!class_exists('SofortLib_iDealClassic')) {
         require VMPATH_ROOT . DS . 'plugins' . DS . 'vmpayment' . DS . 'sofort' . DS . 'sofort' . DS . 'library' . DS . 'sofortLib_ideal_classic.php';
     }
     $sofort_ideal = new SofortLib_iDealClassic($method->configuration_key, $method->project_password);
     $sofort_ideal->setVersion(self::RELEASE);
     $sofort_ideal->setAmount($totalInPaymentCurrency['value'], $currency_code_3);
     $sofort_ideal->setSenderCountryId(ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'));
     $sofort_ideal->setReason($order['details']['BT']->order_number);
     $sofort_ideal->addUserVariable($order['details']['BT']->virtuemart_paymentmethod_id);
     //$sofort_ideal->setSuccessUrl(self::getSuccessUrl($order)); //user_variable_3
     //$sofort_ideal->setAbortUrl(self::getCancelUrl($order)); //user_variable_4
     //$sofort_ideal->setNotificationUrl(self::getNotificationUrl( $order['details']['BT']->order_number)); //user_variable_5
     $sofort_ideal->setSenderCountryId(ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'));
     //sender_country_id
     $sofort_ideal->setSenderBankCode(self::_getSelectedBankCode($order['details']['BT']->virtuemart_paymentmethod_id));
     $url = $sofort_ideal->getPaymentUrl();
     //$this->storePSPluginInternalData($dbValues);
     $mainframe = JFactory::getApplication();
     $mainframe->redirect($url);
 }