Skip to content

Commit

Permalink
Chore: Update deactivate authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
damilola-paystack committed Jan 22, 2024
1 parent 6fd60b2 commit c04ba17
Show file tree
Hide file tree
Showing 13 changed files with 253 additions and 6 deletions.
74 changes: 74 additions & 0 deletions dist/api/customers/deactivate-authorization/requests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const sh = `#!/bin/sh
url="https://api.paystack.co/customer/authorization/deactivate"
authorization="Authorization: Bearer YOUR_SECRET_KEY"
content_type="Content-Type: application/json"
data='{
"authorization_code": "AUTH_xxxIjkZVj5"
}'
curl "$url" -H "$authorization" -H "$content_type" -d "$data" -X POST`

const js = `const https = require('https')
const params = JSON.stringify({
"authorization_code": "AUTH_xxxIjkZVj5"
})
const options = {
hostname: 'api.paystack.co',
port: 443,
path: '/customer/authorization/deactivate',
method: 'POST',
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/customer/authorization/deactivate";
$fields = [
"authorization_code" => "AUTH_xxxIjkZVj5"
];
$fields_string = http_build_query($fields);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
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}
79 changes: 79 additions & 0 deletions dist/doc/payments/direct-debit/deactivate-authorization.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
const sh = `#!/bin/sh
curl https://api.paystack.co/customer/authorization/deactivate
-H "Authorization: Bearer YOUR_SECRET_KEY"
-H "Content-Type: application/json"
-d '{
"authorization_code": "AUTH_xxxIjkZVj5"
}'
-X POST`

const js = `const https = require('https')
const params = JSON.stringify({
"authorization_code": "AUTH_xxxIjkZVj5"
})
const options = {
hostname: 'api.paystack.co',
port: 443,
path: '/customer/authorization/deactivate',
method: 'POST',
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/customer/authorization/deactivate";
$fields = [
'authorization_code' => "AUTH_xxxIjkZVj5"
];
$fields_string = http_build_query($fields);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
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;
?>`

const json = `{
"status": true,
"message": "Authorization has been deactivated"
}
`

export {sh, js, php, json}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const https = require('https')

const params = JSON.stringify({
"authorization_code": "AUTH_72btv547"
"authorization_code": "AUTH_xxxIjkZVj5"
})

const options = {
hostname: 'api.paystack.co',
port: 443,
path: '/customer/deactivate_authorization',
path: '/customer/authorization/deactivate',
method: 'POST',
headers: {
Authorization: 'Bearer SECRET_KEY',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
$url = "https://api.paystack.co/customer/deactivate_authorization";
$url = "https://api.paystack.co/customer/authorization/deactivate";

$fields = [
"authorization_code" => "AUTH_72btv547"
"authorization_code" => "AUTH_xxxIjkZVj5"
];

$fields_string = http_build_query($fields);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh
url="https://api.paystack.co/customer/deactivate_authorization"
url="https://api.paystack.co/customer/authorization/deactivate"
authorization="Authorization: Bearer YOUR_SECRET_KEY"
content_type="Content-Type: application/json"
data='{
"authorization_code": "AUTH_72btv547"
"authorization_code": "AUTH_xxxIjkZVj5"
}'

curl "$url" -H "$authorization" -H "$content_type" -d "$data" -X POST
16 changes: 16 additions & 0 deletions src/api/customers/deactivate-authorization/response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"200": {
"description": "200 Ok",
"data": {
"status": true,
"message": "Authorization has been deactivated"
}
},
"404": {
"description": "404 Not Found",
"data": {
"status": false,
"message": "Authorization code not found."
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
languages:
- sh
- js
- php
- json
33 changes: 33 additions & 0 deletions src/doc/payments/direct-debit/deactivate-authorization/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const https = require('https')

const params = JSON.stringify({
"authorization_code": "AUTH_xxxIjkZVj5"
})

const options = {
hostname: 'api.paystack.co',
port: 443,
path: '/customer/authorization/deactivate',
method: 'POST',
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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"status": true,
"message": "Authorization has been deactivated"
}
28 changes: 28 additions & 0 deletions src/doc/payments/direct-debit/deactivate-authorization/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
$url = "https://api.paystack.co/customer/authorization/deactivate";

$fields = [
'authorization_code' => "AUTH_xxxIjkZVj5"
];

$fields_string = http_build_query($fields);

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
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;
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
curl https://api.paystack.co/customer/authorization/deactivate
-H "Authorization: Bearer YOUR_SECRET_KEY"
-H "Content-Type: application/json"
-d '{
"authorization_code": "AUTH_xxxIjkZVj5"
}'
-X POST

0 comments on commit c04ba17

Please sign in to comment.