From 64d6ec4f1c4174a833bb94ff29feb0028b5dda50 Mon Sep 17 00:00:00 2001 From: Damilola Odujoko Date: Fri, 20 Feb 2026 16:16:43 +0100 Subject: [PATCH] feat: add Capitec Pay code snippet --- dist/api/capitec-pay/requery/requests.js | 62 +++++++++ dist/api/capitec-pay/requery/response.json | 59 +++++++++ .../payments/payment-methods/capitec-pay.js | 118 ++++++++++++++++++ src/api/capitec-pay/requery/config.yml | 4 + src/api/capitec-pay/requery/index.js | 25 ++++ src/api/capitec-pay/requery/index.php | 28 +++++ src/api/capitec-pay/requery/index.sh | 5 + src/api/capitec-pay/requery/response.json | 59 +++++++++ .../payment-methods/capitec-pay/config.yml | 5 + .../payment-methods/capitec-pay/index.js | 39 ++++++ .../payment-methods/capitec-pay/index.json | 30 +++++ .../payment-methods/capitec-pay/index.php | 32 +++++ .../payment-methods/capitec-pay/index.sh | 12 ++ 13 files changed, 478 insertions(+) create mode 100644 dist/api/capitec-pay/requery/requests.js create mode 100644 dist/api/capitec-pay/requery/response.json create mode 100644 dist/doc/payments/payment-methods/capitec-pay.js create mode 100644 src/api/capitec-pay/requery/config.yml create mode 100644 src/api/capitec-pay/requery/index.js create mode 100644 src/api/capitec-pay/requery/index.php create mode 100644 src/api/capitec-pay/requery/index.sh create mode 100644 src/api/capitec-pay/requery/response.json create mode 100644 src/doc/payments/payment-methods/capitec-pay/config.yml create mode 100644 src/doc/payments/payment-methods/capitec-pay/index.js create mode 100644 src/doc/payments/payment-methods/capitec-pay/index.json create mode 100644 src/doc/payments/payment-methods/capitec-pay/index.php create mode 100644 src/doc/payments/payment-methods/capitec-pay/index.sh diff --git a/dist/api/capitec-pay/requery/requests.js b/dist/api/capitec-pay/requery/requests.js new file mode 100644 index 0000000..6139c5e --- /dev/null +++ b/dist/api/capitec-pay/requery/requests.js @@ -0,0 +1,62 @@ +const sh = `#!/bin/sh +url="https://api.paystack.co/capitec-pay/requery/{ref}" +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: '/capitec-pay/requery/{ref}', + 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/capitec-pay/requery/{ref}", + 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/capitec-pay/requery/response.json b/dist/api/capitec-pay/requery/response.json new file mode 100644 index 0000000..0a19ded --- /dev/null +++ b/dist/api/capitec-pay/requery/response.json @@ -0,0 +1,59 @@ +{ + "200": { + "description": "200 Ok", + "data": { + "status": true, + "type": "success", + "code": "ok", + "data": { + "status": "success" + }, + "message": "Charge successful" + } + }, + "200_pending": { + "description": "200 Pending", + "data": { + "status": true, + "type": "success", + "code": "ok", + "data": { + "status": "pending" + }, + "message": "Charge pending" + } + }, + "200_failed": { + "description": "200 Failed", + "data": { + "status": true, + "type": "success", + "code": "ok", + "data": { + "status": "failed" + }, + "message": "Account is de-activated, please contact Capitec for help" + } + }, + "400": { + "description": "400 Bad Request", + "data": { + "status": false, + "message": "Transaction not found", + "meta": { + "nextStep": "Ensure that you're passing the reference of a transaction that exists on this integration" + }, + "type": "validation_error", + "code": "transaction_not_found" + } + }, + "500": { + "description": "500 Server Error", + "data": { + "status": false, + "code": "unknown", + "type": "api_error", + "message": "An error occurred" + } + } +} \ No newline at end of file diff --git a/dist/doc/payments/payment-methods/capitec-pay.js b/dist/doc/payments/payment-methods/capitec-pay.js new file mode 100644 index 0000000..3a77999 --- /dev/null +++ b/dist/doc/payments/payment-methods/capitec-pay.js @@ -0,0 +1,118 @@ +const sh = `curl https://api.paystack.co/charge +-H "Authorization: Bearer YOUR_SECRET_KEY" +-H "Content-Type: application/json" +-d '{ "amount": 1000, + "email": "drew.john@email.com", + "currency": "ZAR", + "capitec_pay": { + "identifier_key" : "CELLPHONE", + "identifier_value" : "0812345678" + } + }' +-X POST` + +const js = `const https = require('https') + +const params = JSON.stringify({ + "email": "drew.john@mail.com", + "amount": 1000, + "currency": "ZAR", + "capitec_pay": { + "identifier_key": "CELLPHONE", + "identifier_value": "0812345678" + } +}) + +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 => [ + "amount" => 1000, + "email" => "drew.john@email.com", + "currency" => "ZAR", + "capitec_pay" => [ + "identifier_key" => "CELLPHONE", + "identifier_value" => "0812345678" + ] + ], + CURLOPT_HTTPHEADER => array( + "Authorization: Bearer SECRET_KEY", + "Content-Type: application/json" ), +)); +$response = curl_exec($curl); +$err = curl_error($curl); +curl_close($curl); +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} +?>` + +const json = `{ + "type": "success", + "code": "ok", + "data": { + "status": "success", + "timeToLive": 120, + "expiryDate": "2026-02-17T11:29:37.000Z", + "transaction": { + "id": 5805764100, + "reference": "nvh8o4pwtivwkx4", + "domain": "live", + "amount": 1000, + "currency": "ZAR", + "metadata": "", + "createdAt": "2026-02-17T11:27:36.000Z", + "customer": { + "id": 180101459, + "first_name": "Drew", + "last_name": "John", + "email": "drew.john@email.com", + "customer_code": "CUS_xy1ofyzvnhagniv", + "phone": "", + "metadata": null, + "risk_action": "default", + "international_format_phone": null + } + } + }, + "message": "Charge pending" +}` + +export {sh, js, php, json} \ No newline at end of file diff --git a/src/api/capitec-pay/requery/config.yml b/src/api/capitec-pay/requery/config.yml new file mode 100644 index 0000000..e49a41b --- /dev/null +++ b/src/api/capitec-pay/requery/config.yml @@ -0,0 +1,4 @@ +languages: + - sh + - js + - php \ No newline at end of file diff --git a/src/api/capitec-pay/requery/index.js b/src/api/capitec-pay/requery/index.js new file mode 100644 index 0000000..f03b6b1 --- /dev/null +++ b/src/api/capitec-pay/requery/index.js @@ -0,0 +1,25 @@ +const https = require('https') + +const options = { + hostname: 'api.paystack.co', + port: 443, + path: '/capitec-pay/requery/{ref}', + 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/capitec-pay/requery/index.php b/src/api/capitec-pay/requery/index.php new file mode 100644 index 0000000..3ec5761 --- /dev/null +++ b/src/api/capitec-pay/requery/index.php @@ -0,0 +1,28 @@ + "https://api.paystack.co/capitec-pay/requery/{ref}", + 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/capitec-pay/requery/index.sh b/src/api/capitec-pay/requery/index.sh new file mode 100644 index 0000000..413bcdf --- /dev/null +++ b/src/api/capitec-pay/requery/index.sh @@ -0,0 +1,5 @@ +#!/bin/sh +url="https://api.paystack.co/capitec-pay/requery/{ref}" +authorization="Authorization: Bearer YOUR_SECRET_KEY" + +curl "$url" -H "$authorization" -X GET \ No newline at end of file diff --git a/src/api/capitec-pay/requery/response.json b/src/api/capitec-pay/requery/response.json new file mode 100644 index 0000000..0a19ded --- /dev/null +++ b/src/api/capitec-pay/requery/response.json @@ -0,0 +1,59 @@ +{ + "200": { + "description": "200 Ok", + "data": { + "status": true, + "type": "success", + "code": "ok", + "data": { + "status": "success" + }, + "message": "Charge successful" + } + }, + "200_pending": { + "description": "200 Pending", + "data": { + "status": true, + "type": "success", + "code": "ok", + "data": { + "status": "pending" + }, + "message": "Charge pending" + } + }, + "200_failed": { + "description": "200 Failed", + "data": { + "status": true, + "type": "success", + "code": "ok", + "data": { + "status": "failed" + }, + "message": "Account is de-activated, please contact Capitec for help" + } + }, + "400": { + "description": "400 Bad Request", + "data": { + "status": false, + "message": "Transaction not found", + "meta": { + "nextStep": "Ensure that you're passing the reference of a transaction that exists on this integration" + }, + "type": "validation_error", + "code": "transaction_not_found" + } + }, + "500": { + "description": "500 Server Error", + "data": { + "status": false, + "code": "unknown", + "type": "api_error", + "message": "An error occurred" + } + } +} \ No newline at end of file diff --git a/src/doc/payments/payment-methods/capitec-pay/config.yml b/src/doc/payments/payment-methods/capitec-pay/config.yml new file mode 100644 index 0000000..3509c90 --- /dev/null +++ b/src/doc/payments/payment-methods/capitec-pay/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/capitec-pay/index.js b/src/doc/payments/payment-methods/capitec-pay/index.js new file mode 100644 index 0000000..971af0f --- /dev/null +++ b/src/doc/payments/payment-methods/capitec-pay/index.js @@ -0,0 +1,39 @@ +const https = require('https') + +const params = JSON.stringify({ + "email": "drew.john@mail.com", + "amount": 1000, + "currency": "ZAR", + "capitec_pay": { + "identifier_key": "CELLPHONE", + "identifier_value": "0812345678" + } +}) + +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/capitec-pay/index.json b/src/doc/payments/payment-methods/capitec-pay/index.json new file mode 100644 index 0000000..9982650 --- /dev/null +++ b/src/doc/payments/payment-methods/capitec-pay/index.json @@ -0,0 +1,30 @@ +{ + "type": "success", + "code": "ok", + "data": { + "status": "success", + "timeToLive": 120, + "expiryDate": "2026-02-17T11:29:37.000Z", + "transaction": { + "id": 5805764100, + "reference": "nvh8o4pwtivwkx4", + "domain": "live", + "amount": 1000, + "currency": "ZAR", + "metadata": "", + "createdAt": "2026-02-17T11:27:36.000Z", + "customer": { + "id": 180101459, + "first_name": "Drew", + "last_name": "John", + "email": "drew.john@email.com", + "customer_code": "CUS_xy1ofyzvnhagniv", + "phone": "", + "metadata": null, + "risk_action": "default", + "international_format_phone": null + } + } + }, + "message": "Charge pending" +} \ No newline at end of file diff --git a/src/doc/payments/payment-methods/capitec-pay/index.php b/src/doc/payments/payment-methods/capitec-pay/index.php new file mode 100644 index 0000000..9870809 --- /dev/null +++ b/src/doc/payments/payment-methods/capitec-pay/index.php @@ -0,0 +1,32 @@ + "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 => [ + "amount" => 1000, + "email" => "drew.john@email.com", + "currency" => "ZAR", + "capitec_pay" => [ + "identifier_key" => "CELLPHONE", + "identifier_value" => "0812345678" + ] + ], + CURLOPT_HTTPHEADER => array( + "Authorization: Bearer SECRET_KEY", + "Content-Type: application/json" ), +)); +$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/capitec-pay/index.sh b/src/doc/payments/payment-methods/capitec-pay/index.sh new file mode 100644 index 0000000..d4e76e0 --- /dev/null +++ b/src/doc/payments/payment-methods/capitec-pay/index.sh @@ -0,0 +1,12 @@ +curl https://api.paystack.co/charge +-H "Authorization: Bearer YOUR_SECRET_KEY" +-H "Content-Type: application/json" +-d '{ "amount": 1000, + "email": "drew.john@email.com", + "currency": "ZAR", + "capitec_pay": { + "identifier_key" : "CELLPHONE", + "identifier_value" : "0812345678" + } + }' +-X POST \ No newline at end of file