示例#1
0
 /**
  * @param $pathUrl
  * @param $data
  * @return mixed
  */
 public static function delete($pathUrl, $data)
 {
     $posId = OpenPayU_Configuration::getMerchantPosId();
     $signatureKey = OpenPayU_Configuration::getSignatureKey();
     $response = OpenPayU_HttpCurl::doRequest('DELETE', $pathUrl, $data, $posId, $signatureKey);
     return $response;
 }
示例#2
0
 /**
  * @param string $key
  * @return array
  */
 public function getConfig($key = null)
 {
     $config = ['merchant_pos_id' => \OpenPayU_Configuration::getMerchantPosId(), 'signature_key' => \OpenPayU_Configuration::getSignatureKey()];
     if ($key) {
         return $config[$key];
     }
     return $config;
 }
示例#3
0
 /**
  * @throws OpenPayU_Exception_Authorization
  */
 public static function verifyBasicAuthCredentials()
 {
     if (isset($_SERVER['PHP_AUTH_USER'])) {
         $user = (string) $_SERVER['PHP_AUTH_USER'];
     } else {
         throw new OpenPayU_Exception_Authorization('Empty user name');
     }
     if (isset($_SERVER['PHP_AUTH_PW'])) {
         $password = (string) $_SERVER['PHP_AUTH_PW'];
     } else {
         throw new OpenPayU_Exception_Authorization('Empty password');
     }
     if ($user !== OpenPayU_Configuration::getMerchantPosId() || $password !== OpenPayU_Configuration::getSignatureKey()) {
         throw new OpenPayU_Exception_Authorization("invalid credentials");
     }
 }
示例#4
0
 /**
  * Generate a form body for hosted order
  *
  * @access public
  * @param $order An array containing full Order
  * @param $params An optional array with form elements' params
  * @return string Response html form
  */
 public static function hostedOrderForm($order, $params = array())
 {
     $orderFormUrl = OpenPayU_Configuration::getServiceUrl() . 'orders';
     $usortedFormFieldValuesAsArray = array();
     $htmlFormFields = OpenPayU_Util::convertArrayToHtmlForm($order, "", $usortedFormFieldValuesAsArray);
     ksort($usortedFormFieldValuesAsArray);
     $sortedFormFieldValuesAsString = implode('', array_values($usortedFormFieldValuesAsArray));
     $signature = OpenPayU_Util::generateSignData($sortedFormFieldValuesAsString, OpenPayU_Configuration::getHashAlgorithm(), OpenPayU_Configuration::getMerchantPosId(), OpenPayU_Configuration::getSignatureKey());
     $formParams = array_merge(self::$defaultFormParams, $params);
     $htmlOutput = sprintf("<form method=\"POST\" action=\"%s\" id=\"%s\" class=\"%s\">\n", $orderFormUrl, $formParams['formId'], $formParams['formClass']);
     $htmlOutput .= $htmlFormFields;
     $htmlOutput .= sprintf("<input type=\"hidden\" name=\"OpenPayu-Signature\" value=\"%s\" />", $signature);
     $htmlOutput .= sprintf("<button type=\"submit\" formtarget=\"%s\" id=\"%s\" class=\"%s\">%s</button>", $formParams['submitTarget'], $formParams['submitId'], $formParams['submitClass'], $formParams['submitContent']);
     $htmlOutput .= "</form>\n";
     return $htmlOutput;
 }
 /**
  * Initializes the payment.
  * @param Mage_Sales_Model_Order
  * @param Mage_Shipping_Model_Shipping
  * @return array
  */
 public function orderCreateRequest(Mage_Sales_Model_Order $order, $allShippingRates)
 {
     $this->_order = $order;
     $orderCurrencyCode = $this->_order->getOrderCurrencyCode();
     $orderCountryCode = $this->_order->getBillingAddress()->getCountry();
     $shippingCostList = array();
     if (empty($allShippingRates) || Mage::getSingleton('customer/session')->isLoggedIn()) {
         if ($order->getShippingInclTax() > 0) {
             $shippingCostList['shippingMethods'][] = array('name' => $order->getShippingDescription(), 'country' => $orderCountryCode, 'price' => $this->toAmount($order->getShippingInclTax()));
         }
         $grandTotal = $this->_order->getGrandTotal() - $order->getShippingInclTax();
     } else {
         $firstPrice = 0;
         foreach ($allShippingRates as $key => $rate) {
             $gross = $this->toAmount($rate->getPrice());
             if ($key == 0) {
                 $firstPrice = $rate->getPrice();
             }
             $shippingCostList['shippingMethods'][] = array('name' => $rate->getMethodTitle(), 'country' => $orderCountryCode, 'price' => $gross);
         }
         $grandTotal = $this->_order->getGrandTotal() - $firstPrice;
     }
     $shippingCost = array('countryCode' => $orderCountryCode, 'shipToOtherCountry' => 'true', 'shippingCostList' => $shippingCostList);
     $orderItems = $this->_order->getAllVisibleItems();
     $items = array();
     $productsTotal = 0;
     $is_discount = false;
     foreach ($orderItems as $key => $item) {
         $itemInfo = $item->getData();
         if ($itemInfo['discount_amount'] > 0) {
             $itemInfo['price_incl_tax'] = $itemInfo['price_incl_tax'] - $itemInfo['discount_amount'];
             $is_discount = true;
         } else {
             if ($itemInfo['discount_percent'] > 0) {
                 $itemInfo['price_incl_tax'] = $itemInfo['price_incl_tax'] * (100 - $itemInfo['discount_percent']) / 100;
             }
         }
         // Check if the item is countable one
         if ($this->toAmount($itemInfo['price_incl_tax']) > 0) {
             $items['products'][] = array('quantity' => (int) $itemInfo['qty_ordered'], 'name' => $itemInfo['name'], 'unitPrice' => $this->toAmount($itemInfo['price_incl_tax']));
             $productsTotal += $itemInfo['price_incl_tax'] * $itemInfo['qty_ordered'];
         }
     }
     //if($this->_order->getShippingAmount () > 0 && !empty ( $shippingCostList['shippingMethods'][0] ) ){
     //        $items ['products'] ['products'] [] = array (
     //            'quantity' => 1 ,'name' => Mage::helper ( 'payu_account' )->__('Shipping costs') . " - " . $shippingCostList['shippingMethods'][0]['name'] ,'unitPrice' => $this->toAmount ( $this->_order->getShippingAmount () ));
     //}
     // assigning the shopping cart
     $shoppingCart = array('grandTotal' => $this->toAmount($grandTotal), 'CurrencyCode' => $orderCurrencyCode, 'ShoppingCartItems' => $items);
     $orderInfo = array('merchantPosId' => OpenPayU_Configuration::getMerchantPosId(), 'orderUrl' => Mage::getBaseUrl() . 'sales/order/view/order_id/' . $this->_order->getId() . '/', 'description' => 'Order no ' . $this->_order->getRealOrderId(), 'validityTime' => $this->_config->getOrderValidityTime());
     if ($is_discount) {
         $items['products'] = array();
         $items['products'][] = array('quantity' => 1, 'name' => Mage::helper('payu_account')->__('Order # ') . $this->_order->getId(), 'unitPrice' => $this->toAmount($grandTotal));
     }
     $OCReq = $orderInfo;
     $OCReq['products'] = $items['products'];
     $OCReq['customerIp'] = Mage::app()->getFrontController()->getRequest()->getClientIp();
     $OCReq['notifyUrl'] = $this->_myUrl . 'orderNotifyRequest';
     $OCReq['cancelUrl'] = $this->_myUrl . 'cancelPayment';
     $OCReq['continueUrl'] = $this->_myUrl . 'continuePayment';
     $OCReq['currencyCode'] = $orderCurrencyCode;
     $OCReq['totalAmount'] = $shoppingCart['grandTotal'];
     $OCReq['extOrderId'] = $this->_order->getId() . '-' . microtime();
     if (!empty($shippingCostList)) {
         $OCReq['shippingMethods'] = $shippingCostList['shippingMethods'];
     }
     unset($OCReq['shoppingCart']);
     $customer_sheet = array();
     $billingAddressId = $this->_order->getBillingAddressId();
     if (!empty($billingAddressId)) {
         $billingAddress = $this->_order->getBillingAddress();
         $customer_mail = $billingAddress->getEmail();
         if (!empty($customer_mail)) {
             $customer_sheet = array('email' => $billingAddress->getEmail(), 'phone' => $billingAddress->getTelephone(), 'firstName' => $billingAddress->getFirstname(), 'lastName' => $billingAddress->getLastname());
             $shippingAddressId = $this->_order->getShippingAddressId();
             if (!empty($shippingAddressId)) {
                 $shippingAddress = $this->_order->getShippingAddress();
             }
             if (!$this->_order->getIsVirtual()) {
                 $customer_sheet['delivery'] = array('street' => trim(implode(' ', $shippingAddress->getStreet())), 'postalCode' => $shippingAddress->getPostcode(), 'city' => $shippingAddress->getCity(), 'countryCode' => $shippingAddress->getCountry(), 'recipientName' => trim($shippingAddress->getFirstname() . ' ' . $shippingAddress->getLastname()), 'recipientPhone' => $shippingAddress->getTelephone(), 'recipientEmail' => $shippingAddress->getEmail());
             }
             $OCReq['buyer'] = $customer_sheet;
         }
     }
     $result = OpenPayU_Order::create($OCReq);
     if ($result->getStatus() == 'SUCCESS') {
         // store session identifier in session info
         Mage::getSingleton('core/session')->setPayUSessionId($result->getResponse()->orderId);
         // assign current transaction id
         $this->_transactionId = $result->getResponse()->orderId;
         $order->getPayment()->setLastTransId($this->_transactionId);
         $locale = Mage::getStoreConfig('general/locale/code', Mage::app()->getStore()->getId());
         $lang_code = explode('_', $locale, 2);
         $ret = array('redirectUri' => $result->getResponse()->redirectUri, 'url' => OpenPayu_Configuration::getSummaryUrl(), 'sessionId' => $result->getResponse()->orderId, 'lang' => strtolower($lang_code[1]));
         $customer = Mage::getModel('customer/customer');
         if ($this->_order->getCustomerIsGuest()) {
             $email = $billingAddress->getEmail();
             $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
             $customer->loadByEmail($email);
         } else {
             $customer->load($this->_order->getCustomerId());
         }
         if (!$customer->getId()) {
             $this->_order->setCustomerEmail($email);
         }
         $this->_order->sendNewOrderEmail();
         $this->_order->save();
     } else {
         Mage::throwException(Mage::helper('payu_account')->__('There was a problem with initializing the payment, please contact the store administrator. ' . $result->getError()));
     }
     return $ret;
 }
 /**
  * Function use to update status
  * @access public
  * @param string $sessionId
  * @param string $status
  * @param boolean $debug
  * @return object $result
  */
 public static function updateStatus($sessionId, $status, $debug = TRUE)
 {
     $rq = array('ReqId' => md5(rand()), 'MerchantPosId' => OpenPayU_Configuration::getMerchantPosId(), 'SessionId' => $sessionId, 'OrderStatus' => $status, 'Timestamp' => date('c'));
     $result = new OpenPayU_Result();
     $result->setRequest($rq);
     $url = OpenPayU_Configuration::getServiceUrl() . 'co/openpayu/OrderStatusUpdateRequest';
     if ($debug) {
         OpenPayU::addOutputConsole('OpenPayU endpoint for OrderStatusUpdateRequest message', $url);
     }
     $oauthResult = OpenPayu_OAuth::accessTokenByClientCredentials();
     OpenPayU::setOpenPayuEndPoint($url . '?oauth_token=' . $oauthResult->getAccessToken());
     $xml = OpenPayU::buildOrderStatusUpdateRequest($rq);
     if ($debug) {
         OpenPayU::addOutputConsole('OrderStatusUpdateRequest message', htmlentities($xml));
     }
     $merchantPosId = OpenPayU_Configuration::getMerchantPosId();
     $signatureKey = OpenPayU_Configuration::getSignatureKey();
     $response = OpenPayU::sendOpenPayuDocumentAuth($xml, $merchantPosId, $signatureKey);
     if ($debug) {
         OpenPayU::addOutputConsole('OrderStatusUpdateResponse message', htmlentities($response));
     }
     // verify response from PayU service
     $status = OpenPayU::verifyOrderStatusUpdateResponseStatus($response);
     if ($debug) {
         OpenPayU::addOutputConsole('OrderStatusUpdateResponse status', serialize($status));
     }
     $result->setStatus($status);
     $result->setError($status['StatusCode']);
     $result->setSuccess($status['StatusCode'] == 'OPENPAYU_SUCCESS' ? TRUE : FALSE);
     $result->setResponse(OpenPayU::parseOpenPayUDocument($response));
     return $result;
 }
 /**
  * @param OptionsResolverInterface $resolver
  */
 protected function configureOrder(OptionsResolverInterface $resolver)
 {
     $resolver->setRequired(['continueUrl', 'notifyUrl', 'customerIp', 'merchantPosId', 'description', 'currencyCode', 'totalAmount', 'extOrderId', 'products', 'buyer'])->setDefaults(['currencyCode' => 'PLN', 'merchantPosId' => (int) \OpenPayU_Configuration::getMerchantPosId()])->setAllowedTypes(['continueUrl' => 'string', 'notifyUrl' => 'string', 'customerIp' => 'string', 'merchantPosId' => 'int', 'description' => 'string', 'currencyCode' => 'string', 'totalAmount' => 'integer', 'extOrderId' => 'integer', 'products' => 'array', 'buyer' => 'array']);
 }
 public function testMerchantPosId()
 {
     OpenPayU_Configuration::setMerchantPosId('PosId');
     $this->assertEquals('PosId', OpenPayU_Configuration::getMerchantPosId());
 }
