-
Notifications
You must be signed in to change notification settings - Fork 2
/
rave-standard.php
60 lines (51 loc) · 1.71 KB
/
rave-standard.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
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
//data required. You can check the doc for more options to add....
$postdata = array(
"tx_ref"=>uniqid().uniqid(),
"amount"=>"100",
"currency"=>"NGN",
"redirect_url"=>"https://webhook.site/9d0b00ba-9a69-44fa-a43d-a82c33c36fdc",
"payment_options"=>"card",
"meta"=> array(
"consumer_id"=>23,
"consumer_mac"=>"92a3-912ba-1192a"
),
"customer"=> array(
"email"=>"[email protected]",
"phonenumber"=>"080****4528",
"name"=>"Yemi Desola"
),
"customizations"=> array(
"title"=>"Pied Piper Payments",
"description"=>"Middleout isn't free. Pay the price",
"logo"=>"https://assets.piedpiper.com/logo.png"
)
);
//making a call to the endpoint....
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.flutterwave.com/v3/payments");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postdata)); //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 200);
curl_setopt($ch, CURLOPT_TIMEOUT, 200);
$secKey = 'FLWSECK_TEST-XXXXXXXXXXXXXXXXXXXXXXXX-X';
$token = 'Bearer '.$secKey;
$headers = array('Content-Type: application/json', 'Authorization:'.$token);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$request = curl_exec($ch);
$result = json_decode($request, true);
print_r($result);
echo $result['data']['link'];
header('location:'.$result['data']['link']);
// if ($request) {
// $result = json_decode($request, true);
// echo "<pre>";
// print_r($result);
// }else{
// if(curl_error($ch))
// {
// echo 'error:' . curl_error($ch);
// }
// }
curl_close($ch);