-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrequests.js
More file actions
73 lines (58 loc) · 1.55 KB
/
requests.js
File metadata and controls
73 lines (58 loc) · 1.55 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
const sh = `#!/bin/sh
curl https://api.paystack.co/directdebit/activation-charge
-H "Authorization: Bearer YOUR_SECRET_KEY"
-H "Content-Type: application/json"
-d '{
"customer_ids": [28958104, 983697220]
}'
-X PUT`
const js = `const https = require('https')
const params = JSON.stringify({
"customer_ids": [28958104, 983697220]
})
const options = {
hostname: 'api.paystack.co',
port: 443,
path: '/directdebit/activation-charge',
method: 'PUT',
headers: {
Authorization: 'Bearer SECRET_KEY',
'Content-Type': 'application/json'
}
}
const req = https.request(options, res => {
let data = ''
res.on('data', (chunk) => {
data += chunk
});
res.on('end', () => {
console.log(JSON.parse(data))
})
}).on('error', error => {
console.error(error)
})
req.write(params)
req.end()`
const php = `<?php
$url = "https://api.paystack.co/directdebit/activation-charge";
$fields = [
'customer_ids' => [28958104, 983697220]
];
$fields_string = http_build_query($fields);
//open connection
$ch = curl_init();
//set the url, PUT data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Authorization: Bearer SECRET_KEY",
"Cache-Control: no-cache",
));
//So that curl_exec returns the contents of the cURL; rather than echoing it
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
echo $result;
?>`
export {sh, js, php}