/**
  * @param array   $dataArray
  * - amount (required)
  * - ...
  * @return array res
  */
 public function setExpressCheckout($data)
 {
     $defaults = array('reason' => __('Sale'), 'description' => '');
     $data = array_merge($defaults, $data);
     //Router::url($dataArray['returnurl'], true);
     $Sofort = new SofortLib_Multipay($this->_configKey());
     $Sofort->new($data['amount'], $this->settings['currency_code']);
     App::uses('Inflector', 'Utility');
     $Sofort->setAmount($data['amount'], $this->settings['currency_code']);
     $Sofort->setReason(Inflector::slug($data['reason']), Inflector::slug($data['description']));
     $Sofort->setSofortueberweisung();
     $Sofort->setLanguageCode(strtolower($this->settings['locale']));
     if (false) {
         $Sofort->setSofortueberweisungCustomerprotection(true);
     }
     //die(returns($Sofort->parameters));
     //die(returns($Sofort->parameters));
     $res = $Sofort->validateRequest();
     die(returns($res));
     $res = $Sofort->sendRequest();
     die(returns($res));
     return;
 }
Exemple #2
0
 function sendTransactionRequest($cart, $order, $doRedirect = true)
 {
     $session = JFactory::getSession();
     $return_context = $session->getId();
     //$this->_debug = $method->debug;
     //$this->debugLog('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
     vmdebug('SOFORT sendTransactionRequest');
     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('CurrencyDisplay')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     if (!class_exists('TableVendors')) {
         require VMPATH_ADMIN . DS . 'tables' . DS . 'vendors.php';
     }
     $this->getPaymentCurrency($this->_currentMethod);
     $email_currency = $this->getEmailCurrency($this->_currentMethod);
     $currency_code_3 = shopFunctions::getCurrencyByID($this->_currentMethod->payment_currency, 'currency_code_3');
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $this->_currentMethod->payment_currency);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['payment_name'] = $this->renderPluginName($this->_currentMethod, 'create_order');
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['cost_per_transaction'] = $this->_currentMethod->cost_per_transaction;
     $dbValues['cost_percent_total'] = $this->_currentMethod->cost_percent_total;
     $dbValues['payment_currency'] = $this->_currentMethod->payment_currency;
     $dbValues['email_currency'] = $email_currency;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['tax_id'] = $this->_currentMethod->tax_id;
     $dbValues['sofort_custom'] = $return_context;
     $security = self::getSecurityKey();
     $dbValues['security'] = $security;
     $this->debugLog('comes from' . (int) $doRedirect . ' order number' . $order['details']['BT']->order_number, "sendTransactionRequest ", 'debug');
     if (!class_exists('SofortLib')) {
         require VMPATH_ROOT . DS . 'plugins' . DS . 'vmpayment' . DS . 'sofort' . DS . 'sofort' . DS . 'library' . DS . 'sofortLib.php';
     }
     $sofort = new SofortLib_Multipay(trim($this->_currentMethod->configuration_key));
     $sofort->setVersion(self::RELEASE);
     $sofort->setAmount($totalInPaymentCurrency['value'], $currency_code_3);
     $sofort->setReason($order['details']['BT']->order_number);
     $sofort->setSuccessUrl(self::getSuccessUrl($order));
     $sofort->setAbortUrl(self::getCancelUrl($order));
     $sofort->setNotificationUrl(self::getNotificationUrl($security, $order['details']['BT']->order_number));
     $sofort->setSofortueberweisung();
     $sofort->setSofortueberweisungCustomerprotection($this->_currentMethod->buyer_protection);
     $jlang = JFactory::getLanguage();
     $lang = $jlang->getTag();
     $langArray = explode("-", $lang);
     $lang = strtolower($langArray[1]);
     $sofort->setLanguageCode($lang);
     $sofort->sendRequest();
     vmdebug('SOFORT sendTransactionRequest ... SofortLib_Multipay ... sendRequest()');
     if ($sofort->isError()) {
         $errors = $sofort->getErrors();
         vmdebug('SOFORT sendTransactionRequest ... SofortLib_Multipay ... getErrors()', $errors);
         $this->displayErrors($errors);
         $this->redirectToCart();
         return;
     }
     $url = $sofort->getPaymentUrl();
     $dbValues['sofort_response_transaction'] = $sofort->getTransactionId();
     $this->storePSPluginInternalData($dbValues);
     if ($doRedirect) {
         $mainframe = JFactory::getApplication();
         $mainframe->redirect($url);
     }
 }