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

Sample Integration - PHP

1
<!DOCTYPE html>
2
<html>
3
<head>
4
<title>Payment</title>
5
<meta charset="utf-8"/>
6
</head>
7
<body>
8
<?php
9
$curl = curl_init();
10
curl_setopt_array($curl, array(
11
CURLOPT_URL => "https://foloosi.com/api/v1/api/initialize-setup",
12
CURLOPT_RETURNTRANSFER => true,
13
CURLOPT_ENCODING => "",
14
CURLOPT_MAXREDIRS => 10,
15
CURLOPT_TIMEOUT => 30,
16
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
17
CURLOPT_CUSTOMREQUEST => "POST",
18
CURLOPT_POSTFIELDS => "transaction_amount=1&currency=AED&customer_address=Address&customer_city=Dubai&billing_country=ARE&billing_state=Dubai&billing_postal_code=000000&customer_name=Test&customer_email=test%40email.com&customer_mobile=9876543210",
19
CURLOPT_HTTPHEADER => array(
20
"content-type: application/x-www-form-urlencoded",
21
"merchant_key: YOUR_MERCHANT_KEY"
22
),
23
));
24
$response = curl_exec($curl);
25
$err = curl_error($curl);
26
curl_close($curl);
27
if ($err) {
28
echo "cURL Error #:" . $err;
29
} else {
30
$responseData = json_decode($response,true);
31
$reference_token = $responseData['data']['reference_token'];
32
}
33
?>
34
<script type="text/javascript" src="https://www.foloosi.com/js/foloosipay.v2.js"></script>
35
<script type="text/javascript">
36
var reference_token = "<?= $reference_token; ?>";
37
var options = {
38
"reference_token" : reference_token,
39
"merchant_key" : "YOUR_MERCHANT_KEY"
40
41
}
42
var fp1 = new Foloosipay(options);
43
fp1.open();
44
foloosiHandler(response, function (e) {
45
if(e.data.status == 'success'){
46
console.log(e.data)
47
}
48
if(e.data.status == 'error'){
49
console.log(e.data)
50
}
51
if(e.data.status == 'closed'){
52
console.log(e.data)
53
}
54
});
55
</script>
56
</body>
57
</html>
Copied!
Last modified 9mo ago
Copy link