public function process()
 {
     if (Tools::getIsset('DOCUMENT')) {
         $data = Tools::getValue('DOCUMENT');
         $result = OpenPayU_Order::consumeMessage($data, false);
         if ($result->getMessage() == 'ShippingCostRetrieveRequest') {
             $id_payu_session = $result->getSessionId();
             $iso_country_code = $result->getCountryCode();
             $payu = new PayU();
             $order_payment = $payu->getOrderPaymentBySessionId($id_payu_session);
             $id_cart = $order_payment['id_cart'];
             if (!empty($id_cart)) {
                 $payu->id_cart = $id_cart;
                 $payu->payu_order_id = $id_payu_session;
                 $payu->id_request = $result->getReqId();
                 $xml = $payu->shippingCostRetrieveRequest($iso_country_code);
                 if (!empty($xml)) {
                     header('Content-Type:text/xml');
                     echo $xml;
                 }
             }
         }
     }
     exit;
 }
 public function testHostedOrderForm()
 {
     $expectedForm = file_get_contents(realpath(dirname(__FILE__)) . '/../../resources/hostedOrderForm.txt');
     OpenPayU_Configuration::setHashAlgorithm('MD5');
     $form = OpenPayU_Order::hostedOrderForm($this->_order);
     $this->assertEquals($expectedForm, $form);
 }
 public function process()
 {
     $body = Tools::file_get_contents('php://input');
     $data = trim($body);
     $result = OpenPayU_Order::consumeNotification($data);
     $response = $result->getResponse();
     SimplePayuLogger::addLog('notification', __FUNCTION__, print_r($result, true), $response->order->orderId, 'Incoming notification: ');
     if (isset($response->order->orderId)) {
         $payu = new PayU();
         $payu->payu_order_id = $response->order->orderId;
         $order_payment = $payu->getOrderPaymentBySessionId($payu->payu_order_id);
         $id_order = (int) $order_payment['id_order'];
         // if order not validated yet
         if ($id_order == 0 && $order_payment['status'] == PayU::PAYMENT_STATUS_NEW) {
             $id_order = $this->createOrder($order_payment, $payu, $response);
         }
         if (!empty($id_order)) {
             $payu->id_order = $id_order;
             $payu->updateOrderData($response);
         }
         if ($this->checkIfPaymentIdIsPresent($response) && $response->order->status == PayU::ORDER_V2_COMPLETED) {
             $this->addPaymentIdToOrder($response, $payu, $id_order);
         }
         //the response should be status 200
         header("HTTP/1.1 200 OK");
         exit;
     }
 }
 public function retrieveOrder($document)
 {
     $result = \OpenPayU_Order::consumeMessage($document);
     if ($result->getMessage() == 'OrderNotifyRequest') {
         $result = \OpenPayU_Order::retrieve($result->getSessionId());
         return $result->getResponse();
     }
     return null;
 }
