From fd4a75c437785aaef3f340fc1a47aa890085f919 Mon Sep 17 00:00:00 2001 From: Damilola Odujoko Date: Thu, 26 Jun 2025 11:18:47 +0100 Subject: [PATCH] Chore: Update DD code snippets --- .../requests.js | 73 +++++++++++++ .../response.json | 9 ++ .../fetch-mandate-authorization/requests.js | 62 +++++++++++ .../fetch-mandate-authorization/response.json | 36 +++++++ .../initialize-direct-debit/requests.js | 98 +++++++++++++++++ .../initialize-direct-debit/response.json | 14 +++ .../activation-charge/requests.js | 73 +++++++++++++ .../activation-charge/response.json | 9 ++ .../list-authorizations/requests.js | 62 +++++++++++ .../list-authorizations/response.json | 36 +++++++ .../direct-debit/initialize-transaction.js | 102 ++++++++++++++++++ dist/doc/payments/direct-debit/initialize.js | 2 +- .../direct-debit/pending-authorization-1.js | 78 ++++++++++++++ .../direct-debit/pending-authorization-2.js | 78 ++++++++++++++ .../direct-debit-activation-charge/config.yml | 4 + .../direct-debit-activation-charge/index.js | 33 ++++++ .../direct-debit-activation-charge/index.php | 28 +++++ .../direct-debit-activation-charge/index.sh | 8 ++ .../response.json | 9 ++ .../fetch-mandate-authorization/config.yml | 4 + .../fetch-mandate-authorization/index.js | 25 +++++ .../fetch-mandate-authorization/index.php | 28 +++++ .../fetch-mandate-authorization/index.sh | 5 + .../fetch-mandate-authorization/response.json | 36 +++++++ .../initialize-direct-debit/config.yml | 4 + .../initialize-direct-debit/index.js | 41 +++++++ .../initialize-direct-debit/index.php | 36 +++++++ .../initialize-direct-debit/index.sh | 17 +++ .../initialize-direct-debit/response.json | 14 +++ .../direct-debit/activation-charge/config.yml | 4 + .../direct-debit/activation-charge/index.js | 33 ++++++ .../direct-debit/activation-charge/index.php | 28 +++++ .../direct-debit/activation-charge/index.sh | 8 ++ .../activation-charge/response.json | 9 ++ .../list-authorizations/config.yml | 4 + .../direct-debit/list-authorizations/index.js | 25 +++++ .../list-authorizations/index.php | 28 +++++ .../direct-debit/list-authorizations/index.sh | 5 + .../list-authorizations/response.json | 36 +++++++ .../initialize-transaction/config.yml | 5 + .../initialize-transaction/index.js | 40 +++++++ .../initialize-transaction/index.json | 9 ++ .../initialize-transaction/index.php | 35 ++++++ .../initialize-transaction/index.sh | 13 +++ .../direct-debit/initialize/index.php | 2 +- .../pending-authorization-1/config.yml | 5 + .../pending-authorization-1/index.js | 33 ++++++ .../pending-authorization-1/index.json | 4 + .../pending-authorization-1/index.php | 28 +++++ .../pending-authorization-1/index.sh | 8 ++ .../pending-authorization-2/config.yml | 5 + .../pending-authorization-2/index.js | 33 ++++++ .../pending-authorization-2/index.json | 4 + .../pending-authorization-2/index.php | 28 +++++ .../pending-authorization-2/index.sh | 8 ++ 55 files changed, 1462 insertions(+), 2 deletions(-) create mode 100644 dist/api/customers/direct-debit-activation-charge/requests.js create mode 100644 dist/api/customers/direct-debit-activation-charge/response.json create mode 100644 dist/api/customers/fetch-mandate-authorization/requests.js create mode 100644 dist/api/customers/fetch-mandate-authorization/response.json create mode 100644 dist/api/customers/initialize-direct-debit/requests.js create mode 100644 dist/api/customers/initialize-direct-debit/response.json create mode 100644 dist/api/direct-debit/activation-charge/requests.js create mode 100644 dist/api/direct-debit/activation-charge/response.json create mode 100644 dist/api/direct-debit/list-authorizations/requests.js create mode 100644 dist/api/direct-debit/list-authorizations/response.json create mode 100644 dist/doc/payments/direct-debit/initialize-transaction.js create mode 100644 dist/doc/payments/direct-debit/pending-authorization-1.js create mode 100644 dist/doc/payments/direct-debit/pending-authorization-2.js create mode 100644 src/api/customers/direct-debit-activation-charge/config.yml create mode 100644 src/api/customers/direct-debit-activation-charge/index.js create mode 100644 src/api/customers/direct-debit-activation-charge/index.php create mode 100644 src/api/customers/direct-debit-activation-charge/index.sh create mode 100644 src/api/customers/direct-debit-activation-charge/response.json create mode 100644 src/api/customers/fetch-mandate-authorization/config.yml create mode 100644 src/api/customers/fetch-mandate-authorization/index.js create mode 100644 src/api/customers/fetch-mandate-authorization/index.php create mode 100644 src/api/customers/fetch-mandate-authorization/index.sh create mode 100644 src/api/customers/fetch-mandate-authorization/response.json create mode 100644 src/api/customers/initialize-direct-debit/config.yml create mode 100644 src/api/customers/initialize-direct-debit/index.js create mode 100644 src/api/customers/initialize-direct-debit/index.php create mode 100644 src/api/customers/initialize-direct-debit/index.sh create mode 100644 src/api/customers/initialize-direct-debit/response.json create mode 100644 src/api/direct-debit/activation-charge/config.yml create mode 100644 src/api/direct-debit/activation-charge/index.js create mode 100644 src/api/direct-debit/activation-charge/index.php create mode 100644 src/api/direct-debit/activation-charge/index.sh create mode 100644 src/api/direct-debit/activation-charge/response.json create mode 100644 src/api/direct-debit/list-authorizations/config.yml create mode 100644 src/api/direct-debit/list-authorizations/index.js create mode 100644 src/api/direct-debit/list-authorizations/index.php create mode 100644 src/api/direct-debit/list-authorizations/index.sh create mode 100644 src/api/direct-debit/list-authorizations/response.json create mode 100644 src/doc/payments/direct-debit/initialize-transaction/config.yml create mode 100644 src/doc/payments/direct-debit/initialize-transaction/index.js create mode 100644 src/doc/payments/direct-debit/initialize-transaction/index.json create mode 100644 src/doc/payments/direct-debit/initialize-transaction/index.php create mode 100644 src/doc/payments/direct-debit/initialize-transaction/index.sh create mode 100644 src/doc/payments/direct-debit/pending-authorization-1/config.yml create mode 100644 src/doc/payments/direct-debit/pending-authorization-1/index.js create mode 100644 src/doc/payments/direct-debit/pending-authorization-1/index.json create mode 100644 src/doc/payments/direct-debit/pending-authorization-1/index.php create mode 100644 src/doc/payments/direct-debit/pending-authorization-1/index.sh create mode 100644 src/doc/payments/direct-debit/pending-authorization-2/config.yml create mode 100644 src/doc/payments/direct-debit/pending-authorization-2/index.js create mode 100644 src/doc/payments/direct-debit/pending-authorization-2/index.json create mode 100644 src/doc/payments/direct-debit/pending-authorization-2/index.php create mode 100644 src/doc/payments/direct-debit/pending-authorization-2/index.sh diff --git a/dist/api/customers/direct-debit-activation-charge/requests.js b/dist/api/customers/direct-debit-activation-charge/requests.js new file mode 100644 index 0000000..100e983 --- /dev/null +++ b/dist/api/customers/direct-debit-activation-charge/requests.js @@ -0,0 +1,73 @@ +const sh = `#!/bin/sh +curl https://api.paystack.co/customer/{id}/directdebit-activation-charge +-H "Authorization: Bearer YOUR_SECRET_KEY" +-H "Content-Type: application/json" +-d '{ + "authorization_id" : 1069309917 + }' +-X PUT` + +const js = `const https = require('https') + +const params = JSON.stringify({ + "authorization_id" : 1069309917 +}) + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/customer/{id}/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 = ` 1069309917 + ]; + + $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} \ No newline at end of file diff --git a/dist/api/customers/direct-debit-activation-charge/response.json b/dist/api/customers/direct-debit-activation-charge/response.json new file mode 100644 index 0000000..f2d2d27 --- /dev/null +++ b/dist/api/customers/direct-debit-activation-charge/response.json @@ -0,0 +1,9 @@ +{ + "200": { + "description": "200 Ok", + "data": { + "status": true, + "message": "Mandate is queued for retry" + } + } +} diff --git a/dist/api/customers/fetch-mandate-authorization/requests.js b/dist/api/customers/fetch-mandate-authorization/requests.js new file mode 100644 index 0000000..de4b5de --- /dev/null +++ b/dist/api/customers/fetch-mandate-authorization/requests.js @@ -0,0 +1,62 @@ +const sh = `#!/bin/sh +url="https://api.paystack.co/customer/{id}/directdebit-mandate-authorizations" +authorization="Authorization: Bearer YOUR_SECRET_KEY" + +curl "$url" -H "$authorization" -X GET` + +const js = `const https = require('https') + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/customer/{id}/directdebit-mandate-authorizations', + method: 'GET', + headers: { + Authorization: 'Bearer SECRET_KEY' + } +} + +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) +})` + +const php = ` "https://api.paystack.co//customer/{id}/directdebit-mandate-authorizations", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_HTTPHEADER => array( + "Authorization: Bearer SECRET_KEY", + "Cache-Control: no-cache", + ), + )); + + $response = curl_exec($curl); + $err = curl_error($curl); + + curl_close($curl); + + if ($err) { + echo "cURL Error #:" . $err; + } else { + echo $response; + } +?>` + +export {sh, js, php} \ No newline at end of file diff --git a/dist/api/customers/fetch-mandate-authorization/response.json b/dist/api/customers/fetch-mandate-authorization/response.json new file mode 100644 index 0000000..e96179b --- /dev/null +++ b/dist/api/customers/fetch-mandate-authorization/response.json @@ -0,0 +1,36 @@ +{ + "200": { + "description": "200 Ok", + "data": { + "status": true, + "message": "Mandate authorizations retrieved successfully", + "data": [ + { + "id": 164098, + "status": "active", + "mandate_id": 512003, + "authorization_id": 110049014, + "authorization_code": "AUTH_8Lol0pNt14", + "integration_id": 463433, + "account_number": "0123456789", + "bank_code": "032", + "bank_name": null, + "customer": { + "id": 43975700, + "customer_code": "CUS_2eusy8uwe34s23fy", + "email": "customer@email.com", + "first_name": "Smith", + "last_name": "Bel" + }, + "authorized_at": "2024-09-27T10:57:53.824Z" + } + ], + "meta": { + "per_page": 50, + "next": null, + "count": 1, + "total": 1 + } + } + } +} diff --git a/dist/api/customers/initialize-direct-debit/requests.js b/dist/api/customers/initialize-direct-debit/requests.js new file mode 100644 index 0000000..1191e9b --- /dev/null +++ b/dist/api/customers/initialize-direct-debit/requests.js @@ -0,0 +1,98 @@ +const sh = `#!/bin/sh +url="https://api.paystack.co/customer/{id}/initialize-direct-debit" +authorization="Authorization: Bearer YOUR_SECRET_KEY" +content_type="Content-Type: application/json" +data='{ + "account": { + "number": "0123456789", + "bank_code": "058" + }, + "address": { + "street": "Some Where", + "city": "Ikeja", + "state": "Lagos" + } +}' + +curl "$url" -H "$authorization" -H "$content_type" -d "$data" -X POST` + +const js = `const https = require('https') + +const params = JSON.stringify({ + "account": { + "number": "0123456789", + "bank_code": "058" + }, + "address": { + "street": "Some Where", + "city": "Ikeja", + "state": "Lagos" + } +}) + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/customer/{id}/initialize-direct-debit', + 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 = ` [ + 'number' => '0123456789', + 'bank_code' => '058' + ], + 'address' => [ + 'street' => 'Some Where', + 'city' => 'Ikeja', + 'state' => 'Lagos' + ] + ]; + + $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} \ No newline at end of file diff --git a/dist/api/customers/initialize-direct-debit/response.json b/dist/api/customers/initialize-direct-debit/response.json new file mode 100644 index 0000000..f0cc001 --- /dev/null +++ b/dist/api/customers/initialize-direct-debit/response.json @@ -0,0 +1,14 @@ +{ + "200": { + "description": "200 Ok", + "data": { + "status": true, + "message": "Authorization initialized", + "data": { + "redirect_url": "https://link.paystack.com/ll6b0szngj1f27k", + "access_code": "ll6b0szngj1f27k", + "reference": "1er945lpy4txyki" + } + } + } +} diff --git a/dist/api/direct-debit/activation-charge/requests.js b/dist/api/direct-debit/activation-charge/requests.js new file mode 100644 index 0000000..5c05451 --- /dev/null +++ b/dist/api/direct-debit/activation-charge/requests.js @@ -0,0 +1,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 = ` [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} \ No newline at end of file diff --git a/dist/api/direct-debit/activation-charge/response.json b/dist/api/direct-debit/activation-charge/response.json new file mode 100644 index 0000000..f2d2d27 --- /dev/null +++ b/dist/api/direct-debit/activation-charge/response.json @@ -0,0 +1,9 @@ +{ + "200": { + "description": "200 Ok", + "data": { + "status": true, + "message": "Mandate is queued for retry" + } + } +} diff --git a/dist/api/direct-debit/list-authorizations/requests.js b/dist/api/direct-debit/list-authorizations/requests.js new file mode 100644 index 0000000..69d0a73 --- /dev/null +++ b/dist/api/direct-debit/list-authorizations/requests.js @@ -0,0 +1,62 @@ +const sh = `#!/bin/sh +url="https://api.paystack.co/directdebit/mandate-authorizations" +authorization="Authorization: Bearer YOUR_SECRET_KEY" + +curl "$url" -H "$authorization" -X GET` + +const js = `const https = require('https') + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/directdebit/mandate-authorizations', + method: 'GET', + headers: { + Authorization: 'Bearer SECRET_KEY' + } +} + +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) +})` + +const php = ` "https://api.paystack.co/directdebit/mandate-authorizations", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_HTTPHEADER => array( + "Authorization: Bearer SECRET_KEY", + "Cache-Control: no-cache", + ), + )); + + $response = curl_exec($curl); + $err = curl_error($curl); + + curl_close($curl); + + if ($err) { + echo "cURL Error #:" . $err; + } else { + echo $response; + } +?>` + +export {sh, js, php} \ No newline at end of file diff --git a/dist/api/direct-debit/list-authorizations/response.json b/dist/api/direct-debit/list-authorizations/response.json new file mode 100644 index 0000000..3e4047b --- /dev/null +++ b/dist/api/direct-debit/list-authorizations/response.json @@ -0,0 +1,36 @@ +{ + "200": { + "description": "200 Ok", + "data": { + "status": true, + "message": "Mandate authorizations retrieved successfully", + "data": [ + { + "id": 112244, + "status": "active", + "mandate_id": 1560169, + "authorization_id": 1069309917, + "authorization_code": "AUTH_lEt8QgrSfW", + "integration_id": 463433, + "account_number": "0123456789", + "bank_code": "058", + "bank_name": "Guaranty Trust Bank", + "customer": { + "id": 28958104, + "customer_code": "CUS_5kye9bc41uw15pb", + "email": "customer@email.com", + "first_name": "Booker", + "last_name": "Jones" + }, + "authorized_at": "2025-06-23T12:47:10.632Z" + } + ], + "meta": { + "per_page": 10, + "next": "MTI1OTc=", + "count": 10, + "total": 40 + } + } + } +} diff --git a/dist/doc/payments/direct-debit/initialize-transaction.js b/dist/doc/payments/direct-debit/initialize-transaction.js new file mode 100644 index 0000000..4f67cdc --- /dev/null +++ b/dist/doc/payments/direct-debit/initialize-transaction.js @@ -0,0 +1,102 @@ +const sh = `curl https://api.paystack.co/transaction/initialize +-H "Authorization: Bearer YOUR_SECRET_KEY" +-H "Content-Type: application/json" +-d '{ "email": "customer@email.com", + "amount": "10000", + "channels": ["bank"], + "metadata": { + "custom_filters": { + "recurring": true + } + } + }' +-X POST` + +const js = `const https = require('https') + +const params = JSON.stringify({ + "email": "customer@email.com", + "amount": 10000, + "channels": ["bank"], + "metadata": { + "custom_filters": { + "recurring": true + } + } +}) + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/transaction/initialize', + 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 = ` "customer@email.com", + 'amount' => "10000", + 'channels' => ["bank"], + 'metadata' => [ + 'custom_filters' => [ + 'recurring' => true + ] + ] + ]; + + $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 URL created", + "data": { + "authorization_url": "https://checkout.paystack.com/zcwh3axoir37x7q", + "access_code": "zcwh3axoir37x7q", + "reference": "gz8nyit2zd" + } +}` + +export {sh, js, php, json} \ No newline at end of file diff --git a/dist/doc/payments/direct-debit/initialize.js b/dist/doc/payments/direct-debit/initialize.js index ed65597..735ed1d 100644 --- a/dist/doc/payments/direct-debit/initialize.js +++ b/dist/doc/payments/direct-debit/initialize.js @@ -50,7 +50,7 @@ const php = ` "mail@mail.com", - 'channel' => "direct-debit", + 'channel' => "direct_debit", 'callback_url' => "http://test.url.com" ]; diff --git a/dist/doc/payments/direct-debit/pending-authorization-1.js b/dist/doc/payments/direct-debit/pending-authorization-1.js new file mode 100644 index 0000000..7aba036 --- /dev/null +++ b/dist/doc/payments/direct-debit/pending-authorization-1.js @@ -0,0 +1,78 @@ +const sh = `#!/bin/sh +curl https://api.paystack.co/customer/{id}/directdebit-activation-charge +-H "Authorization: Bearer YOUR_SECRET_KEY" +-H "Content-Type: application/json" +-d '{ + "authorization_id" : 1069309917 + }' +-X PUT` + +const js = `const https = require('https') + +const params = JSON.stringify({ + "authorization_id" : 1069309917 +}) + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/customer/{id}/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 = ` 1069309917 + ]; + + $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; +?>` + +const json = `{ + "status": true, + "message": "Mandate is queued for retry" +}` + +export {sh, js, php, json} \ No newline at end of file diff --git a/dist/doc/payments/direct-debit/pending-authorization-2.js b/dist/doc/payments/direct-debit/pending-authorization-2.js new file mode 100644 index 0000000..810af4b --- /dev/null +++ b/dist/doc/payments/direct-debit/pending-authorization-2.js @@ -0,0 +1,78 @@ +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 = ` [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; +?>` + +const json = `{ + "status": true, + "message": "Mandate is queued for retry" +}` + +export {sh, js, php, json} \ No newline at end of file diff --git a/src/api/customers/direct-debit-activation-charge/config.yml b/src/api/customers/direct-debit-activation-charge/config.yml new file mode 100644 index 0000000..e49a41b --- /dev/null +++ b/src/api/customers/direct-debit-activation-charge/config.yml @@ -0,0 +1,4 @@ +languages: + - sh + - js + - php \ No newline at end of file diff --git a/src/api/customers/direct-debit-activation-charge/index.js b/src/api/customers/direct-debit-activation-charge/index.js new file mode 100644 index 0000000..2708974 --- /dev/null +++ b/src/api/customers/direct-debit-activation-charge/index.js @@ -0,0 +1,33 @@ +const https = require('https') + +const params = JSON.stringify({ + "authorization_id" : 1069309917 +}) + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/customer/{id}/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() \ No newline at end of file diff --git a/src/api/customers/direct-debit-activation-charge/index.php b/src/api/customers/direct-debit-activation-charge/index.php new file mode 100644 index 0000000..71b6b96 --- /dev/null +++ b/src/api/customers/direct-debit-activation-charge/index.php @@ -0,0 +1,28 @@ + 1069309917 + ]; + + $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; +?> \ No newline at end of file diff --git a/src/api/customers/direct-debit-activation-charge/index.sh b/src/api/customers/direct-debit-activation-charge/index.sh new file mode 100644 index 0000000..9387ef2 --- /dev/null +++ b/src/api/customers/direct-debit-activation-charge/index.sh @@ -0,0 +1,8 @@ +#!/bin/sh +curl https://api.paystack.co/customer/{id}/directdebit-activation-charge +-H "Authorization: Bearer YOUR_SECRET_KEY" +-H "Content-Type: application/json" +-d '{ + "authorization_id" : 1069309917 + }' +-X PUT \ No newline at end of file diff --git a/src/api/customers/direct-debit-activation-charge/response.json b/src/api/customers/direct-debit-activation-charge/response.json new file mode 100644 index 0000000..f2d2d27 --- /dev/null +++ b/src/api/customers/direct-debit-activation-charge/response.json @@ -0,0 +1,9 @@ +{ + "200": { + "description": "200 Ok", + "data": { + "status": true, + "message": "Mandate is queued for retry" + } + } +} diff --git a/src/api/customers/fetch-mandate-authorization/config.yml b/src/api/customers/fetch-mandate-authorization/config.yml new file mode 100644 index 0000000..e49a41b --- /dev/null +++ b/src/api/customers/fetch-mandate-authorization/config.yml @@ -0,0 +1,4 @@ +languages: + - sh + - js + - php \ No newline at end of file diff --git a/src/api/customers/fetch-mandate-authorization/index.js b/src/api/customers/fetch-mandate-authorization/index.js new file mode 100644 index 0000000..a4d08dd --- /dev/null +++ b/src/api/customers/fetch-mandate-authorization/index.js @@ -0,0 +1,25 @@ +const https = require('https') + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/customer/{id}/directdebit-mandate-authorizations', + method: 'GET', + headers: { + Authorization: 'Bearer SECRET_KEY' + } +} + +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) +}) \ No newline at end of file diff --git a/src/api/customers/fetch-mandate-authorization/index.php b/src/api/customers/fetch-mandate-authorization/index.php new file mode 100644 index 0000000..952d452 --- /dev/null +++ b/src/api/customers/fetch-mandate-authorization/index.php @@ -0,0 +1,28 @@ + "https://api.paystack.co//customer/{id}/directdebit-mandate-authorizations", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_HTTPHEADER => array( + "Authorization: Bearer SECRET_KEY", + "Cache-Control: no-cache", + ), + )); + + $response = curl_exec($curl); + $err = curl_error($curl); + + curl_close($curl); + + if ($err) { + echo "cURL Error #:" . $err; + } else { + echo $response; + } +?> \ No newline at end of file diff --git a/src/api/customers/fetch-mandate-authorization/index.sh b/src/api/customers/fetch-mandate-authorization/index.sh new file mode 100644 index 0000000..5219b41 --- /dev/null +++ b/src/api/customers/fetch-mandate-authorization/index.sh @@ -0,0 +1,5 @@ +#!/bin/sh +url="https://api.paystack.co/customer/{id}/directdebit-mandate-authorizations" +authorization="Authorization: Bearer YOUR_SECRET_KEY" + +curl "$url" -H "$authorization" -X GET \ No newline at end of file diff --git a/src/api/customers/fetch-mandate-authorization/response.json b/src/api/customers/fetch-mandate-authorization/response.json new file mode 100644 index 0000000..e96179b --- /dev/null +++ b/src/api/customers/fetch-mandate-authorization/response.json @@ -0,0 +1,36 @@ +{ + "200": { + "description": "200 Ok", + "data": { + "status": true, + "message": "Mandate authorizations retrieved successfully", + "data": [ + { + "id": 164098, + "status": "active", + "mandate_id": 512003, + "authorization_id": 110049014, + "authorization_code": "AUTH_8Lol0pNt14", + "integration_id": 463433, + "account_number": "0123456789", + "bank_code": "032", + "bank_name": null, + "customer": { + "id": 43975700, + "customer_code": "CUS_2eusy8uwe34s23fy", + "email": "customer@email.com", + "first_name": "Smith", + "last_name": "Bel" + }, + "authorized_at": "2024-09-27T10:57:53.824Z" + } + ], + "meta": { + "per_page": 50, + "next": null, + "count": 1, + "total": 1 + } + } + } +} diff --git a/src/api/customers/initialize-direct-debit/config.yml b/src/api/customers/initialize-direct-debit/config.yml new file mode 100644 index 0000000..e49a41b --- /dev/null +++ b/src/api/customers/initialize-direct-debit/config.yml @@ -0,0 +1,4 @@ +languages: + - sh + - js + - php \ No newline at end of file diff --git a/src/api/customers/initialize-direct-debit/index.js b/src/api/customers/initialize-direct-debit/index.js new file mode 100644 index 0000000..f56b525 --- /dev/null +++ b/src/api/customers/initialize-direct-debit/index.js @@ -0,0 +1,41 @@ +const https = require('https') + +const params = JSON.stringify({ + "account": { + "number": "0123456789", + "bank_code": "058" + }, + "address": { + "street": "Some Where", + "city": "Ikeja", + "state": "Lagos" + } +}) + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/customer/{id}/initialize-direct-debit', + 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() \ No newline at end of file diff --git a/src/api/customers/initialize-direct-debit/index.php b/src/api/customers/initialize-direct-debit/index.php new file mode 100644 index 0000000..7cde25d --- /dev/null +++ b/src/api/customers/initialize-direct-debit/index.php @@ -0,0 +1,36 @@ + [ + 'number' => '0123456789', + 'bank_code' => '058' + ], + 'address' => [ + 'street' => 'Some Where', + 'city' => 'Ikeja', + 'state' => 'Lagos' + ] + ]; + + $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; +?> \ No newline at end of file diff --git a/src/api/customers/initialize-direct-debit/index.sh b/src/api/customers/initialize-direct-debit/index.sh new file mode 100644 index 0000000..cc0ccf6 --- /dev/null +++ b/src/api/customers/initialize-direct-debit/index.sh @@ -0,0 +1,17 @@ +#!/bin/sh +url="https://api.paystack.co/customer/{id}/initialize-direct-debit" +authorization="Authorization: Bearer YOUR_SECRET_KEY" +content_type="Content-Type: application/json" +data='{ + "account": { + "number": "0123456789", + "bank_code": "058" + }, + "address": { + "street": "Some Where", + "city": "Ikeja", + "state": "Lagos" + } +}' + +curl "$url" -H "$authorization" -H "$content_type" -d "$data" -X POST \ No newline at end of file diff --git a/src/api/customers/initialize-direct-debit/response.json b/src/api/customers/initialize-direct-debit/response.json new file mode 100644 index 0000000..f0cc001 --- /dev/null +++ b/src/api/customers/initialize-direct-debit/response.json @@ -0,0 +1,14 @@ +{ + "200": { + "description": "200 Ok", + "data": { + "status": true, + "message": "Authorization initialized", + "data": { + "redirect_url": "https://link.paystack.com/ll6b0szngj1f27k", + "access_code": "ll6b0szngj1f27k", + "reference": "1er945lpy4txyki" + } + } + } +} diff --git a/src/api/direct-debit/activation-charge/config.yml b/src/api/direct-debit/activation-charge/config.yml new file mode 100644 index 0000000..e49a41b --- /dev/null +++ b/src/api/direct-debit/activation-charge/config.yml @@ -0,0 +1,4 @@ +languages: + - sh + - js + - php \ No newline at end of file diff --git a/src/api/direct-debit/activation-charge/index.js b/src/api/direct-debit/activation-charge/index.js new file mode 100644 index 0000000..4d67ff6 --- /dev/null +++ b/src/api/direct-debit/activation-charge/index.js @@ -0,0 +1,33 @@ +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() \ No newline at end of file diff --git a/src/api/direct-debit/activation-charge/index.php b/src/api/direct-debit/activation-charge/index.php new file mode 100644 index 0000000..af70f2e --- /dev/null +++ b/src/api/direct-debit/activation-charge/index.php @@ -0,0 +1,28 @@ + [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; +?> \ No newline at end of file diff --git a/src/api/direct-debit/activation-charge/index.sh b/src/api/direct-debit/activation-charge/index.sh new file mode 100644 index 0000000..567abab --- /dev/null +++ b/src/api/direct-debit/activation-charge/index.sh @@ -0,0 +1,8 @@ +#!/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 \ No newline at end of file diff --git a/src/api/direct-debit/activation-charge/response.json b/src/api/direct-debit/activation-charge/response.json new file mode 100644 index 0000000..f2d2d27 --- /dev/null +++ b/src/api/direct-debit/activation-charge/response.json @@ -0,0 +1,9 @@ +{ + "200": { + "description": "200 Ok", + "data": { + "status": true, + "message": "Mandate is queued for retry" + } + } +} diff --git a/src/api/direct-debit/list-authorizations/config.yml b/src/api/direct-debit/list-authorizations/config.yml new file mode 100644 index 0000000..e49a41b --- /dev/null +++ b/src/api/direct-debit/list-authorizations/config.yml @@ -0,0 +1,4 @@ +languages: + - sh + - js + - php \ No newline at end of file diff --git a/src/api/direct-debit/list-authorizations/index.js b/src/api/direct-debit/list-authorizations/index.js new file mode 100644 index 0000000..4d0a298 --- /dev/null +++ b/src/api/direct-debit/list-authorizations/index.js @@ -0,0 +1,25 @@ +const https = require('https') + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/directdebit/mandate-authorizations', + method: 'GET', + headers: { + Authorization: 'Bearer SECRET_KEY' + } +} + +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) +}) \ No newline at end of file diff --git a/src/api/direct-debit/list-authorizations/index.php b/src/api/direct-debit/list-authorizations/index.php new file mode 100644 index 0000000..3d76d01 --- /dev/null +++ b/src/api/direct-debit/list-authorizations/index.php @@ -0,0 +1,28 @@ + "https://api.paystack.co/directdebit/mandate-authorizations", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_HTTPHEADER => array( + "Authorization: Bearer SECRET_KEY", + "Cache-Control: no-cache", + ), + )); + + $response = curl_exec($curl); + $err = curl_error($curl); + + curl_close($curl); + + if ($err) { + echo "cURL Error #:" . $err; + } else { + echo $response; + } +?> \ No newline at end of file diff --git a/src/api/direct-debit/list-authorizations/index.sh b/src/api/direct-debit/list-authorizations/index.sh new file mode 100644 index 0000000..18218b2 --- /dev/null +++ b/src/api/direct-debit/list-authorizations/index.sh @@ -0,0 +1,5 @@ +#!/bin/sh +url="https://api.paystack.co/directdebit/mandate-authorizations" +authorization="Authorization: Bearer YOUR_SECRET_KEY" + +curl "$url" -H "$authorization" -X GET \ No newline at end of file diff --git a/src/api/direct-debit/list-authorizations/response.json b/src/api/direct-debit/list-authorizations/response.json new file mode 100644 index 0000000..3e4047b --- /dev/null +++ b/src/api/direct-debit/list-authorizations/response.json @@ -0,0 +1,36 @@ +{ + "200": { + "description": "200 Ok", + "data": { + "status": true, + "message": "Mandate authorizations retrieved successfully", + "data": [ + { + "id": 112244, + "status": "active", + "mandate_id": 1560169, + "authorization_id": 1069309917, + "authorization_code": "AUTH_lEt8QgrSfW", + "integration_id": 463433, + "account_number": "0123456789", + "bank_code": "058", + "bank_name": "Guaranty Trust Bank", + "customer": { + "id": 28958104, + "customer_code": "CUS_5kye9bc41uw15pb", + "email": "customer@email.com", + "first_name": "Booker", + "last_name": "Jones" + }, + "authorized_at": "2025-06-23T12:47:10.632Z" + } + ], + "meta": { + "per_page": 10, + "next": "MTI1OTc=", + "count": 10, + "total": 40 + } + } + } +} diff --git a/src/doc/payments/direct-debit/initialize-transaction/config.yml b/src/doc/payments/direct-debit/initialize-transaction/config.yml new file mode 100644 index 0000000..3509c90 --- /dev/null +++ b/src/doc/payments/direct-debit/initialize-transaction/config.yml @@ -0,0 +1,5 @@ +languages: + - sh + - js + - php + - json \ No newline at end of file diff --git a/src/doc/payments/direct-debit/initialize-transaction/index.js b/src/doc/payments/direct-debit/initialize-transaction/index.js new file mode 100644 index 0000000..05929b4 --- /dev/null +++ b/src/doc/payments/direct-debit/initialize-transaction/index.js @@ -0,0 +1,40 @@ +const https = require('https') + +const params = JSON.stringify({ + "email": "customer@email.com", + "amount": 10000, + "channels": ["bank"], + "metadata": { + "custom_filters": { + "recurring": true + } + } +}) + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/transaction/initialize', + 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() \ No newline at end of file diff --git a/src/doc/payments/direct-debit/initialize-transaction/index.json b/src/doc/payments/direct-debit/initialize-transaction/index.json new file mode 100644 index 0000000..b265e10 --- /dev/null +++ b/src/doc/payments/direct-debit/initialize-transaction/index.json @@ -0,0 +1,9 @@ +{ + "status": true, + "message": "Authorization URL created", + "data": { + "authorization_url": "https://checkout.paystack.com/zcwh3axoir37x7q", + "access_code": "zcwh3axoir37x7q", + "reference": "gz8nyit2zd" + } +} \ No newline at end of file diff --git a/src/doc/payments/direct-debit/initialize-transaction/index.php b/src/doc/payments/direct-debit/initialize-transaction/index.php new file mode 100644 index 0000000..3a41109 --- /dev/null +++ b/src/doc/payments/direct-debit/initialize-transaction/index.php @@ -0,0 +1,35 @@ + "customer@email.com", + 'amount' => "10000", + 'channels' => ["bank"], + 'metadata' => [ + 'custom_filters' => [ + 'recurring' => true + ] + ] + ]; + + $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; +?> \ No newline at end of file diff --git a/src/doc/payments/direct-debit/initialize-transaction/index.sh b/src/doc/payments/direct-debit/initialize-transaction/index.sh new file mode 100644 index 0000000..6fab47e --- /dev/null +++ b/src/doc/payments/direct-debit/initialize-transaction/index.sh @@ -0,0 +1,13 @@ +curl https://api.paystack.co/transaction/initialize +-H "Authorization: Bearer YOUR_SECRET_KEY" +-H "Content-Type: application/json" +-d '{ "email": "customer@email.com", + "amount": "10000", + "channels": ["bank"], + "metadata": { + "custom_filters": { + "recurring": true + } + } + }' +-X POST \ No newline at end of file diff --git a/src/doc/payments/direct-debit/initialize/index.php b/src/doc/payments/direct-debit/initialize/index.php index dd5a454..e5679a9 100644 --- a/src/doc/payments/direct-debit/initialize/index.php +++ b/src/doc/payments/direct-debit/initialize/index.php @@ -3,7 +3,7 @@ $fields = [ 'email' => "mail@mail.com", - 'channel' => "direct-debit", + 'channel' => "direct_debit", 'callback_url' => "http://test.url.com" ]; diff --git a/src/doc/payments/direct-debit/pending-authorization-1/config.yml b/src/doc/payments/direct-debit/pending-authorization-1/config.yml new file mode 100644 index 0000000..3509c90 --- /dev/null +++ b/src/doc/payments/direct-debit/pending-authorization-1/config.yml @@ -0,0 +1,5 @@ +languages: + - sh + - js + - php + - json \ No newline at end of file diff --git a/src/doc/payments/direct-debit/pending-authorization-1/index.js b/src/doc/payments/direct-debit/pending-authorization-1/index.js new file mode 100644 index 0000000..70dcd18 --- /dev/null +++ b/src/doc/payments/direct-debit/pending-authorization-1/index.js @@ -0,0 +1,33 @@ +const https = require('https') + +const params = JSON.stringify({ + "authorization_id" : 1069309917 +}) + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/customer/{id}/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() \ No newline at end of file diff --git a/src/doc/payments/direct-debit/pending-authorization-1/index.json b/src/doc/payments/direct-debit/pending-authorization-1/index.json new file mode 100644 index 0000000..b32205c --- /dev/null +++ b/src/doc/payments/direct-debit/pending-authorization-1/index.json @@ -0,0 +1,4 @@ +{ + "status": true, + "message": "Mandate is queued for retry" +} \ No newline at end of file diff --git a/src/doc/payments/direct-debit/pending-authorization-1/index.php b/src/doc/payments/direct-debit/pending-authorization-1/index.php new file mode 100644 index 0000000..71b6b96 --- /dev/null +++ b/src/doc/payments/direct-debit/pending-authorization-1/index.php @@ -0,0 +1,28 @@ + 1069309917 + ]; + + $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; +?> \ No newline at end of file diff --git a/src/doc/payments/direct-debit/pending-authorization-1/index.sh b/src/doc/payments/direct-debit/pending-authorization-1/index.sh new file mode 100644 index 0000000..9387ef2 --- /dev/null +++ b/src/doc/payments/direct-debit/pending-authorization-1/index.sh @@ -0,0 +1,8 @@ +#!/bin/sh +curl https://api.paystack.co/customer/{id}/directdebit-activation-charge +-H "Authorization: Bearer YOUR_SECRET_KEY" +-H "Content-Type: application/json" +-d '{ + "authorization_id" : 1069309917 + }' +-X PUT \ No newline at end of file diff --git a/src/doc/payments/direct-debit/pending-authorization-2/config.yml b/src/doc/payments/direct-debit/pending-authorization-2/config.yml new file mode 100644 index 0000000..3509c90 --- /dev/null +++ b/src/doc/payments/direct-debit/pending-authorization-2/config.yml @@ -0,0 +1,5 @@ +languages: + - sh + - js + - php + - json \ No newline at end of file diff --git a/src/doc/payments/direct-debit/pending-authorization-2/index.js b/src/doc/payments/direct-debit/pending-authorization-2/index.js new file mode 100644 index 0000000..cb7ec42 --- /dev/null +++ b/src/doc/payments/direct-debit/pending-authorization-2/index.js @@ -0,0 +1,33 @@ +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() \ No newline at end of file diff --git a/src/doc/payments/direct-debit/pending-authorization-2/index.json b/src/doc/payments/direct-debit/pending-authorization-2/index.json new file mode 100644 index 0000000..b32205c --- /dev/null +++ b/src/doc/payments/direct-debit/pending-authorization-2/index.json @@ -0,0 +1,4 @@ +{ + "status": true, + "message": "Mandate is queued for retry" +} \ No newline at end of file diff --git a/src/doc/payments/direct-debit/pending-authorization-2/index.php b/src/doc/payments/direct-debit/pending-authorization-2/index.php new file mode 100644 index 0000000..af70f2e --- /dev/null +++ b/src/doc/payments/direct-debit/pending-authorization-2/index.php @@ -0,0 +1,28 @@ + [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; +?> \ No newline at end of file diff --git a/src/doc/payments/direct-debit/pending-authorization-2/index.sh b/src/doc/payments/direct-debit/pending-authorization-2/index.sh new file mode 100644 index 0000000..567abab --- /dev/null +++ b/src/doc/payments/direct-debit/pending-authorization-2/index.sh @@ -0,0 +1,8 @@ +#!/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 \ No newline at end of file