-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSepehrPaySend.php
105 lines (77 loc) · 3.84 KB
/
SepehrPaySend.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
$EcommerceUrl = $_GET['EcommerceUrl'];
$MerchantID = $_GET['MerchantID'];
$Amount = $_GET['Amount'];
$Description = $_GET['Description'];
$Email = $_GET['Email'];
$Mobile = $_GET['Mobile'];
$Amount = (int)$Amount * 10;
// $newURL1 = 'aryaclub://eshop.aryaclub.com?key=transaction_id&level=0&result=';
$newURL1 = 'aryaclub://eshop.aryaclub.com?level=0&result=';
if ($Amount>=1000) {
if($MerchantID !="" && $EcommerceUrl !="" ){
$invoiceNumber = time();
$terminal = $MerchantID;
$CallbackURL = $EcommerceUrl.'SepehrPayGet.php'.'?Amount='.$Amount.'&MerchantID='.$MerchantID;
$params ='terminalID='.$terminal.'&Amount='.$Amount.'&callbackURL='.urlencode($CallbackURL).'&invoiceID='.$invoiceNumber;
if (!empty($Mobile)){
$params .= '&CellNumber=' . $Mobile;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://sepehr.shaparak.ir:8081/V1/PeymentApi/GetToken');
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
if($res)
{
$res = json_decode($res,true);
if($res['Status'] == '0')
{
echo '<form id="paymentUTLfrm" action="https://sepehr.shaparak.ir:8080" method="POST">
<input type="hidden" id="TerminalID" name="TerminalID" value="'.$terminal.'">
<input type="hidden" id="token" name="token" value="'.$res['Accesstoken'].'">
<input type="hidden" id="getMethod" name="getMethod" value="1">
</form>
<script>
function submitmabna() {
document.getElementById("paymentUTLfrm").submit();
}
window.onload=submitmabna;
</script>';
die;
die();
}else
{
// echo 'ERROR,'. 'خطا در ساخت توکن کد خطا :'.$res['Status'];
$res = 'پرداخت انجام نشد';
$msg = 'خطا در ساخت توکن کد خطا :'.$res['Status'];
$responseData = array('success' => 'ERROR1', 'message' => $res, 'tracking' => $msg, 'value' => 0);
header('Location: '.$newURL1.json_encode($responseData));
die();
die;
}
}
else
{
// echo 'ERROR,'. 'پورت 8081 در هاست شما بسته است !';
$res = 'پرداخت انجام نشد';
$msg = 'پورت 8081 در هاست شما بسته است !';
$responseData = array('success' => 'ERROR2', 'message' => $res, 'tracking' => $msg, 'value' => 0);
header('Location: '.$newURL1.json_encode($responseData));
die();
die;
}
}
}else{
// echo 'مبلغ سفارش کمتر از هزار ریال است';
$res = 'پرداخت انجام نشد';
$msg = 'مبلغ سفارش کمتر از هزار ریال است';
$responseData = array('success' => 'ERROR3', 'message' => $res, 'tracking' => $msg, 'value' => 0);
header('Location: '.$newURL1.json_encode($responseData));
die();
die;
// $ret=$msg;
}
?>