Beispiel #5
0
 function payment_status($payment)
 {
     $this->config->load('payu', true);
     if (!$this->isLoggedIn) {
         redirect('/login', 'refresh');
     }
     if (!$this->isAdmin) {
         redirect('/', 'refresh');
     }
     OpenPayU_Configuration::setEnvironment('secure');
     OpenPayU_Configuration::setMerchantPosId($this->config->item('PosId', 'payu'));
     OpenPayU_Configuration::setSignatureKey($this->config->item('SignatureKey', 'payu'));
     $order = OpenPayU_Order::retrieve($payment)->getResponse()->orders;
     /* $this->Debug( $order, true ); */
     $this->show('user/panels/admin/payment_status', array('order' => $order));
 }
 /**
  * @return JsonResponse|Response
  */
 public function notifyAction()
 {
     $paymentController = $this->get('ant_qa.payu_bundle.controller.payment');
     /** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */
     $dispatcher = $this->container->get('event_dispatcher');
     try {
         $body = file_get_contents('php://input');
         $data = stripslashes(trim($body));
         /** @var \stdClass $result */
         $result = \OpenPayU_Order::consumeNotification($data)->getResponse();
         if ($result->order->orderId) {
             $order = \OpenPayU_Order::retrieve($result->order->orderId);
             /** @var Payment $payment */
             $payment = $this->getDoctrine()->getManager()->getRepository($this->container->getParameter('payu_bundle.payment_class'))->find($result->order->orderId);
             if ($payment) {
                 if ($payment->getStatus() !== Payment::STATUS_COMPLETED && $payment->getStatus() !== Payment::STATUS_CANCELED) {
                     //update payment status
                     $payment->setStatus($result->order->status);
                     $this->getDoctrine()->getManager()->flush();
                     $event = new PaymentEvent($payment);
                     $dispatcher->dispatch(AntQaPaymentEvents::PAYMENT_STATUS_UPDATE, $event);
                     if ($result->order->status === Payment::STATUS_CANCELED) {
                         //payment canceled - eg. notify user?
                         $event = new PaymentEvent($payment);
                         $dispatcher->dispatch(AntQaPaymentEvents::PAYMENT_CANCELED, $event);
                     }
                     if ($result->order->status === Payment::STATUS_COMPLETED) {
                         //process payment action - eg. add user point?
                         $event = new PaymentEvent($payment);
                         $dispatcher->dispatch(AntQaPaymentEvents::PAYMENT_COMPLETED, $event);
                     }
                 }
             }
             $responseContent = \OpenPayU::buildOrderNotifyResponse($result->order->orderId);
             $response = new Response();
             $response->setContent($responseContent);
             $response->headers->add(['Content-Type' => 'application/json']);
             return $response;
         }
     } catch (\Exception $e) {
         $this->get('logger')->addError($e->getMessage());
         return new JsonResponse($e->getMessage());
     }
     return new Response('thanks for notice');
 }
 /**
  * @param array      $orderDetails
  * @param array|null $options
  *
  * @return RedirectResponse
  */
 public function createOrder(array $orderDetails = [], array $options = [])
 {
     $resolver = new OptionsResolver();
     $this->configureOrder($resolver);
     $this->orderDetails = $resolver->resolve($orderDetails);
     $response = \OpenPayU_Order::create($this->orderDetails);
     /** @var Payment $payment */
     $payment = new $this->class();
     $payment->setId($response->getResponse()->orderId)->setOrderId($response->getResponse()->extOrderId);
     if (!empty($options)) {
         $accessor = PropertyAccess::createPropertyAccessor();
         foreach ($options as $key => $value) {
             $accessor->setValue($payment, $key, $value);
         }
     }
     $this->em->persist($payment);
     $this->em->flush();
     return $this->redirectToUrl($response->getResponse()->redirectUri);
 }
    <title>Order Cancel - OpenPayU v2</title>
    <link rel="stylesheet" href="../../layout/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../layout/css/style.css">
</head>
</head>
<body>
<div class="container">
    <div class="page-header">
        <h1>Cancel order - OpenPayU v2</h1>
    </div>
    <div id="message"></div>
    <div id="unregisteredCardData">
        <?php 
