forked from jaiiali/idpay-payment
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpayment.php
More file actions
51 lines (39 loc) · 1.03 KB
/
Copy pathpayment.php
File metadata and controls
51 lines (39 loc) · 1.03 KB
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
<?php
require_once('variables.php');
$params = array(
'order_id' => '101',
'amount' => 10000,
'phone' => '09382198592',
'name' => 'نام پرداخت کننده',
'desc' => 'توضیحات پرداخت کننده',
'callback' => URL_CALLBACK,
);
idpay_payment_create($params);
/**
* @param array $params
* @return bool
*/
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;
}
//.Redirect to payment form
header('Location:' . $result->link);
}