public function getTranactionDetail($token) { $response = array("status" => 0, "message" => "Get Fail"); $obj = new \NL_MicroCheckout($this->uid, $this->secret, $this->banking_url); $inputs = array('token' => $token); $result = $obj->getExpressCheckout($inputs); if ($result["result_code"] == "00" && isset($result["transaction_status"]) && $result["transaction_status"] == 4) { $response = array("status" => 1, "message" => "Bạn đã nạp : " . $result["amount"] . " VNĐ. Vào tài khoản : " . $this->user["ch_nickname"], "old_partner_transaction" => $token, "partner_transaction" => $result["transaction_id"], "value" => $result["amount"], "promotion" => 0); } else { $response = array("status" => 0, "message" => "Giao Dịch Không Thành Công - Mã Lỗi : " . $result["result_code"] . "-" . $result["transaction_status"], "old_partner_transaction" => $token, "partner_transaction" => isset($result["transaction_id"]) ? $result["transaction_id"] : "", "value" => isset($result["amount"]) ? $result["amount"] : "", "promotion" => 0); } $response_log = $this->_endChargeBanking($response); return $response; }
$index = $_POST['index']; $name = $_POST['name']; $quanty = $_POST['quanty']; $price = $_POST['price']; $amount = 0; $items = array(); foreach ($index as $i) { $amount += $price[$i] * $quanty[$i]; $items[$i] = array('item_name' => $name[$i], 'item_quanty' => $quanty[$i], 'item_amount' => $price[$i]); } $return_url = 'http://www.cucre24h.com/noidungso/payment_success.php'; $cancel_url = 'http://www.cucre24h.com'; //$receiver = ''; $inputs = array('receiver' => RECEIVER, 'order_code' => 'Đơn hàng-' . date('His-dmY'), 'amount' => $amount, 'currency_code' => 'vnd', 'tax_amount' => '0', 'discount_amount' => '0', 'fee_shipping' => '0', 'request_confirm_shipping' => '0', 'no_shipping' => '1', 'return_url' => $return_url, 'cancel_url' => $cancel_url, 'language' => 'vn', 'items' => $items); $link_checkout = ''; $obj = new NL_MicroCheckout(MERCHANT_ID, MERCHANT_PASS, URL_WS); $result = $obj->setExpressCheckoutPayment($inputs); if ($result != false) { if ($result['result_code'] == '00') { $link_checkout = $result['link_checkout']; } else { die('Mã lỗi ' . $result['result_code'] . ' (' . $result['result_description'] . ') '); } } else { die('Lỗi kết nối tới cổng thanh toán Ngân Lượng'); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
@mysql_query($cmd); desession(); global $link; header('location:' . $link); } } // THANH TOÁN THẤT BẠI function fail() { desession(); global $link; echo '<meta charset="utf-8"/><script>alert("Giao dịch không thành công !"); window.location="' . $link . '";</script>'; } if ($_SESSION['payment'] == 'nganluong') { $obj = new NL_MicroCheckout(MERCHANT_ID, MERCHANT_PASS, URL_WS); if ($obj->checkReturnUrlAuto()) { $inputs = array('token' => $obj->getTokenCode()); $result = $obj->getExpressCheckout($inputs); if ($result != false) { if ($result['result_code'] != '00') { fail(); } } else { die('<meta charset="utf-8"/>Lỗi kết nối tới cổng thanh toán Ngân Lượng'); } } else { die('<meta charset="utf-8"/>Tham số truyền không đúng'); } $code = $_SESSION['code']; $pass = $_SESSION['pass'];
<? include('database.php'); include('include/lib/nusoap.php'); include('include/nganluong.microcheckout.class.php'); //khai bao $obj = new NL_MicroCheckout(MERCHANT_ID, MERCHANT_PASS, URL_WS); if ($obj->checkReturnUrlAuto()) { $inputs = array( 'token' => $obj->getTokenCode(),//$token_code, ); $result = $obj->getExpressCheckout($inputs); if ($result != false) { if ($result['result_code'] != '00') { die('Mã lỗi '.$result['result_code'].' ('.$result['result_description'].') '); } } else { die('Lỗi kết nối tới cổng thanh toán Ngân Lượng'); } } else { die('Tham số truyền không đúng'); } if (isset($result) && !empty($result)) { if ($result['result_code'] == '00') { $transaction_info = $result['method_payment_name']; $order_code = @$_GET['order_code']; $payment_id = $result['transaction_id']; $payment_type = $result['transaction_type'];
<? include("database.php"); include('include/lib/nusoap.php'); include('include/nganluong.microcheckout.class.php'); $order_id = 'MT-'.date('His-dmY').rand(1000, 9999); $inputs = array( 'receiver' => RECEIVER, 'order_code' => $order_id, 'return_url' => $_return_url, 'cancel_url' => '', 'language' => 'vn' ); $link_checkout = ''; $obj = new NL_MicroCheckout(MERCHANT_ID, MERCHANT_PASS, URL_WS); $result = $obj->setExpressCheckoutDeposit($inputs); if ($result != false) { if ($result['result_code'] == '00') { $link_checkout = $result['link_checkout']; $link_checkout = str_replace('micro_checkout.php?token=', 'index.php?portal=checkout&page=micro_checkout&token_code=', $link_checkout); } else { die('Ma loi '.$result['result_code'].' ('.$result['result_description'].') '); } } else { die('Loi ket noi toi cong thanh toan ngan luong'); } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />