<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(); echo '<br>';
/** * Refund payment * * @param Varien_Object $payment * @param float $amount * @return $this */ public function refund(Varien_Object $payment, $amount) { $order = $payment->getOrder(); $this->_order = $order; $amount = $amount * 100; $result = OpenPayU_Refund::create($this->_order->getPayment()->getLastTransId(), 'Magento payu refund', $amount); Mage::log($result, null, 'orderRefund.log'); if ($result->getStatus() == 'SUCCESS') { return $this; } $serverMsg = OpenPayU_Util::statusDesc($result->getStatus()); $errorMsg = $this->_getHelper()->__($serverMsg); Mage::throwException($errorMsg); }
}) }) </script> <div class="container"> <div class="page-header"> <h1>Refund</h1> </div> <div id="message"></div> <div id="unregisteredCardData"> <?php if (isset($_POST['orderId'])) { $orderId = trim($_POST['orderId']); try { $refund = OpenPayU_Refund::create($orderId, $_POST['description'], isset($_POST['amount']) ? (int) $_POST['amount'] : null); $status_desc = OpenPayU_Util::statusDesc($refund->getStatus()); if ($refund->getStatus() == 'SUCCESS') { echo '<div class="alert alert-success">SUCCESS: ' . $status_desc; echo '</div>'; } else { echo '<div class="alert alert-warning">' . $refund->getStatus() . ': ' . $status_desc; echo '</div>'; } echo '<pre>'; echo '<br>'; print_r($refund->getResponse()); echo '</pre>'; } catch (OpenPayU_Exception $e) { echo '<pre>'; echo 'Error code: ' . $e->getCode(); echo '<br>';
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)); } }