Skip to content

Commit 10c7d02

Browse files
add php code snippet for list preauthorizations
1 parent 9b3460a commit 10c7d02

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

dist/api/preauthorization/list/requests.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,33 @@ const req = https.request(options, res => {
3131
})
3232
req.end()`
3333

34-
export {sh, js}
34+
const php = `<?php
35+
$curl = curl_init();
36+
37+
curl_setopt_array($curl, array(
38+
CURLOPT_URL => "https://api.paystack.co/preauthorization",
39+
CURLOPT_RETURNTRANSFER => true,
40+
CURLOPT_ENCODING => "",
41+
CURLOPT_MAXREDIRS => 10,
42+
CURLOPT_TIMEOUT => 30,
43+
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
44+
CURLOPT_CUSTOMREQUEST => "GET",
45+
CURLOPT_HTTPHEADER => array(
46+
"Authorization: Bearer SECRET_KEY",
47+
"Cache-Control: no-cache",
48+
),
49+
));
50+
51+
$response = curl_exec($curl);
52+
$err = curl_error($curl);
53+
54+
curl_close($curl);
55+
56+
if ($err) {
57+
echo "cURL Error #:" . $err;
58+
} else {
59+
echo $response;
60+
}
61+
?>`
62+
63+
export {sh, js, php}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
languages:
22
- sh
3-
- js
3+
- js
4+
- php
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
$curl = curl_init();
3+
4+
curl_setopt_array($curl, array(
5+
CURLOPT_URL => "https://api.paystack.co/preauthorization",
6+
CURLOPT_RETURNTRANSFER => true,
7+
CURLOPT_ENCODING => "",
8+
CURLOPT_MAXREDIRS => 10,
9+
CURLOPT_TIMEOUT => 30,
10+
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
11+
CURLOPT_CUSTOMREQUEST => "GET",
12+
CURLOPT_HTTPHEADER => array(
13+
"Authorization: Bearer SECRET_KEY",
14+
"Cache-Control: no-cache",
15+
),
16+
));
17+
18+
$response = curl_exec($curl);
19+
$err = curl_error($curl);
20+
21+
curl_close($curl);
22+
23+
if ($err) {
24+
echo "cURL Error #:" . $err;
25+
} else {
26+
echo $response;
27+
}
28+
?>

0 commit comments

Comments
 (0)