Skip to content

Commit bebc140

Browse files
Merge pull request #122 from PaystackOSS/feat-capitec-pay
feat: add Capitec Pay code snippet
2 parents 35d3e68 + 64d6ec4 commit bebc140

File tree

13 files changed

+478
-0
lines changed

13 files changed

+478
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
const sh = `#!/bin/sh
2+
url="https://api.paystack.co/capitec-pay/requery/{ref}"
3+
authorization="Authorization: Bearer YOUR_SECRET_KEY"
4+
5+
curl "$url" -H "$authorization" -X GET`
6+
7+
const js = `const https = require('https')
8+
9+
const options = {
10+
hostname: 'api.paystack.co',
11+
port: 443,
12+
path: '/capitec-pay/requery/{ref}',
13+
method: 'GET',
14+
headers: {
15+
Authorization: 'Bearer SECRET_KEY'
16+
}
17+
}
18+
19+
https.request(options, res => {
20+
let data = ''
21+
22+
res.on('data', (chunk) => {
23+
data += chunk
24+
});
25+
26+
res.on('end', () => {
27+
console.log(JSON.parse(data))
28+
})
29+
}).on('error', error => {
30+
console.error(error)
31+
})`
32+
33+
const php = `<?php
34+
$curl = curl_init();
35+
36+
curl_setopt_array($curl, array(
37+
CURLOPT_URL => "https://api.paystack.co/capitec-pay/requery/{ref}",
38+
CURLOPT_RETURNTRANSFER => true,
39+
CURLOPT_ENCODING => "",
40+
CURLOPT_MAXREDIRS => 10,
41+
CURLOPT_TIMEOUT => 30,
42+
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
43+
CURLOPT_CUSTOMREQUEST => "GET",
44+
CURLOPT_HTTPHEADER => array(
45+
"Authorization: Bearer SECRET_KEY",
46+
"Cache-Control: no-cache",
47+
),
48+
));
49+
50+
$response = curl_exec($curl);
51+
$err = curl_error($curl);
52+
53+
curl_close($curl);
54+
55+
if ($err) {
56+
echo "cURL Error #:" . $err;
57+
} else {
58+
echo $response;
59+
}
60+
?>`
61+
62+
export {sh, js, php}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"200": {
3+
"description": "200 Ok",
4+
"data": {
5+
"status": true,
6+
"type": "success",
7+
"code": "ok",
8+
"data": {
9+
"status": "success"
10+
},
11+
"message": "Charge successful"
12+
}
13+
},
14+
"200_pending": {
15+
"description": "200 Pending",
16+
"data": {
17+
"status": true,
18+
"type": "success",
19+
"code": "ok",
20+
"data": {
21+
"status": "pending"
22+
},
23+
"message": "Charge pending"
24+
}
25+
},
26+
"200_failed": {
27+
"description": "200 Failed",
28+
"data": {
29+
"status": true,
30+
"type": "success",
31+
"code": "ok",
32+
"data": {
33+
"status": "failed"
34+
},
35+
"message": "Account is de-activated, please contact Capitec for help"
36+
}
37+
},
38+
"400": {
39+
"description": "400 Bad Request",
40+
"data": {
41+
"status": false,
42+
"message": "Transaction not found",
43+
"meta": {
44+
"nextStep": "Ensure that you're passing the reference of a transaction that exists on this integration"
45+
},
46+
"type": "validation_error",
47+
"code": "transaction_not_found"
48+
}
49+
},
50+
"500": {
51+
"description": "500 Server Error",
52+
"data": {
53+
"status": false,
54+
"code": "unknown",
55+
"type": "api_error",
56+
"message": "An error occurred"
57+
}
58+
}
59+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
const sh = `curl https://api.paystack.co/charge
2+
-H "Authorization: Bearer YOUR_SECRET_KEY"
3+
-H "Content-Type: application/json"
4+
-d '{ "amount": 1000,
5+
"email": "drew.john@email.com",
6+
"currency": "ZAR",
7+
"capitec_pay": {
8+
"identifier_key" : "CELLPHONE",
9+
"identifier_value" : "0812345678"
10+
}
11+
}'
12+
-X POST`
13+
14+
const js = `const https = require('https')
15+
16+
const params = JSON.stringify({
17+
"email": "drew.john@mail.com",
18+
"amount": 1000,
19+
"currency": "ZAR",
20+
"capitec_pay": {
21+
"identifier_key": "CELLPHONE",
22+
"identifier_value": "0812345678"
23+
}
24+
})
25+
26+
const options = {
27+
hostname: 'api.paystack.co',
28+
port: 443,
29+
path: '/charge',
30+
method: 'POST',
31+
headers: {
32+
Authorization: 'Bearer SECRET_KEY',
33+
'Content-Type': 'application/json'
34+
}
35+
}
36+
37+
const req = https.request(options, res => {
38+
let data = ''
39+
40+
res.on('data', (chunk) => {
41+
data += chunk
42+
});
43+
44+
res.on('end', () => {
45+
console.log(JSON.parse(data))
46+
})
47+
}).on('error', error => {
48+
console.error(error)
49+
})
50+
51+
req.write(params)
52+
req.end()`
53+
54+
const php = `<?php
55+
$curl = curl_init();
56+
curl_setopt_array($curl, array(
57+
CURLOPT_URL => "https://api.paystack.co/charge",
58+
CURLOPT_RETURNTRANSFER => true,
59+
CURLOPT_ENCODING => "",
60+
CURLOPT_MAXREDIRS => 10,
61+
CURLOPT_TIMEOUT => 30,
62+
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
63+
CURLOPT_CUSTOMREQUEST => "POST",
64+
CURLOPT_POSTFIELDS => [
65+
"amount" => 1000,
66+
"email" => "drew.john@email.com",
67+
"currency" => "ZAR",
68+
"capitec_pay" => [
69+
"identifier_key" => "CELLPHONE",
70+
"identifier_value" => "0812345678"
71+
]
72+
],
73+
CURLOPT_HTTPHEADER => array(
74+
"Authorization: Bearer SECRET_KEY",
75+
"Content-Type: application/json" ),
76+
));
77+
$response = curl_exec($curl);
78+
$err = curl_error($curl);
79+
curl_close($curl);
80+
if ($err) {
81+
echo "cURL Error #:" . $err;
82+
} else {
83+
echo $response;
84+
}
85+
?>`
86+
87+
const json = `{
88+
"type": "success",
89+
"code": "ok",
90+
"data": {
91+
"status": "success",
92+
"timeToLive": 120,
93+
"expiryDate": "2026-02-17T11:29:37.000Z",
94+
"transaction": {
95+
"id": 5805764100,
96+
"reference": "nvh8o4pwtivwkx4",
97+
"domain": "live",
98+
"amount": 1000,
99+
"currency": "ZAR",
100+
"metadata": "",
101+
"createdAt": "2026-02-17T11:27:36.000Z",
102+
"customer": {
103+
"id": 180101459,
104+
"first_name": "Drew",
105+
"last_name": "John",
106+
"email": "drew.john@email.com",
107+
"customer_code": "CUS_xy1ofyzvnhagniv",
108+
"phone": "",
109+
"metadata": null,
110+
"risk_action": "default",
111+
"international_format_phone": null
112+
}
113+
}
114+
},
115+
"message": "Charge pending"
116+
}`
117+
118+
export {sh, js, php, json}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
languages:
2+
- sh
3+
- js
4+
- php
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const https = require('https')
2+
3+
const options = {
4+
hostname: 'api.paystack.co',
5+
port: 443,
6+
path: '/capitec-pay/requery/{ref}',
7+
method: 'GET',
8+
headers: {
9+
Authorization: 'Bearer SECRET_KEY'
10+
}
11+
}
12+
13+
https.request(options, res => {
14+
let data = ''
15+
16+
res.on('data', (chunk) => {
17+
data += chunk
18+
});
19+
20+
res.on('end', () => {
21+
console.log(JSON.parse(data))
22+
})
23+
}).on('error', error => {
24+
console.error(error)
25+
})
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
$curl = curl_init();
3+
4+
curl_setopt_array($curl, array(
5+
CURLOPT_URL => "https://api.paystack.co/capitec-pay/requery/{ref}",
6+
CURLOPT_RETURNTRANSFER => true,
7+
CURLOPT_ENCODING => "",
8+
CURLOPT_MAXREDIRS => 10,
9+
CURLOPT_TIMEOUT => 30,
10+
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
11+
CURLOPT_CUSTOMREQUEST => "GET",
12+
CURLOPT_HTTPHEADER => array(
13+
"Authorization: Bearer SECRET_KEY",
14+
"Cache-Control: no-cache",
15+
),
16+
));
17+
18+
$response = curl_exec($curl);
19+
$err = curl_error($curl);
20+
21+
curl_close($curl);
22+
23+
if ($err) {
24+
echo "cURL Error #:" . $err;
25+
} else {
26+
echo $response;
27+
}
28+
?>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
url="https://api.paystack.co/capitec-pay/requery/{ref}"
3+
authorization="Authorization: Bearer YOUR_SECRET_KEY"
4+
5+
curl "$url" -H "$authorization" -X GET
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"200": {
3+
"description": "200 Ok",
4+
"data": {
5+
"status": true,
6+
"type": "success",
7+
"code": "ok",
8+
"data": {
9+
"status": "success"
10+
},
11+
"message": "Charge successful"
12+
}
13+
},
14+
"200_pending": {
15+
"description": "200 Pending",
16+
"data": {
17+
"status": true,
18+
"type": "success",
19+
"code": "ok",
20+
"data": {
21+
"status": "pending"
22+
},
23+
"message": "Charge pending"
24+
}
25+
},
26+
"200_failed": {
27+
"description": "200 Failed",
28+
"data": {
29+
"status": true,
30+
"type": "success",
31+
"code": "ok",
32+
"data": {
33+
"status": "failed"
34+
},
35+
"message": "Account is de-activated, please contact Capitec for help"
36+
}
37+
},
38+
"400": {
39+
"description": "400 Bad Request",
40+
"data": {
41+
"status": false,
42+
"message": "Transaction not found",
43+
"meta": {
44+
"nextStep": "Ensure that you're passing the reference of a transaction that exists on this integration"
45+
},
46+
"type": "validation_error",
47+
"code": "transaction_not_found"
48+
}
49+
},
50+
"500": {
51+
"description": "500 Server Error",
52+
"data": {
53+
"status": false,
54+
"code": "unknown",
55+
"type": "api_error",
56+
"message": "An error occurred"
57+
}
58+
}
59+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
languages:
2+
- sh
3+
- js
4+
- php
5+
- json

0 commit comments

Comments
 (0)