Skip to content

Feat/add mpesa till #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions dist/doc/payments/payment-methods/mobile-mpesa-till.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
const sh = `curl https://api.paystack.co/charge
-H "Authorization: Bearer YOUR_SECRET_KEY"
-H "Content-Type: application/json"
-d '{ "amount": 100,
"email": "[email protected]",
"currency": "KES",
"mobile_money": {
"account" : "1234567",
"provider" : "mptill"
}
}'
-X POST`

const js = `const https = require('https')

const params = JSON.stringify({
"amount": 100,
"email": "[email protected]",
"currency": "KES",
"mobile_money": {
"account" : "1234567",
"provider" : "mptill"
}
})

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" => 100,
"email" => "[email protected]",
"currency" => "KES",
"mobile_money" => [
"account" => "1234567",
"provider" => "mptill"
]
],
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;
}`

export {sh, js, php}
4 changes: 4 additions & 0 deletions src/doc/payments/payment-methods/mobile-mpesa-till/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
languages:
- sh
- js
- php
39 changes: 39 additions & 0 deletions src/doc/payments/payment-methods/mobile-mpesa-till/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const https = require('https')

const params = JSON.stringify({
"amount": 100,
"email": "[email protected]",
"currency": "KES",
"mobile_money": {
"account" : "1234567",
"provider" : "mptill"
}
})

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()
37 changes: 37 additions & 0 deletions src/doc/payments/payment-methods/mobile-mpesa-till/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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" => 100,
"email" => "[email protected]",
"currency" => "KES",
"mobile_money" => [
"account" => "1234567",
"provider" => "mptill"
]
],
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;
}
12 changes: 12 additions & 0 deletions src/doc/payments/payment-methods/mobile-mpesa-till/index.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
curl https://api.paystack.co/charge
-H "Authorization: Bearer YOUR_SECRET_KEY"
-H "Content-Type: application/json"
-d '{ "amount": 100,
"email": "[email protected]",
"currency": "KES",
"mobile_money": {
"account" : "1234567",
"provider" : "mptill"
}
}'
-X POST