if (isset($_POST['orderId'])) {
    try {
        $response = OpenPayU_Order::cancel(stripslashes($_POST['orderId']));
        $status_desc = OpenPayU_Util::statusDesc($response->getStatus());
        if ($response->getStatus() == 'SUCCESS') {
            echo '<div class="alert alert-success">SUCCESS: ' . $status_desc;
            echo '</div>';
        } else {
            echo '<div class="alert alert-warning">' . $response->getStatus() . ': ' . $status_desc;
            echo '</div>';
        }
        echo '<pre>';
        echo '<br>';
        print_r($response->getResponse());
        echo '</pre>';
    } catch (OpenPayU_Exception $e) {
        echo '<pre>';
        echo 'Error code: ' . $e->getCode();
 /**
  * Function consume message
  * @access public
  * @param string $xml
  * @param boolean $response Show Response Xml
  * @param boolean $debug
  * @return object $result
  */
 public static function consumeMessage($xml, $response = TRUE, $debug = TRUE)
 {
     $xml = stripslashes(urldecode($xml));
     $rq = OpenPayU::parseOpenPayUDocument($xml);
     $msg = $rq['OpenPayU']['OrderDomainRequest'];
     switch (key($msg)) {
         case 'OrderNotifyRequest':
             return OpenPayU_Order::consumeNotification($xml, $response, $debug);
             break;
         case 'ShippingCostRetrieveRequest':
             return OpenPayU_Order::consumeShippingCostRetrieveRequest($xml, $debug);
             break;
         default:
             return key($msg);
             break;
     }
 }
Beispiel #10
0
 *
 * @copyright  Copyright (c) 2013 PayU
 * @license    http://opensource.org/licenses/LGPL-3.0  Open Software License (LGPL 3.0)
 *
 * http://www.payu.com
 * http://openpayu.com
 * http://twitter.com/openpayu
 *
 */
include dirname(__FILE__) . '/../../../config/config.inc.php';
include dirname(__FILE__) . '/../../../init.php';
include dirname(__FILE__) . '/../../../header.php';
ob_clean();
if (Tools::getIsset('DOCUMENT')) {
    $data = Tools::getValue('DOCUMENT');
    $result = OpenPayU_Order::consumeMessage($data, false);
    if ($result->getMessage() == 'ShippingCostRetrieveRequest') {
        $id_payu_session = $result->getSessionId();
        $iso_country_code = $result->getCountryCode();
        $payu = new PayU();
        $order_payment = $payu->getOrderPaymentBySessionId($id_payu_session);
        $id_cart = $order_payment['id_cart'];
        if (!empty($id_cart)) {
            $payu->id_cart = $id_cart;
            $payu->payu_order_id = $id_payu_session;
            $payu->id_request = $result->getReqId();
            $xml = $payu->shippingCostRetrieveRequest($iso_country_code);
            if (!empty($xml)) {
                header('Content-Type:text/xml');
                echo $xml;
            }
<?php

/**
 * OpenPayU Examples
 *
 * @copyright  Copyright (c) 2011-2015 PayU
 * @license    http://opensource.org/licenses/LGPL-3.0  Open Software License (LGPL 3.0)
 * http://www.payu.com
 * http://developers.payu.com
 */
require_once realpath(dirname(__FILE__)) . '/../../../lib/openpayu.php';
require_once realpath(dirname(__FILE__)) . '/../../config.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $body = file_get_contents('php://input');
    $data = trim($body);
    try {
        if (!empty($data)) {
            $result = OpenPayU_Order::consumeNotification($data);
        }
        if ($result->getResponse()->order->orderId) {
            /* Check if OrderId exists in Merchant Service, update Order data by OrderRetrieveRequest */
            $order = OpenPayU_Order::retrieve($result->getResponse()->order->orderId);
            if ($order->getStatus() == 'SUCCESS') {
                //the response should be status 200
                header("HTTP/1.1 200 OK");
            }
        }
    } catch (OpenPayU_Exception $e) {
        echo $e->getMessage();
    }
}
Beispiel #12
0
 public function retrieve($id)
 {
     return \OpenPayU_Order::retrieve($id);
 }
Beispiel #13
0
 /**
  * Consume notification message
  *
  * @access public
  * @param $data Request array received from with PayU OrderNotifyRequest
  * @return null|OpenPayU_Result Response array with OrderNotifyRequest
  * @throws OpenPayU_Exception
  */
 public static function consumeNotification($data)
 {
     if (empty($data)) {
         throw new OpenPayU_Exception('Empty value of data');
     }
     $headers = OpenPayU_Util::getRequestHeaders();
     $incomingSignature = OpenPayU_HttpCurl::getSignature($headers);
     self::verifyDocumentSignature($data, $incomingSignature);
     return OpenPayU_Order::verifyResponse(array('response' => $data, 'code' => 200), 'OrderNotifyRequest');
 }
    <title>Order Retrieve - OpenPayU v2</title>
    <link rel="stylesheet" href="../../layout/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../layout/css/style.css">
</head>
</head>
<body>
<div class="container">
    <div class="page-header">
        <h1>Retrieve order's data - OpenPayU v2</h1>
    </div>
    <div id="message"></div>
    <div id="unregisteredCardData">
        <?php 
if (isset($_POST['orderId'])) {
    try {
        $response = OpenPayU_Order::retrieve(stripslashes($_POST['orderId']));
        $status_desc = OpenPayU_Util::statusDesc($response->getStatus());
        if ($response->getStatus() == 'SUCCESS') {
            echo '<div class="alert alert-success">SUCCESS: ' . $status_desc;
            echo '</div>';
            $order = $response->getResponse()->orders[0];
            echo '<table class="table table-hover table-bordered">';
            echo '<thead>';
            echo '<tr><th colspan="2">Important data from response</th></tr>';
            echo '</thead>';
            echo '<tbody>';
            echo '<tr><td>Order status</td><td>' . $order->status . '</td></tr>';
            echo '<tr><td>Order id</td><td>' . $order->orderId . '</td></tr>';
            echo '<tr><td>Redirect Uri</td><td><a href="' . $order->notifyUrl . '">' . $order->notifyUrl . '</a></td></tr>';
            echo '</tbody>';
            echo '</table>';
 public function testHostedOrderForm()
 {
     $expectedForm = file_get_contents(realpath(dirname(__FILE__)) . '/../../resources/hostedOrderForm.txt');
     $this->assertEquals($expectedForm, OpenPayU_Order::hostedOrderForm($this->_order));
 }
Beispiel #16
0
 public function expresscheckout()
 {
     ob_start();
     $this->load->model('checkout/order');
     $this->loadLibConfig();
     $cart = $this->cart->getProducts();
     if (empty($cart)) {
         $this->redirect($this->url->link('checkout/cart'));
     }
     $this->session->data['order_id'] = $this->collectData();
     $order = $this->buildorder();
     $result = OpenPayU_Order::create($order);
     ob_end_flush();
     if ($result->getStatus() == 'SUCCESS') {
         $this->session->data['sessionId'] = $result->getResponse()->orderId;
         $this->model_payment_payu->addOrder($this->session->data['order_id'], $this->session->data['sessionId']);
         $this->data['actionUrl'] = $result->getResponse()->redirectUri;
         header('Location:' . $this->data['actionUrl']);
     } else {
         $this->logger->write($result->getError() . ' [' . serialize($result->getResponse()) . ']');
         $this->redirect($this->url->link('checkout/cart'));
     }
 }
Beispiel #17
0
$order['merchantPosId'] = OpenPayU_Configuration::getMerchantPosId();
$order['description'] = 'New order';
$order['currencyCode'] = 'PLN';
$order['totalAmount'] = 3200;
$order['extOrderId'] = uniqid('', true);
$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';
$rsp = OpenPayU_Order::hostedOrderForm($order);
?>
<!doctype html>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title>Generated Order Form - OpenPayU v2</title>
    <link rel="stylesheet" href="../../layout/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../layout/css/style.css">
    <style type="text/css">
        #payu-payment-form button[type=submit]{
            border: 0px;
            height: 50px;
            width: 290px;
            background: url('http://static.payu.com/pl/standard/partners/buttons/payu_account_button_long_03.png') no-repeat;
            cursor: pointer;
Beispiel #18
0
 /**
  * @param string $data
  * @return \OpenPayU_Result
  * @throws \OpenPayU_Exception
  */
 public function orderConsumeNotification($data)
 {
     return \OpenPayU_Order::consumeNotification($data);
 }
 public function orderNotifyRequest()
 {
     $body = file_get_contents('php://input');
     $data = trim($body);
     $result = OpenPayU_Order::consumeNotification($data);
     $response = $result->getResponse();
     if ($response->order->orderId) {
         $this->_transactionId = $response->order->orderId;
         $extOrderIdExploded = $pieces = explode("-", $response->order->extOrderId);
         $orderId = $extOrderIdExploded[0];
         //            Mage::log(print_r($orderId, true),null, 'notification.log');
         $this->setOrderByOrderId($orderId);
         if ($response->order->status == 'COMPLETED' && $this->_order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING) {
             header("HTTP/1.1 200 OK");
             exit;
         }
         $this->retrieveAndUpdateByOrderRetrieved($response->order);
         //the response should be status 200
         header("HTTP/1.1 200 OK");
     }
     exit;
 }
 * @copyright  Copyright (c) 2013 PayU
 * @license    http://opensource.org/licenses/LGPL-3.0  Open Software License (LGPL 3.0)
 *
 * http://www.payu.com
 * http://openpayu.com
 * http://twitter.com/openpayu
 *
 */
include dirname(__FILE__) . '/../../../config/config.inc.php';
include dirname(__FILE__) . '/../../../init.php';
include dirname(__FILE__) . '/../../../header.php';
ob_clean();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $body = Tools::file_get_contents('php://input');
    $data = trim($body);
    $result = OpenPayU_Order::consumeNotification($data);
    $response = $result->getResponse();
    if (isset($response->order->orderId)) {
        $payu = new PayU();
        $payu->payu_order_id = $response->order->orderId;
        if (isset($response->properties[0]) && !empty($response->properties[0])) {
            if ($response->properties[0]->name == 'PAYMENT_ID' && isset($response->properties[0]->value)) {
                $payu->payu_payment_id = $response->properties[0]->value;
            }
        }
        $order_payment = $payu->getOrderPaymentBySessionId($payu->payu_order_id);
        $id_order = (int) $order_payment['id_order'];
        // if order not validated yet
        if ($id_order == 0 && $order_payment['status'] == PayU::PAYMENT_STATUS_NEW) {
            $cart = new Cart($order_payment['id_cart']);
            $payu->validateOrder($cart->id, (int) Configuration::get('PAYU_PAYMENT_STATUS_PENDING'), $cart->getOrderTotal(true, Cart::BOTH), $payu->displayName, 'PayU cart ID: ' . $cart->id . ', orderId: ' . $payu->payu_order_id, null, (int) $cart->id_currency, false, $cart->secure_key, Context::getContext()->shop->id ? new Shop((int) Context::getContext()->shop->id) : null);
Beispiel #21
0
 /**
  * Consume notification message
  *
  * @access public
  * @param $data Request array received from with PayU OrderNotifyRequest
  * @return null|OpenPayU_Result Response array with OrderNotifyRequest
  * @throws OpenPayU_Exception
  */
 public static function consumeNotification($data)
 {
     $sslConnection = self::isSecureConnection();
     if (empty($data)) {
         throw new OpenPayU_Exception('Empty value of data');
     }
     $headers = OpenPayU_Util::getRequestHeaders();
     $incomingSignature = OpenPayU_HttpCurl::getSignature($headers);
     if ($sslConnection) {
         self::verifyBasicAuthCredentials();
     } else {
         self::verifyDocumentSignature($data, $incomingSignature);
     }
     return OpenPayU_Order::verifyResponse(array('response' => $data, 'code' => 200), 'OrderNotifyRequest');
 }
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title>Create Order - OpenPayU v2</title>
    <link rel="stylesheet" href="../../layout/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../layout/css/style.css">
</head>

<body>
<div class="container">
    <div class="page-header">
        <h1>Create Order - OpenPayU v2</h1>
    </div>
    <?php 
try {
    $response = OpenPayU_Order::create($order);
    $status_desc = OpenPayU_Util::statusDesc($response->getStatus());
    if ($response->getStatus() == 'SUCCESS') {
        echo '<div class="alert alert-success">SUCCESS: ' . $status_desc;
        echo '</div>';
    } else {
        echo '<div class="alert alert-warning">' . $response->getStatus() . ': ' . $status_desc;
        echo '</div>';
    }
} catch (OpenPayU_Exception $e) {
    echo '<pre>';
    var_dump((string) $e);
    echo '</pre>';
}
?>
Beispiel #23
0
 public function orderNotifyRequest()
 {
     $body = file_get_contents('php://input');
     $data = trim($body);
     $result = OpenPayU_Order::consumeNotification($data);
     $response = $result->getResponse();
     $orderRetrieved = $response->order;
     if (isset($orderRetrieved) && is_object($orderRetrieved) && $orderRetrieved->orderId) {
         $this->_transactionId = $orderRetrieved->orderId;
         $extOrderIdExploded = explode(self::DELIMITER, $orderRetrieved->extOrderId);
         $orderId = array_shift($extOrderIdExploded);
         $this->setOrderByOrderId($orderId);
         if (isset($orderRetrieved->payMethod->type)) {
             $this->_payuPayMethod = $orderRetrieved->payMethod->type;
         }
         $payUPaymentStatus = $orderRetrieved->status;
         $this->_updatePaymentStatus($payUPaymentStatus);
         //the response should be status 200
         header("HTTP/1.1 200 OK");
     }
     exit;
 }
Beispiel #24
0
 /**
  *
  */
 public function updateOrderData($response_notification = null)
 {
     SimplePayuLogger::addLog('notification', __FUNCTION__, $this->l('Entrance:'), $this->payu_order_id);
     if (empty($this->payu_order_id)) {
         Logger::addLog($this->displayName . ' ' . $this->l('Can not get order information - id_session is empty'), 1);
     }
     $result = null;
     if ($response_notification) {
         $result = $response_notification;
     } else {
         $raw = OpenPayU_Order::retrieve($this->payu_order_id);
         $result = $raw->getResponse();
     }
     SimplePayuLogger::addLog('order', __FUNCTION__, print_r($result, true), $this->payu_order_id, 'OrderRetrieve response object: ');
     $response = $result;
     //        SimplePayuLogger::addLog('notification', __FUNCTION__, print_r($response, true), $this->payu_order_id);
     $payu_order = null;
     isset($response_notification) ? $payu_order = $response->order : ($payu_order = $response->orders[0]);
     if (isset($payu_order)) {
         if (!empty($this->id_order)) {
             $this->order = new Order($this->id_order);
             // Delivery address add
             if (!empty($payu_order->buyer)) {
                 $buyer = $payu_order->buyer;
                 if (isset($buyer->phone) && !empty($buyer->phone)) {
                     $buyer->delivery->{'recipientPhone'} = $buyer->phone;
                 }
                 $new_delivery_address_id = $this->addNewAddress($buyer->delivery);
                 if (!empty($new_delivery_address_id)) {
                     $this->order->id_address_delivery = $new_delivery_address_id;
                     $this->updateCustomizationAddress($new_delivery_address_id);
                 }
                 // Invoice address add
                 if (isset($payu_order->buyer->invoice)) {
                     if (isset($buyer->phone) && !empty($buyer->phone)) {
                         $buyer->invoice->{'recipientPhone'} = $buyer->phone;
                     }
                     $new_invoice_address_id = $this->addNewAddress($buyer->invoice);
                     if (!empty($new_invoice_address_id)) {
                         $this->order->id_address_invoice = $new_invoice_address_id;
                     }
                 }
             }
             SimplePayuLogger::addLog('notification', __FUNCTION__, $this->l('Order exists in PayU system '), $this->payu_order_id);
             if ($this->getCurrentPrestaOrderState() != 2) {
                 SimplePayuLogger::addLog('notification', __FUNCTION__, $this->l('Prestashop order statusIS NOT COMPLETED, go to status actualization'), $this->payu_order_id);
                 if ($this->order->update()) {
                     SimplePayuLogger::addLog('notification', __FUNCTION__, $this->l('Prestashop updated order status, go to PayU status update to: ') . $payu_order->status, $this->payu_order_id);
                     $this->updateOrderState(isset($payu_order->status) ? $payu_order->status : null);
                 }
             }
         }
     }
 }
    <link rel="stylesheet" href="../../layout/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../layout/css/style.css">
</head>
</head>
<body>
<div class="container">
    <div class="page-header">
        <h1>Order status update - OpenPayU v2</h1>
    </div>
    <div id="message"></div>
    <div id="unregisteredCardData">
        <?php 
if (isset($_POST['orderId'])) {
    try {
        $status_update = array("orderId" => stripslashes($_POST['orderId']), "orderStatus" => stripslashes($_POST['orderStatus']));
        $response = OpenPayU_Order::statusUpdate($status_update);
        $status_desc = OpenPayU_Util::statusDesc($response->getStatus());
        if ($response->getStatus() == 'SUCCESS') {
            echo '<div class="alert alert-success">SUCCESS: ' . $status_desc;
            echo '</div>';
        } else {
            echo '<div class="alert alert-warning">' . $response->getStatus() . ': ' . $status_desc;
            echo '</div>';
        }
        echo '<pre>';
        echo '<br>';
        print_r($response->getResponse());
        echo '</pre>';
    } catch (OpenPayU_Exception $e) {
        echo '<pre>';
        echo 'Error code: ' . $e->getCode();
Beispiel #26
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));
     }
 }