-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
40 lines (33 loc) · 1.13 KB
/
example.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
Lets do it...
<?php
function HTTPPost($url, array $params) {
$query = http_build_query($params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$params = array();
$params['merchant_id'] = '<type your merchant_id>';
$params['access_key'] = '<type your access_key>';
$params['contract_number'] = '<type your contract_number>';
$params['return_url'] = 'http://101e98f8.ngrok.io/return_url';
$params['cancel_url'] = 'http://101e98f8.ngrok.io/cancel_url';
$params['notification_url'] = 'http://101e98f8.ngrok.io/notification_url';
$params['amount'] = 100;
$params['reference'] = 'my_reference';
$response = HTTPPost('http://101e98f8.ngrok.io/do_web_payment', $params);
$result = json_decode($response, true);
echo '<pre>';
var_dump($response);
echo '</pre>';
echo '<pre>';
var_dump($result);
echo '</pre>';
echo $result['result'];
echo $result['result']['code'];