-
Notifications
You must be signed in to change notification settings - Fork 0
/
pay.php
46 lines (41 loc) · 1.15 KB
/
pay.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
<?php
/**
* Payir utils
*
* @package enrol_payir
* @copyright 2021 Geraked
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function send($api, $amount, $redirect, $mobile = null, $factorNumber = null, $description = null)
{
return curl_post('https://pay.ir/pg/send', [
'api' => $api,
'amount' => $amount,
'redirect' => $redirect,
'mobile' => $mobile,
'factorNumber' => $factorNumber,
'description' => $description,
]);
}
function verify($api, $token)
{
return curl_post('https://pay.ir/pg/verify', [
'api' => $api,
'token' => $token,
]);
}
function curl_post($url, $params)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
]);
$res = curl_exec($ch);
curl_close($ch);
return $res;
}