IppoPay
Search…
PHP Integration
IppoPay Payment Gateway for your Online Business.

Sample Integration - PHP

1
<!DOCTYPE html>
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6
<title>IppoPay</title>
7
</head>
8
<body>
9
<?php
10
$publicKey = 'pk_live_XXXXXXX';
11
$secretKey = 'sk_live_XXXXXXXXXXXXXX';
12
$data = "{
13
\"amount\": 2.00,
14
\"currency\": \"INR\",
15
\"payment_modes\": \"cc,dc,nb,upi\",
16
\"return_url\": \"\",
17
\"customer\": {
18
\"name\": \"Test\",
19
\"email\": \"[email protected]\",
20
\"phone\": {
21
\"country_code\": \"91\" ,
22
\"national_number\": \"9876543210\"
23
}
24
}
25
}";
26
$curl = curl_init();
27
curl_setopt_array($curl, array(
28
CURLOPT_URL => "https://".$publicKey.":".$secretKey."@api.ippopay.com/v1/order/create",
29
CURLOPT_RETURNTRANSFER => true,
30
CURLOPT_ENCODING => "",
31
CURLOPT_MAXREDIRS => 10,
32
CURLOPT_TIMEOUT => 0,
33
CURLOPT_FOLLOWLOCATION => true,
34
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
35
CURLOPT_CUSTOMREQUEST => "POST",
36
CURLOPT_SSL_VERIFYHOST => 0,
37
CURLOPT_SSL_VERIFYPEER => 0,
38
CURLOPT_POSTFIELDS => $data,
39
CURLOPT_HTTPHEADER => array(
40
"Content-Type: application/json"
41
),
42
));
43
$response = curl_exec($curl);
44
$err = curl_error($curl);
45
curl_close($curl);
46
if ($err) {
47
echo "cURL Error #:" . $err;
48
} else {
49
$array = json_decode($response,true);
50
$orderId = $array['data']['order']['order_id'];
51
}
52
53
?>
54
<script type="text/javascript" src="https://js.ippopay.com/scripts/ippopay.v1.js"></script>
55
<script type="text/javascript">
56
var order_id;
57
var options = {
58
"order_id" : "<?php echo $orderId; ?>",
59
"public_key" : "<?php echo $publicKey; ?>"
60
}
61
var ipay = new Ippopay(options);
62
ipay.open();
63
ippopayHandler(response, function (e) {
64
if(e.data.status == 'success'){
65
console.log(e.data);
66
}
67
if(e.data.status == 'failure'){
68
console.log(e.data);
69
}
70
});
71
</script>
72
</body>
73
</html>
Copied!

Author

This component is written by IppoPay.

License

IppoPay 2020 © All Rights Reserved. IppoPay
Last modified 9mo ago
Copy link