示例#9
0
 * http://developers.payu.com
 * http://twitter.com/openpayu
 *
 */
require_once realpath(dirname(__FILE__)) . '/../../../lib/openpayu.php';
require_once realpath(dirname(__FILE__)) . '/../../config.php';
OpenPayU_Configuration::setEnvironment('secure');
OpenPayU_Configuration::setMerchantPosId('4966124');
// POS ID (Checkout)
OpenPayU_Configuration::setSignatureKey('b5588f9e8c0b3587bf8de820f385c76e');
//Second MD5 key. You will find it in admin panel.
$order = array();
$order['notifyUrl'] = 'http://localhost' . dirname($_SERVER['REQUEST_URI']) . '/OrderNotify.php';
$order['continueUrl'] = 'http://localhost' . dirname($_SERVER['REQUEST_URI']) . '/../../layout/success.php';
$order['customerIp'] = '127.0.0.1';
$order['merchantPosId'] = OpenPayU_Configuration::getMerchantPosId();
$order['description'] = 'New order';
$order['currencyCode'] = 'PLN';
$order['totalAmount'] = 3200;
$order['extOrderId'] = rand(1000, 1000000);
$order['products'][0]['name'] = 'Product1';
$order['products'][0]['unitPrice'] = 1000;
$order['products'][0]['quantity'] = 1;
$order['products'][1]['name'] = 'Product2';
$order['products'][1]['unitPrice'] = 2200;
$order['products'][1]['quantity'] = 1;
$order['buyer']['email'] = '*****@*****.**';
$order['buyer']['phone'] = '123123123';
$order['buyer']['firstName'] = 'Jan';
$order['buyer']['lastName'] = 'Kowalski';
/*~~~~~~~~ optional part INVOICE data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
示例#10
0
 public function buildorder()
 {
     $OCRV2 = array();
     $this->language->load('payment/payu');
     $this->load->model('payment/payu');
     $this->loadLibConfig();
     $this->load->model('checkout/order');
     $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
     $this->load->model('localisation/country');
     $this->tax->setShippingAddress($order_info['shipping_country_id'], $order_info['shipping_zone_id']);
     $this->tax->setPaymentAddress($order_info['payment_country_id'], $order_info['payment_zone_id']);
     $this->tax->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
     $grandTotal = 0;
     $cartItems = array();
     $orderType = 'VIRTUAL';
     $shippingCostAmount = 0.0;
     $decimalPlace = $this->currency->getDecimalPlace();
     if (!empty($this->session->data['vouchers'])) {
         foreach ($this->session->data['vouchers'] as $voucher) {
             $this->vouchersAmount += $this->currency->format($voucher['amount']);
             $OCRV2['products'][] = array('quantity' => 1, 'name' => $voucher['description'], 'unitPrice' => $this->toAmount($voucher['amount']));
         }
     }
     foreach ($this->cart->getProducts() as $item) {
         list($orderType, $OCRV2, $grandTotal) = $this->prepareProductsSection($decimalPlace, $item, $order_info, $OCRV2, $grandTotal);
     }
     $shoppingCart = array('GrandTotal' => $grandTotal, 'CurrencyCode' => $order_info['currency_code'], 'ShoppingCartItems' => $cartItems);
     //$this->session->data['sessionId'] = md5(rand() . rand() . rand() . rand()) . $this->session->data['order_id'];
     $order = array('MerchantPosId' => OpenPayU_Configuration::getMerchantPosId(), 'SessionId' => '', 'OrderUrl' => $this->url->link('payment/payu/callback') . '?order=' . $this->session->data['order_id'], 'OrderCreateDate' => date("c"), 'OrderDescription' => 'Order ' . $this->session->data['order_id'], 'MerchantAuthorizationKey' => OpenPayU_Configuration::getPosAuthKey(), 'OrderType' => $orderType, 'ShoppingCart' => $shoppingCart);
     $OCReq = array('ReqId' => md5(rand()), 'CustomerIp' => $order_info['ip'] == "::1" || $order_info['ip'] == "::" || !preg_match("/^((?:25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9]).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\$/m", $order_info['ip']) ? '127.0.0.1' : $order_info['ip'], 'NotifyUrl' => $this->url->link('payment/payu/ordernotify'), 'OrderCancelUrl' => $this->url->link('payment/payu/paymentcancel'), 'OrderCompleteUrl' => $this->url->link('payment/payu/paymentsuccess'), 'Order' => $order);
     $customer = array();
     if (!empty($order_info['email'])) {
         $customer = array('email' => $order_info['email'], 'firstName' => $order_info['firstname'], 'lastName' => $order_info['lastname'], 'phone' => $order_info['telephone']);
     } elseif (!empty($this->session->data['customer_id'])) {
         $this->load->model('account\\customer');
         $custdata = $this->model_account_customer->getCustomer($this->session['customer_id']);
         if (!empty($custdata['email'])) {
             $customer = array('email' => $order_info['email'], 'firstName' => $order_info['firstname'], 'lastName' => $order_info['lastname'], 'phone' => $order_info['telephone']);
         }
     }
     if ($orderType == 'MATERIAL') {
         if (!empty($customer) && !empty($order_info['shipping_city']) && !empty($order_info['shipping_postcode']) && !empty($order_info['payment_iso_code_2'])) {
             $customer['delivery'] = array('street' => $order_info['shipping_address_1'] . " " . ($order_info['shipping_address_2'] ? $order_info['shipping_address_2'] : ''), 'postalCode' => $order_info['shipping_postcode'], 'city' => $order_info['shipping_city'], 'countryCode' => $order_info['payment_iso_code_2'], 'recipientName' => $order_info['shipping_firstname'] . " " . $order_info['shipping_lastname'], 'recipientPhone' => $order_info['telephone'], 'recipientEmail' => $order_info['email']);
         }
         if (!empty($order_info['shipping_method'])) {
             list($shippingCostList, $shippingCostAmount) = $this->prepareShippingMethodsSection($decimalPlace, $order_info);
         } else {
             $shippingCostList = array();
             $shipping_methods = $this->getShippings($this->session->data['order_id'], $order_info['shipping_country_id']);
             $country = $this->model_localisation_country->getCountry($order_info['shipping_country_id']);
             foreach ($shipping_methods as $onemethod) {
                 if (empty($decimalPlace)) {
                     $onemethod['cost'] *= 100;
                     $shippingCostAmount = $shippingCost;
                 }
                 $price = $this->currency->format($this->tax->calculate($onemethod['cost'], $onemethod['tax_class_id']), $order_info['currency_code'], false, false);
                 $price = preg_replace("/[^0-9]/", "", $price);
                 $shippingCostList['shippingMethods'][] = array('name' => $onemethod['title'], 'country' => $country['iso_code_2'], 'price' => $price);
             }
         }
     }
     if (isset($this->session->data['coupon']) || !empty($this->session->data['coupon'])) {
         $OCRV2 = $this->prepareCumulatedProductsArray($OCRV2, $order_info, $shippingCostAmount);
     }
     $OCRV2['merchantPosId'] = OpenPayU_Configuration::getMerchantPosId();
     $OCRV2['orderUrl'] = $this->url->link('payment/payu/callback') . '?order=' . $this->session->data['order_id'];
     $OCRV2['description'] = "Zamówienie #" . $this->session->data['order_id'];
     $OCRV2['customerIp'] = $OCReq['CustomerIp'];
     $OCRV2['notifyUrl'] = $OCReq['NotifyUrl'];
     $OCRV2['cancelUrl'] = $OCReq['OrderCancelUrl'];
     $OCRV2['continueUrl'] = $OCReq['OrderCompleteUrl'];
     $OCRV2['currencyCode'] = $order_info['currency_code'];
     $total = $order_info['total'];
     if (empty($decimalPlace)) {
         $total = $this->toAmount($total);
     }
     $total = str_ireplace(array('.', ' '), array('', ''), $this->currency->format($total - $shippingCostAmount, $order_info['currency_code'], false, false));
     $OCRV2['totalAmount'] = $total;
     $OCRV2['extOrderId'] = $this->session->data['order_id'] . '-' . microtime();
     if (isset($shippingCostList)) {
         $OCRV2['shippingMethods'] = $shippingCostList['shippingMethods'];
     }
     $OCRV2['buyer'] = $customer;
     return $OCRV2;
 }
示例#11
0
 /**
  * @param $items
  * @param $customer_sheet
  * @param $order_notify_link
  * @param $order_cancel_link
  * @param $order_complete_link
  * @param $currency
  * @param $grand_total
  * @param $carriers_list
  * @return array
  */
 private function prepareOrder($items, $customer_sheet, $order_notify_link, $order_cancel_link, $order_complete_link, $currency, $grand_total, $carriers_list)
 {
     $ocreq = array();
     $ocreq['merchantPosId'] = OpenPayU_Configuration::getMerchantPosId();
     $ocreq['orderUrl'] = $this->context->link->getPageLink('guest-tracking.php', true);
     $ocreq['description'] = $this->l('Order for cart: ') . ' ' . $this->cart->id . ' ' . $this->l(' from the store: ') . ' ' . Configuration::get('PS_SHOP_NAME');
     $ocreq['validityTime'] = 60 * (int) Configuration::get('PAYU_VALIDITY_TIME');
     $ocreq['products'] = $items['products'];
     $ocreq['buyer'] = $customer_sheet;
     $ocreq['customerIp'] = $_SERVER['REMOTE_ADDR'] == '::1' || $_SERVER['REMOTE_ADDR'] == '::' || !preg_match('/^((?:25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9]).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])$/m', $_SERVER['REMOTE_ADDR']) ? '127.0.0.1' : $_SERVER['REMOTE_ADDR'];
     $ocreq['notifyUrl'] = $order_notify_link;
     $ocreq['cancelUrl'] = $order_cancel_link;
     $ocreq['continueUrl'] = $order_complete_link . '?id_cart=' . $this->cart->id;
     $ocreq['currencyCode'] = $currency['iso_code'];
     $ocreq['totalAmount'] = $grand_total;
     $ocreq['extOrderId'] = $this->cart->id . '-' . microtime();
     $ocreq['shippingMethods'] = $carriers_list['shippingMethods'];
     return $ocreq;
 }
