diff --git a/dist/doc/payments/direct-debit/charge.js b/dist/doc/payments/direct-debit/charge.js new file mode 100644 index 0000000..d9e8478 --- /dev/null +++ b/dist/doc/payments/direct-debit/charge.js @@ -0,0 +1,114 @@ +const sh = `#!/bin/sh +curl https://api.paystack.co/charge +-H "Authorization: Bearer YOUR_SECRET_KEY" +-H "Content-Type: application/json" +-d '{ + "email": "ravi@demo.com", + "amount": "1000000", + "currency": "NGN", + "direct_debit": { + "account": { "number": "0123456789", "bank_code": "057" }, + "address": { "street": "126 Joel Ogunnaike", "city": "Ikeja", "state": "Lagos", "country": "NG" }, + "phone": "+2348012345678" + } + }' +-X POST` + +const js = `const https = require('https') + +const params = JSON.stringify({ + "email": "ravi@demo.com", + "amount": 1000000, + "currency": "NGN", + "direct_debit": { + "account": { "number": "0123456789", "bank_code": "057" }, + "address": { "street": "126 Joel Ogunnaike", "city": "Ikeja", "state": "Lagos", "country": "NG" }, + "phone": "+2348012345678" + } +}) + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/charge', + 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 = ` "ravi@demo.com", + 'amount' => "1000000", + 'currency' => "NGN", + 'direct_debit' => [ + 'account' => [ + 'number' => "0123456789", + 'bank_code' => "057" + ], + 'address' => [ + 'street' => "126 Joel Ogunnaike", + 'city' => "Ikeja", + 'state' => "Lagos", + 'country' => "NG" + ], + 'phone' => "+2348012345678" + ] + ]; + + $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": "Charge attempted", + "data": { + "reference": "dd-charge-8f3a1c", + "status": "pending_bank_transfer", + "amount": 1000000, + "account_number": "1234567890", + "bank_name": "Test Bank" + } +}` + +export {sh, js, php, json} \ No newline at end of file diff --git a/src/doc/payments/direct-debit/charge/config.yml b/src/doc/payments/direct-debit/charge/config.yml new file mode 100644 index 0000000..73f0a25 --- /dev/null +++ b/src/doc/payments/direct-debit/charge/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/charge/index.js b/src/doc/payments/direct-debit/charge/index.js new file mode 100644 index 0000000..ba0abdb --- /dev/null +++ b/src/doc/payments/direct-debit/charge/index.js @@ -0,0 +1,40 @@ +const https = require('https') + +const params = JSON.stringify({ + "email": "ravi@demo.com", + "amount": 1000000, + "currency": "NGN", + "direct_debit": { + "account": { "number": "0123456789", "bank_code": "057" }, + "address": { "street": "126 Joel Ogunnaike", "city": "Ikeja", "state": "Lagos", "country": "NG" }, + "phone": "+2348012345678" + } +}) + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/charge', + 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/charge/index.json b/src/doc/payments/direct-debit/charge/index.json new file mode 100644 index 0000000..2cfbfaf --- /dev/null +++ b/src/doc/payments/direct-debit/charge/index.json @@ -0,0 +1,11 @@ +{ + "status": true, + "message": "Charge attempted", + "data": { + "reference": "dd-charge-8f3a1c", + "status": "pending_bank_transfer", + "amount": 1000000, + "account_number": "1234567890", + "bank_name": "Test Bank" + } +} \ No newline at end of file diff --git a/src/doc/payments/direct-debit/charge/index.php b/src/doc/payments/direct-debit/charge/index.php new file mode 100644 index 0000000..17bb987 --- /dev/null +++ b/src/doc/payments/direct-debit/charge/index.php @@ -0,0 +1,43 @@ + "ravi@demo.com", + 'amount' => "1000000", + 'currency' => "NGN", + 'direct_debit' => [ + 'account' => [ + 'number' => "0123456789", + 'bank_code' => "057" + ], + 'address' => [ + 'street' => "126 Joel Ogunnaike", + 'city' => "Ikeja", + 'state' => "Lagos", + 'country' => "NG" + ], + 'phone' => "+2348012345678" + ] + ]; + + $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/charge/index.sh b/src/doc/payments/direct-debit/charge/index.sh new file mode 100644 index 0000000..7967bfa --- /dev/null +++ b/src/doc/payments/direct-debit/charge/index.sh @@ -0,0 +1,15 @@ +#!/bin/sh +curl https://api.paystack.co/charge +-H "Authorization: Bearer YOUR_SECRET_KEY" +-H "Content-Type: application/json" +-d '{ + "email": "ravi@demo.com", + "amount": "1000000", + "currency": "NGN", + "direct_debit": { + "account": { "number": "0123456789", "bank_code": "057" }, + "address": { "street": "126 Joel Ogunnaike", "city": "Ikeja", "state": "Lagos", "country": "NG" }, + "phone": "+2348012345678" + } + }' +-X POST \ No newline at end of file