Skip to content

Commit 0f8d6c2

Browse files
Merge pull request #55 from PaystackOSS/patch-dd
Chore: Update deactivate authorization
2 parents 6fd60b2 + c04ba17 commit 0f8d6c2

File tree

13 files changed

+253
-6
lines changed

13 files changed

+253
-6
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
const sh = `#!/bin/sh
2+
url="https://api.paystack.co/customer/authorization/deactivate"
3+
authorization="Authorization: Bearer YOUR_SECRET_KEY"
4+
content_type="Content-Type: application/json"
5+
data='{
6+
"authorization_code": "AUTH_xxxIjkZVj5"
7+
}'
8+
9+
curl "$url" -H "$authorization" -H "$content_type" -d "$data" -X POST`
10+
11+
const js = `const https = require('https')
12+
13+
const params = JSON.stringify({
14+
"authorization_code": "AUTH_xxxIjkZVj5"
15+
})
16+
17+
const options = {
18+
hostname: 'api.paystack.co',
19+
port: 443,
20+
path: '/customer/authorization/deactivate',
21+
method: 'POST',
22+
headers: {
23+
Authorization: 'Bearer SECRET_KEY',
24+
'Content-Type': 'application/json'
25+
}
26+
}
27+
28+
const req = https.request(options, res => {
29+
let data = ''
30+
31+
res.on('data', (chunk) => {
32+
data += chunk
33+
});
34+
35+
res.on('end', () => {
36+
console.log(JSON.parse(data))
37+
})
38+
}).on('error', error => {
39+
console.error(error)
40+
})
41+
42+
req.write(params)
43+
req.end()`
44+
45+
const php = `<?php
46+
$url = "https://api.paystack.co/customer/authorization/deactivate";
47+
48+
$fields = [
49+
"authorization_code" => "AUTH_xxxIjkZVj5"
50+
];
51+
52+
$fields_string = http_build_query($fields);
53+
54+
//open connection
55+
$ch = curl_init();
56+
57+
//set the url, number of POST vars, POST data
58+
curl_setopt($ch,CURLOPT_URL, $url);
59+
curl_setopt($ch,CURLOPT_POST, true);
60+
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
61+
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
62+
"Authorization: Bearer SECRET_KEY",
63+
"Cache-Control: no-cache",
64+
));
65+
66+
//So that curl_exec returns the contents of the cURL; rather than echoing it
67+
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
68+
69+
//execute post
70+
$result = curl_exec($ch);
71+
echo $result;
72+
?>`
73+
74+
export {sh, js, php}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
const sh = `#!/bin/sh
2+
curl https://api.paystack.co/customer/authorization/deactivate
3+
-H "Authorization: Bearer YOUR_SECRET_KEY"
4+
-H "Content-Type: application/json"
5+
-d '{
6+
"authorization_code": "AUTH_xxxIjkZVj5"
7+
}'
8+
-X POST`
9+
10+
const js = `const https = require('https')
11+
12+
const params = JSON.stringify({
13+
"authorization_code": "AUTH_xxxIjkZVj5"
14+
})
15+
16+
const options = {
17+
hostname: 'api.paystack.co',
18+
port: 443,
19+
path: '/customer/authorization/deactivate',
20+
method: 'POST',
21+
headers: {
22+
Authorization: 'Bearer SECRET_KEY',
23+
'Content-Type': 'application/json'
24+
}
25+
}
26+
27+
const req = https.request(options, res => {
28+
let data = ''
29+
30+
res.on('data', (chunk) => {
31+
data += chunk
32+
});
33+
34+
res.on('end', () => {
35+
console.log(JSON.parse(data))
36+
})
37+
}).on('error', error => {
38+
console.error(error)
39+
})
40+
41+
req.write(params)
42+
req.end()`
43+
44+
const php = `<?php
45+
$url = "https://api.paystack.co/customer/authorization/deactivate";
46+
47+
$fields = [
48+
'authorization_code' => "AUTH_xxxIjkZVj5"
49+
];
50+
51+
$fields_string = http_build_query($fields);
52+
53+
//open connection
54+
$ch = curl_init();
55+
56+
//set the url, number of POST vars, POST data
57+
curl_setopt($ch,CURLOPT_URL, $url);
58+
curl_setopt($ch,CURLOPT_POST, true);
59+
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
60+
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
61+
"Authorization: Bearer SECRET_KEY",
62+
"Cache-Control: no-cache",
63+
));
64+
65+
//So that curl_exec returns the contents of the cURL; rather than echoing it
66+
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
67+
68+
//execute post
69+
$result = curl_exec($ch);
70+
echo $result;
71+
?>`
72+
73+
const json = `{
74+
"status": true,
75+
"message": "Authorization has been deactivated"
76+
}
77+
`
78+
79+
export {sh, js, php, json}

src/api/customers/deactivate_authorization/index.js renamed to src/api/customers/deactivate-authorization/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const https = require('https')
22

33
const params = JSON.stringify({
4-
"authorization_code": "AUTH_72btv547"
4+
"authorization_code": "AUTH_xxxIjkZVj5"
55
})
66

77
const options = {
88
hostname: 'api.paystack.co',
99
port: 443,
10-
path: '/customer/deactivate_authorization',
10+
path: '/customer/authorization/deactivate',
1111
method: 'POST',
1212
headers: {
1313
Authorization: 'Bearer SECRET_KEY',

src/api/customers/deactivate_authorization/index.php renamed to src/api/customers/deactivate-authorization/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
2-
$url = "https://api.paystack.co/customer/deactivate_authorization";
2+
$url = "https://api.paystack.co/customer/authorization/deactivate";
33

44
$fields = [
5-
"authorization_code" => "AUTH_72btv547"
5+
"authorization_code" => "AUTH_xxxIjkZVj5"
66
];
77

88
$fields_string = http_build_query($fields);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/sh
2-
url="https://api.paystack.co/customer/deactivate_authorization"
2+
url="https://api.paystack.co/customer/authorization/deactivate"
33
authorization="Authorization: Bearer YOUR_SECRET_KEY"
44
content_type="Content-Type: application/json"
55
data='{
6-
"authorization_code": "AUTH_72btv547"
6+
"authorization_code": "AUTH_xxxIjkZVj5"
77
}'
88

99
curl "$url" -H "$authorization" -H "$content_type" -d "$data" -X POST
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"200": {
3+
"description": "200 Ok",
4+
"data": {
5+
"status": true,
6+
"message": "Authorization has been deactivated"
7+
}
8+
},
9+
"404": {
10+
"description": "404 Not Found",
11+
"data": {
12+
"status": false,
13+
"message": "Authorization code not found."
14+
}
15+
}
16+
}
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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const https = require('https')
2+
3+
const params = JSON.stringify({
4+
"authorization_code": "AUTH_xxxIjkZVj5"
5+
})
6+
7+
const options = {
8+
hostname: 'api.paystack.co',
9+
port: 443,
10+
path: '/customer/authorization/deactivate',
11+
method: 'POST',
12+
headers: {
13+
Authorization: 'Bearer SECRET_KEY',
14+
'Content-Type': 'application/json'
15+
}
16+
}
17+
18+
const req = https.request(options, res => {
19+
let data = ''
20+
21+
res.on('data', (chunk) => {
22+
data += chunk
23+
});
24+
25+
res.on('end', () => {
26+
console.log(JSON.parse(data))
27+
})
28+
}).on('error', error => {
29+
console.error(error)
30+
})
31+
32+
req.write(params)
33+
req.end()

0 commit comments

Comments
 (0)