示例#12
0
 function process($order_id)
 {
     if (!$this->isLoggedIn) {
         redirect('/login', 'refresh');
     }
     $this->load->model('Ordermodel');
     $_order = $this->Ordermodel->get_order($this->session->userdata['user']->id, $order_id, 'W');
     if ($_order == null) {
         $this->http404();
     }
     $_order = $_order[0];
     $this->config->load('payu', true);
     OpenPayU_Configuration::setEnvironment('secure');
     OpenPayU_Configuration::setMerchantPosId($this->config->item('PosId', 'payu'));
     OpenPayU_Configuration::setSignatureKey($this->config->item('SignatureKey', 'payu'));
     $order = array();
     $order['notifyUrl'] = base_url() . 'index.php/order/notify';
     //$order['notifyUrl'] = "http://t01.pl/payu/index.php";
     $order['continueUrl'] = base_url() . 'index.php/user_panel/history';
     $order['customerIp'] = $this->input->ip_address();
     $order['merchantPosId'] = OpenPayU_Configuration::getMerchantPosId();
     $order['description'] = $this->config->item('title', 'payu');
     $order['currencyCode'] = 'PLN';
     //$order['extOrderId'] = "think01-".time().'-'.$order_id;
     $order['products'] = array();
     $cost = 0;
     if (count($_order->cart) == 0) {
         return false;
     }
     foreach ($_order->cart as $v) {
         array_push($order['products'], array('name' => $v->diet, 'unitPrice' => $v->price, 'quantity' => $v->quantity));
         $cost += $v->price * $v->quantity;
     }
     $order['totalAmount'] = $cost;
     $order['buyer']['email'] = $v->email;
     $order['buyer']['phone'] = preg_replace('/[^0-9\\+]/', '', $v->phone);
     $order['buyer']['firstName'] = $v->name;
     $order['buyer']['lastName'] = $v->surname;
     try {
         //echo '<pre>'; print_r($order); die('');
         $response = OpenPayU_Order::create($order);
         $status_desc = OpenPayU_Util::statusDesc($response->getStatus());
         if ($response->getStatus() == 'SUCCESS') {
             $this->Ordermodel->set_payment_id($order_id, $response->getResponse()->orderId);
             redirect($response->getResponse()->redirectUri, 'refresh');
         } else {
             $this->show("alert", array('msg' => '<pre>' . print_r($order, true) . '</pre><br>' . $response->getStatus() . ': ' . $status_desc));
         }
         return;
     } catch (OpenPayU_Exception $e) {
         $this->show("alert", array('msg' => '<pre>' . print_r($order, true) . '</pre><br>' . (string) $e));
     }
 }