Skip to content

Commit 2376b7a

Browse files
Merge pull request #105 from PaystackOSS/fix/update-preauth
Add pay with Pesalink
2 parents 4b420cf + 817fb06 commit 2376b7a

File tree

6 files changed

+220
-0
lines changed

6 files changed

+220
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
const sh = `#!/bin/sh
2+
3+
url="https://api.paystack.co/charge"
4+
authorization="Authorization: Bearer YOUR_SECRET_KEY"
5+
content_type="Content-Type: application/json"
6+
data='{
7+
"email": "[email protected]",
8+
"amount": "10000",
9+
"bank_transfer": {
10+
"account_expires_at": "2025-04-24T16:40:57.954Z"
11+
}
12+
}'
13+
14+
curl "$url" -H "$authorization" -H "$content_type" -d "$data" -X POST`
15+
16+
const js = `const https = require('https')
17+
18+
const params = JSON.stringify({
19+
"email": "[email protected]",
20+
"amount": "10000",
21+
"bank_transfer": {
22+
"account_expires_at": "2025-04-24T16:40:57.954Z"
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+
57+
curl_setopt_array($curl, array(
58+
CURLOPT_URL => "https://api.paystack.co/charge",
59+
CURLOPT_RETURNTRANSFER => true,
60+
CURLOPT_ENCODING => "",
61+
CURLOPT_MAXREDIRS => 10,
62+
CURLOPT_TIMEOUT => 30,
63+
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
64+
CURLOPT_CUSTOMREQUEST => "POST",
65+
CURLOPT_POSTFIELDS => [
66+
"email" => "[email protected]",
67+
"amount" => "10000",
68+
"bank_transfer" => [
69+
"account_expires_at" => "2025-04-24T16:40:57.954Z"
70+
]
71+
],
72+
CURLOPT_HTTPHEADER => array(
73+
"Authorization: Bearer SECRET_KEY",
74+
"Cache-Control: no-cache"
75+
),
76+
));
77+
78+
$response = curl_exec($curl);
79+
$err = curl_error($curl);
80+
81+
curl_close($curl);
82+
83+
if ($err) {
84+
echo "cURL Error #:" . $err;
85+
} else {
86+
echo $response;
87+
}
88+
?>`
89+
90+
const json = `{
91+
"status": true,
92+
"message": "Charge attempted",
93+
"data": {
94+
"reference": "kcvu0t3kzs",
95+
"status": "pending_bank_transfer",
96+
"display_text": "Please make a transfer to the account specified",
97+
"account_name": "Paystack Payments Kenya Limited",
98+
"account_number": "1234567891",
99+
"bank": {
100+
"slug": "dtbk-bank",
101+
"name": "Diamond Trust Bank Kenya Ltd",
102+
"id": 225
103+
},
104+
"account_expires_at": "2025-04-24T16:55:57.954Z",
105+
"amount": 10000,
106+
"transaction_reference": "1234567"
107+
}
108+
}`
109+
110+
export {sh, js, php, json}
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
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const https = require('https')
2+
3+
const params = JSON.stringify({
4+
"email": "[email protected]",
5+
"amount": "10000",
6+
"bank_transfer": {
7+
"account_expires_at": "2025-04-24T16:40:57.954Z"
8+
}
9+
})
10+
11+
const options = {
12+
hostname: 'api.paystack.co',
13+
port: 443,
14+
path: '/charge',
15+
method: 'POST',
16+
headers: {
17+
Authorization: 'Bearer SECRET_KEY',
18+
'Content-Type': 'application/json'
19+
}
20+
}
21+
22+
const req = https.request(options, res => {
23+
let data = ''
24+
25+
res.on('data', (chunk) => {
26+
data += chunk
27+
});
28+
29+
res.on('end', () => {
30+
console.log(JSON.parse(data))
31+
})
32+
}).on('error', error => {
33+
console.error(error)
34+
})
35+
36+
req.write(params)
37+
req.end()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"status": true,
3+
"message": "Charge attempted",
4+
"data": {
5+
"reference": "kcvu0t3kzs",
6+
"status": "pending_bank_transfer",
7+
"display_text": "Please make a transfer to the account specified",
8+
"account_name": "Paystack Payments Kenya Limited",
9+
"account_number": "1234567891",
10+
"bank": {
11+
"slug": "dtbk-bank",
12+
"name": "Diamond Trust Bank Kenya Ltd",
13+
"id": 225
14+
},
15+
"account_expires_at": "2025-04-24T16:55:57.954Z",
16+
"amount": 10000,
17+
"transaction_reference": "1234567"
18+
}
19+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
$curl = curl_init();
3+
4+
curl_setopt_array($curl, array(
5+
CURLOPT_URL => "https://api.paystack.co/charge",
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 => "POST",
12+
CURLOPT_POSTFIELDS => [
13+
"email" => "[email protected]",
14+
"amount" => "10000",
15+
"bank_transfer" => [
16+
"account_expires_at" => "2025-04-24T16:40:57.954Z"
17+
]
18+
],
19+
CURLOPT_HTTPHEADER => array(
20+
"Authorization: Bearer SECRET_KEY",
21+
"Cache-Control: no-cache"
22+
),
23+
));
24+
25+
$response = curl_exec($curl);
26+
$err = curl_error($curl);
27+
28+
curl_close($curl);
29+
30+
if ($err) {
31+
echo "cURL Error #:" . $err;
32+
} else {
33+
echo $response;
34+
}
35+
?>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
url="https://api.paystack.co/charge"
4+
authorization="Authorization: Bearer YOUR_SECRET_KEY"
5+
content_type="Content-Type: application/json"
6+
data='{
7+
"email": "[email protected]",
8+
"amount": "10000",
9+
"bank_transfer": {
10+
"account_expires_at": "2025-04-24T16:40:57.954Z"
11+
}
12+
}'
13+
14+
curl "$url" -H "$authorization" -H "$content_type" -d "$data" -X POST

0 commit comments

Comments
 (0)