-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcapitec-pay.js
More file actions
118 lines (108 loc) · 2.59 KB
/
capitec-pay.js
File metadata and controls
118 lines (108 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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 = `<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "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}