Skip to content

Commit a8d39a1

Browse files
Merge pull request #58 from PaystackOSS/feat-terminal
Chore: Add list bank snippet for Account Validation
2 parents 14aee15 + 41dfee2 commit a8d39a1

File tree

6 files changed

+510
-0
lines changed

6 files changed

+510
-0
lines changed
Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
const sh = `curl https://api.paystack.co/bank?currency=ZAR&enabled_for_verification=true
2+
-H "Authorization: Bearer YOUR_SECRET_KEY"
3+
-X GET`
4+
5+
const js = `const https = require('https')
6+
7+
const options = {
8+
hostname: 'api.paystack.co',
9+
port: 443,
10+
path: '/bank?currency=ZAR&enabled_for_verification=true',
11+
method: 'GET',
12+
headers: {
13+
Authorization: 'Bearer SECRET_KEY'
14+
}
15+
}
16+
17+
https.request(options, res => {
18+
let data = ''
19+
20+
res.on('data', (chunk) => {
21+
data += chunk
22+
});
23+
24+
res.on('end', () => {
25+
console.log(JSON.parse(data))
26+
})
27+
}).on('error', error => {
28+
console.error(error)
29+
})`
30+
31+
const php = `<?php
32+
33+
$curl = curl_init();
34+
35+
curl_setopt_array($curl, array(
36+
CURLOPT_URL => "https://api.paystack.co/bank?currency=ZAR&enabled_for_verification=true",
37+
CURLOPT_RETURNTRANSFER => true,
38+
CURLOPT_ENCODING => "",
39+
CURLOPT_MAXREDIRS => 10,
40+
CURLOPT_TIMEOUT => 30,
41+
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
42+
CURLOPT_CUSTOMREQUEST => "GET",
43+
CURLOPT_HTTPHEADER => array(
44+
"Authorization: Bearer SECRET_KEY",
45+
"Cache-Control: no-cache",
46+
),
47+
));
48+
49+
$response = curl_exec($curl);
50+
$err = curl_error($curl);
51+
52+
curl_close($curl);
53+
54+
if ($err) {
55+
echo "cURL Error #:" . $err;
56+
} else {
57+
echo $response;
58+
}
59+
?>`
60+
61+
const json = `{
62+
"status": true,
63+
"message": "Banks retrieved",
64+
"data": [
65+
{
66+
"id": 140,
67+
"name": "Absa Bank Limited, South Africa",
68+
"slug": "absa-za",
69+
"code": "632005",
70+
"longcode": "632005",
71+
"gateway": null,
72+
"pay_with_bank": false,
73+
"active": true,
74+
"country": "South Africa",
75+
"currency": "ZAR",
76+
"type": "basa",
77+
"is_deleted": false,
78+
"createdAt": "2020-09-04T10:38:56.000Z",
79+
"updatedAt": null,
80+
"supported_types": ["business", "personal"]
81+
},
82+
{
83+
"id": 141,
84+
"name": "African Bank Limited",
85+
"slug": "african-bank-za",
86+
"code": "430000",
87+
"longcode": "430000",
88+
"gateway": null,
89+
"pay_with_bank": false,
90+
"active": true,
91+
"country": "South Africa",
92+
"currency": "ZAR",
93+
"type": "basa",
94+
"is_deleted": false,
95+
"createdAt": "2020-09-04T10:38:56.000Z",
96+
"updatedAt": null,
97+
"supported_types": ["business", "personal"]
98+
},
99+
{
100+
"id": 146,
101+
"name": "Capitec Bank Limited",
102+
"slug": "capitec-bank-za",
103+
"code": "470010",
104+
"longcode": "470010",
105+
"gateway": null,
106+
"pay_with_bank": false,
107+
"active": true,
108+
"country": "South Africa",
109+
"currency": "ZAR",
110+
"type": "basa",
111+
"is_deleted": false,
112+
"createdAt": "2020-09-04T10:38:56.000Z",
113+
"updatedAt": null,
114+
"supported_types": ["personal"]
115+
},
116+
{
117+
"id": 147,
118+
"name": "Discovery Bank Limited",
119+
"slug": "discovery-bank-za",
120+
"code": "679000",
121+
"longcode": "679000",
122+
"gateway": null,
123+
"pay_with_bank": false,
124+
"active": true,
125+
"country": "South Africa",
126+
"currency": "ZAR",
127+
"type": "basa",
128+
"is_deleted": false,
129+
"createdAt": "2020-09-04T10:38:56.000Z",
130+
"updatedAt": null,
131+
"supported_types": ["business", "personal"]
132+
},
133+
{
134+
"id": 151,
135+
"name": "First National Bank",
136+
"slug": "first-national-bank-za",
137+
"code": "250655",
138+
"longcode": "250655",
139+
"gateway": null,
140+
"pay_with_bank": false,
141+
"active": true,
142+
"country": "South Africa",
143+
"currency": "ZAR",
144+
"type": "basa",
145+
"is_deleted": false,
146+
"createdAt": "2020-09-04T10:38:56.000Z",
147+
"updatedAt": null,
148+
"supported_types": ["business", "personal"]
149+
},
150+
{
151+
"id": 152,
152+
"name": "Grindrod Bank",
153+
"slug": "grindrod-bank-za",
154+
"code": "584000",
155+
"longcode": "584000",
156+
"gateway": null,
157+
"pay_with_bank": false,
158+
"active": true,
159+
"country": "South Africa",
160+
"currency": "ZAR",
161+
"type": "basa",
162+
"is_deleted": false,
163+
"createdAt": "2020-09-04T10:38:56.000Z",
164+
"updatedAt": null,
165+
"supported_types": ["business", "personal"]
166+
},
167+
{
168+
"id": 153,
169+
"name": "Investec Bank Ltd",
170+
"slug": "investec-bank-za",
171+
"code": "580105",
172+
"longcode": "580105",
173+
"gateway": null,
174+
"pay_with_bank": false,
175+
"active": true,
176+
"country": "South Africa",
177+
"currency": "ZAR",
178+
"type": "basa",
179+
"is_deleted": false,
180+
"createdAt": "2020-09-04T10:38:56.000Z",
181+
"updatedAt": null,
182+
"supported_types": ["business", "personal"]
183+
},
184+
{
185+
"id": 157,
186+
"name": "Nedbank",
187+
"slug": "nedbank-za",
188+
"code": "198765",
189+
"longcode": "198765",
190+
"gateway": null,
191+
"pay_with_bank": false,
192+
"active": true,
193+
"country": "South Africa",
194+
"currency": "ZAR",
195+
"type": "basa",
196+
"is_deleted": false,
197+
"createdAt": "2020-09-04T10:38:56.000Z",
198+
"updatedAt": null,
199+
"supported_types": ["business", "personal"]
200+
},
201+
{
202+
"id": 161,
203+
"name": "SASFIN Bank",
204+
"slug": "sasfin-bank-za",
205+
"code": "683000",
206+
"longcode": "683000",
207+
"gateway": null,
208+
"pay_with_bank": false,
209+
"active": true,
210+
"country": "South Africa",
211+
"currency": "ZAR",
212+
"type": "basa",
213+
"is_deleted": false,
214+
"createdAt": "2020-09-04T10:38:56.000Z",
215+
"updatedAt": null,
216+
"supported_types": ["business", "personal"]
217+
},
218+
{
219+
"id": 163,
220+
"name": "Standard Bank South Africa",
221+
"slug": "standard-bank-za",
222+
"code": "051001",
223+
"longcode": "051001",
224+
"gateway": null,
225+
"pay_with_bank": false,
226+
"active": true,
227+
"country": "South Africa",
228+
"currency": "ZAR",
229+
"type": "basa",
230+
"is_deleted": false,
231+
"createdAt": "2020-09-04T10:38:56.000Z",
232+
"updatedAt": null,
233+
"supported_types": ["business", "personal"]
234+
},
235+
{
236+
"id": 165,
237+
"name": "TymeBank",
238+
"slug": "tymebank-za",
239+
"code": "678910",
240+
"longcode": "678910",
241+
"gateway": null,
242+
"pay_with_bank": false,
243+
"active": true,
244+
"country": "South Africa",
245+
"currency": "ZAR",
246+
"type": "basa",
247+
"is_deleted": false,
248+
"createdAt": "2020-09-04T10:38:56.000Z",
249+
"updatedAt": null,
250+
"supported_types": ["business", "personal"]
251+
}
252+
]
253+
}`
254+
255+
export {sh, js, php, json}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
languages:
2+
- sh
3+
- js
4+
- php
5+
- json
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: '/bank?currency=ZAR&enabled_for_verification=true',
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+
})

0 commit comments

Comments
 (0)