From 2fa55c809bab443ad97e781228e16c2d49d6ee72 Mon Sep 17 00:00:00 2001 From: andrew-paystack Date: Wed, 16 Jul 2025 20:09:28 +0300 Subject: [PATCH 1/4] add pesalink code snippets --- .../payment-methods/pesalink/config.yml | 5 +++ .../payment-methods/pesalink/index.js | 37 +++++++++++++++++++ .../payment-methods/pesalink/index.json | 17 +++++++++ .../payment-methods/pesalink/index.php | 35 ++++++++++++++++++ .../payment-methods/pesalink/index.sh | 14 +++++++ 5 files changed, 108 insertions(+) create mode 100644 src/doc/payments/payment-methods/pesalink/config.yml create mode 100644 src/doc/payments/payment-methods/pesalink/index.js create mode 100644 src/doc/payments/payment-methods/pesalink/index.json create mode 100644 src/doc/payments/payment-methods/pesalink/index.php create mode 100644 src/doc/payments/payment-methods/pesalink/index.sh diff --git a/src/doc/payments/payment-methods/pesalink/config.yml b/src/doc/payments/payment-methods/pesalink/config.yml new file mode 100644 index 0000000..3509c90 --- /dev/null +++ b/src/doc/payments/payment-methods/pesalink/config.yml @@ -0,0 +1,5 @@ +languages: + - sh + - js + - php + - json \ No newline at end of file diff --git a/src/doc/payments/payment-methods/pesalink/index.js b/src/doc/payments/payment-methods/pesalink/index.js new file mode 100644 index 0000000..e2a79e5 --- /dev/null +++ b/src/doc/payments/payment-methods/pesalink/index.js @@ -0,0 +1,37 @@ +const https = require('https') + +const params = JSON.stringify({ + "email": "user@example.com", + "amount": "10000", + "bank_transfer": { + "account_expires_at": "2025-04-24T16:40:57.954Z" + } +}) + +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/payment-methods/pesalink/index.json b/src/doc/payments/payment-methods/pesalink/index.json new file mode 100644 index 0000000..2626376 --- /dev/null +++ b/src/doc/payments/payment-methods/pesalink/index.json @@ -0,0 +1,17 @@ +{ + "status": true, + "message": "Charge attempted", + "data": { + "reference": "kcvu0t3kzs", + "status": "pending_bank_transfer", + "display_text": "Please make a transfer to the account specified", + "account_name": "Paystack Payments Kenya Limited", + "account_number": "1260257501", + "bank": { + "slug": "diamond-trust-bank-ltd-ke", + "name": "Diamond Trust Bank Kenya Ltd", + "id": 225 + }, + "account_expires_at": "2025-04-24T16:55:57.954Z" + } +} \ No newline at end of file diff --git a/src/doc/payments/payment-methods/pesalink/index.php b/src/doc/payments/payment-methods/pesalink/index.php new file mode 100644 index 0000000..1051b70 --- /dev/null +++ b/src/doc/payments/payment-methods/pesalink/index.php @@ -0,0 +1,35 @@ + "https://api.paystack.co/charge", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => [ + "email" => "user@example.com", + "amount" => "10000", + "bank_transfer" => [ + "account_expires_at" => "2025-04-24T16:40:57.954Z" + ] + ], + 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/doc/payments/payment-methods/pesalink/index.sh b/src/doc/payments/payment-methods/pesalink/index.sh new file mode 100644 index 0000000..8e1c24a --- /dev/null +++ b/src/doc/payments/payment-methods/pesalink/index.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +url="https://api.paystack.co/charge" +authorization="Authorization: Bearer YOUR_SECRET_KEY" +content_type="Content-Type: application/json" +data='{ + "email": "user@example.com", + "amount": "10000", + "bank_transfer": { + "account_expires_at": "2025-04-24T16:40:57.954Z" + } +}' + +curl "$url" -H "$authorization" -H "$content_type" -d "$data" -X POST \ No newline at end of file From f04bf5adddf16b44311bebabce6621c5aeaf7621 Mon Sep 17 00:00:00 2001 From: andrew-paystack Date: Wed, 16 Jul 2025 20:10:03 +0300 Subject: [PATCH 2/4] generate code snippets --- dist/doc/payments/payment-methods/pesalink.js | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 dist/doc/payments/payment-methods/pesalink.js diff --git a/dist/doc/payments/payment-methods/pesalink.js b/dist/doc/payments/payment-methods/pesalink.js new file mode 100644 index 0000000..8f3c323 --- /dev/null +++ b/dist/doc/payments/payment-methods/pesalink.js @@ -0,0 +1,108 @@ +const sh = `#!/bin/sh + +url="https://api.paystack.co/charge" +authorization="Authorization: Bearer YOUR_SECRET_KEY" +content_type="Content-Type: application/json" +data='{ + "email": "user@example.com", + "amount": "10000", + "bank_transfer": { + "account_expires_at": "2025-04-24T16:40:57.954Z" + } +}' + +curl "$url" -H "$authorization" -H "$content_type" -d "$data" -X POST` + +const js = `const https = require('https') + +const params = JSON.stringify({ + "email": "user@example.com", + "amount": "10000", + "bank_transfer": { + "account_expires_at": "2025-04-24T16:40:57.954Z" + } +}) + +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 = ` "https://api.paystack.co/charge", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => [ + "email" => "user@example.com", + "amount" => "10000", + "bank_transfer" => [ + "account_expires_at" => "2025-04-24T16:40:57.954Z" + ] + ], + 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; + } +?>` + +const json = `{ + "status": true, + "message": "Charge attempted", + "data": { + "reference": "kcvu0t3kzs", + "status": "pending_bank_transfer", + "display_text": "Please make a transfer to the account specified", + "account_name": "Paystack Payments Kenya Limited", + "account_number": "1260257501", + "bank": { + "slug": "diamond-trust-bank-ltd-ke", + "name": "Diamond Trust Bank Kenya Ltd", + "id": 225 + }, + "account_expires_at": "2025-04-24T16:55:57.954Z" + } +}` + +export {sh, js, php, json} \ No newline at end of file From c4fe7301ffbaeff4599eb51c4fcf5bb65e29a537 Mon Sep 17 00:00:00 2001 From: andrew-paystack Date: Thu, 24 Jul 2025 10:35:54 +0300 Subject: [PATCH 3/4] update response payload --- src/doc/payments/payment-methods/pesalink/index.json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/doc/payments/payment-methods/pesalink/index.json b/src/doc/payments/payment-methods/pesalink/index.json index 2626376..7a5c1d2 100644 --- a/src/doc/payments/payment-methods/pesalink/index.json +++ b/src/doc/payments/payment-methods/pesalink/index.json @@ -6,12 +6,14 @@ "status": "pending_bank_transfer", "display_text": "Please make a transfer to the account specified", "account_name": "Paystack Payments Kenya Limited", - "account_number": "1260257501", + "account_number": "1234567891", "bank": { - "slug": "diamond-trust-bank-ltd-ke", + "slug": "dtbk-bank", "name": "Diamond Trust Bank Kenya Ltd", "id": 225 }, - "account_expires_at": "2025-04-24T16:55:57.954Z" + "account_expires_at": "2025-04-24T16:55:57.954Z", + "amount": 10000, + "transaction_reference": "1234567" } } \ No newline at end of file From 817fb068cae6b1b951f890b80f9f20b66bbbb3be Mon Sep 17 00:00:00 2001 From: andrew-paystack Date: Thu, 24 Jul 2025 17:09:10 +0300 Subject: [PATCH 4/4] build response payload --- dist/doc/payments/payment-methods/pesalink.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dist/doc/payments/payment-methods/pesalink.js b/dist/doc/payments/payment-methods/pesalink.js index 8f3c323..c328653 100644 --- a/dist/doc/payments/payment-methods/pesalink.js +++ b/dist/doc/payments/payment-methods/pesalink.js @@ -95,13 +95,15 @@ const json = `{ "status": "pending_bank_transfer", "display_text": "Please make a transfer to the account specified", "account_name": "Paystack Payments Kenya Limited", - "account_number": "1260257501", + "account_number": "1234567891", "bank": { - "slug": "diamond-trust-bank-ltd-ke", + "slug": "dtbk-bank", "name": "Diamond Trust Bank Kenya Ltd", "id": 225 }, - "account_expires_at": "2025-04-24T16:55:57.954Z" + "account_expires_at": "2025-04-24T16:55:57.954Z", + "amount": 10000, + "transaction_reference": "1234567" } }`