-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
47 lines (38 loc) · 1.01 KB
/
index.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
<?php
$amount = $_GET['amount'];
$name = "NAME";
$desc = "DESCRIPTION";
require_once('variables.php');
$params = array(
'order_id' => '101',
'amount' => $amount,
'phone' => '',
'name' => $name,
'desc' => $desc,
'callback' => URL_CALLBACK,
);
idpay_payment_create($params);
function idpay_payment_create($params)
{
$header = array(
'Content-Type: application/json',
'X-API-KEY:' . APIKEY,
'X-SANDBOX:' . SANDBOX,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, URL_PAYMENT);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result);
if (empty($result) || empty($result->link)) {
print 'Exception message:';
print '<pre>';
print_r($result);
print '</pre>';
return FALSE;
}
header('Location:' . $result->link);
}