Skip to content

Commit 8b9b330

Browse files
Merge pull request #120 from tolu-paystack/docs/add-transfer-export
Add Transfer Export endpoint
2 parents f85bd52 + 48a3dd1 commit 8b9b330

7 files changed

Lines changed: 141 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
const sh = `#!/bin/sh
2+
url="https://api.paystack.co/transfer/export"
3+
authorization="Authorization: Bearer YOUR_SECRET_KEY"
4+
5+
curl "$url" -H "$authorization" -X GET
6+
`
7+
8+
const js = `const https = require('https')
9+
10+
const options = {
11+
hostname: 'api.paystack.co',
12+
port: 443,
13+
path: '/transfer/export',
14+
method: 'GET',
15+
headers: {
16+
Authorization: 'Bearer SECRET_KEY'
17+
}
18+
}
19+
20+
https.request(options, res => {
21+
let data = ''
22+
23+
res.on('data', (chunk) => {
24+
data += chunk
25+
});
26+
27+
res.on('end', () => {
28+
console.log(JSON.parse(data))
29+
})
30+
}).on('error', error => {
31+
console.error(error)
32+
})
33+
`
34+
35+
const php = `<?php
36+
$curl = curl_init();
37+
38+
curl_setopt_array($curl, array(
39+
CURLOPT_URL => "https://api.paystack.co/transfer/export",
40+
CURLOPT_RETURNTRANSFER => true,
41+
CURLOPT_ENCODING => "",
42+
CURLOPT_MAXREDIRS => 10,
43+
CURLOPT_TIMEOUT => 30,
44+
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
45+
CURLOPT_CUSTOMREQUEST => "GET",
46+
CURLOPT_HTTPHEADER => array(
47+
"Authorization: Bearer SECRET_KEY",
48+
"Cache-Control: no-cache",
49+
),
50+
));
51+
52+
$response = curl_exec($curl);
53+
$err = curl_error($curl);
54+
55+
curl_close($curl);
56+
57+
if ($err) {
58+
echo "cURL Error #:" . $err;
59+
} else {
60+
echo $response;
61+
}
62+
?>
63+
`
64+
65+
export {sh, js, php}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"status": true,
3+
"message": "Export successful",
4+
"data": {
5+
"path": "https://files.paystack.co/exports/100032/1460290758207.csv"
6+
}
7+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
languages:
2+
- sh
3+
- js
4+
- php

src/api/transfers/export/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const https = require('https')
2+
3+
const options = {
4+
hostname: 'api.paystack.co',
5+
port: 443,
6+
path: '/transfer/export',
7+
method: 'GET',
8+
headers: {
9+
Authorization: 'Bearer SECRET_KEY'
10+
}
11+
}
12+
13+
https.request(options, res => {
14+
let data = ''
15+
16+
res.on('data', (chunk) => {
17+
data += chunk
18+
});
19+
20+
res.on('end', () => {
21+
console.log(JSON.parse(data))
22+
})
23+
}).on('error', error => {
24+
console.error(error)
25+
})

src/api/transfers/export/index.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/transfer/export",
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+
?>

src/api/transfers/export/index.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
url="https://api.paystack.co/transfer/export"
3+
authorization="Authorization: Bearer YOUR_SECRET_KEY"
4+
5+
curl "$url" -H "$authorization" -X GET
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"status": true,
3+
"message": "Export successful",
4+
"data": {
5+
"path": "https://files.paystack.co/exports/100032/1460290758207.csv"
6+
}
7+
}

0 commit comments

Comments
 (0)