Created
January 26, 2018 06:14
-
-
Save byhbt/7377f5a49bc4a52e555190f309c41e62 to your computer and use it in GitHub Desktop.
Thanh toán bằng thẻ cào
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_curl($url) | |
{ | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL, $url); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); | |
$str = curl_exec($curl); | |
if(empty($str)) $str = $this->curl_exec_follow($curl); | |
curl_close($curl); | |
return $str; | |
} | |
function signature_hash($parnerID, $secreckey, $telco, $serial, $mathe, $tranid) | |
{ | |
return md5($parnerID.'-'.$secreckey.'-'.$telco.'-'.$serial.'-'.$mathe.'-'.$tranid); | |
} | |
$status=''; | |
if(isset($_POST['fnapthe'])){ | |
$TxtCard = mysqli_escape_string($_POST['card_type_id']); | |
$TxtMaThe = mysqli_escape_string($_POST['pin']); | |
$TxtSeri= mysqli_escape_string($_POST['seri']); | |
$url = 'http://mpay123.com/CardCharge.ashx'; | |
$url .= '?partnerId=19'; | |
$url .= '&telco='.$TxtCard; | |
$url .= '&serial='.$TxtSeri; | |
$url .= '&cardcode='.$TxtMaThe; | |
$transid = rand().'_19'; | |
$url .= '&transId='.$transid; | |
$url .= '&key='.signature_hash(19,'609911968_H170981602116046_pay123',$TxtCard,$TxtSeri,$TxtMaThe,$transid); | |
$response = get_curl($url); | |
$result = json_decode($response); | |
$statuscard=intval($result->ResCode); | |
if($statuscard ==1){ | |
$status ='Nạp thẻ thành công mệnh giá: ' . $result->Amount; | |
} else { | |
$status='Nạp thẻ không thành công. Quý khách vui lòng liên hệ với xGemStore.com'; | |
} | |
} else { | |
$status=''; | |
} | |
?> | |
<html> | |
<head> | |
<title>Nạp thẻ xGemstore.com</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" /> | |
</head> | |
<body> | |
<div style="margin: 0 auto; width: 500px;"> | |
<h3>Hệ thống thanh toán thẻ tại <a target="_blank" href="http://xgemstore.com/">xGemStore</a></h3> | |
<p> | |
<div class="alert alert-danger" role="alert">Các bạn vui lòng giữ lại thẻ cào sau khi nạp.</div> | |
</p> | |
<form action="index.php" method="post" id="fnapthe" name="fnapthe"> | |
<input type="hidden" name="fnapthe" value="ok"/> | |
<table class="table table-condensed table-bordered"> | |
<tbody> | |
<tr> | |
<td>Loại thẻ</td> | |
<td> | |
<select name="card_type_id" style="width: 390px;border: 1px solid #ccc;height: 30px;"> | |
<option value="VTT">Viettel</option> | |
<option value="VMS">Mobiphone</option> | |
<option value="VNP">Vinaphone</option> | |
<option value="FPT">Gate</option> | |
<option value="VNM">Vietnammobile</option> | |
<option value="MGC">Megacard</option> | |
<option value="ONC">OnCash</option> | |
</select> | |
</td> | |
</tr> | |
<tr> | |
<td>Mã thẻ</td> | |
<td><input type="text" value="" name="pin" style="width: 390px;border: 1px solid #ccc;height: 30px;"/></td> | |
</tr> | |
<tr> | |
<td>Seri</td> | |
<td><input type="text" value="" name="seri" style="width: 390px;border: 1px solid #ccc;height: 30px;"/></td> | |
</tr> | |
</tbody> | |
</table> | |
<center> | |
<input class="btn btn-info" type="submit" value="Nạp thẻ"/> | |
<div id="loading_napthe" style="display: none; float: center"> Xin chờ trong giây lát...</div><br> | |
<div class="label label-success" id="msg_success_napthe"></div><br> | |
<div class="label label-danger" id="msg_err_napthe"><?php echo $status;?></div><br> | |
</center> | |
</form> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment