diff --git a/dist/doc/payments/payment-methods/mobile-mpesa-offline.js b/dist/doc/payments/payment-methods/mobile-mpesa-offline.js new file mode 100644 index 0000000..717b409 --- /dev/null +++ b/dist/doc/payments/payment-methods/mobile-mpesa-offline.js @@ -0,0 +1,104 @@ +const sh = `curl https://api.paystack.co/charge +-H "Authorization: Bearer YOUR_SECRET_KEY" +-H "Content-Type: application/json" +-d '{ "amount": 100, + "email": "customer@email.com", + "currency": "KES", + "mobile_money": { + "phone": "254700000000", + "provider" : "mpesa_offline" + } + }' +-X POST` + +const js = `const https = require('https') + +const params = JSON.stringify({ + "amount": 100, + "email": "customer@email.com", + "currency": "KES", + "mobile_money": { + "phone": "254700000000", + "provider" : "mpesa_offline" + } +}) + +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" => 100, + "email" => "customer@email.com", + "currency" => "KES", + "mobile_money" => [ + "phone" => "254700000000", + "provider" => "mpesa_offline" + ] + ], + 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 = `{ + "status": true, + "message": "Charge attempted", + "data": { + "reference": "e6i9ak3rbq982wh", + "status": "pay_offline", + "display_text": "Please complete authorization process on your mobile phone", + "account_number": "4084333", + "account_reference": 1234567 + } +}` + +export {sh, js, php, json} \ No newline at end of file diff --git a/src/doc/payments/payment-methods/mobile-mpesa-offline/config.yml b/src/doc/payments/payment-methods/mobile-mpesa-offline/config.yml new file mode 100644 index 0000000..3509c90 --- /dev/null +++ b/src/doc/payments/payment-methods/mobile-mpesa-offline/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/mobile-mpesa-offline/index.js b/src/doc/payments/payment-methods/mobile-mpesa-offline/index.js new file mode 100644 index 0000000..285719b --- /dev/null +++ b/src/doc/payments/payment-methods/mobile-mpesa-offline/index.js @@ -0,0 +1,39 @@ +const https = require('https') + +const params = JSON.stringify({ + "amount": 100, + "email": "customer@email.com", + "currency": "KES", + "mobile_money": { + "phone": "254700000000", + "provider" : "mpesa_offline" + } +}) + +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/mobile-mpesa-offline/index.json b/src/doc/payments/payment-methods/mobile-mpesa-offline/index.json new file mode 100644 index 0000000..5f3fa77 --- /dev/null +++ b/src/doc/payments/payment-methods/mobile-mpesa-offline/index.json @@ -0,0 +1,11 @@ +{ + "status": true, + "message": "Charge attempted", + "data": { + "reference": "e6i9ak3rbq982wh", + "status": "pay_offline", + "display_text": "Please complete authorization process on your mobile phone", + "account_number": "4084333", + "account_reference": 1234567 + } +} \ No newline at end of file diff --git a/src/doc/payments/payment-methods/mobile-mpesa-offline/index.php b/src/doc/payments/payment-methods/mobile-mpesa-offline/index.php new file mode 100644 index 0000000..385f262 --- /dev/null +++ b/src/doc/payments/payment-methods/mobile-mpesa-offline/index.php @@ -0,0 +1,37 @@ + "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" => "customer@email.com", + "currency" => "KES", + "mobile_money" => [ + "phone" => "254700000000", + "provider" => "mpesa_offline" + ] + ], + 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/mobile-mpesa-offline/index.sh b/src/doc/payments/payment-methods/mobile-mpesa-offline/index.sh new file mode 100644 index 0000000..9ee7f11 --- /dev/null +++ b/src/doc/payments/payment-methods/mobile-mpesa-offline/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": 100, + "email": "customer@email.com", + "currency": "KES", + "mobile_money": { + "phone": "254700000000", + "provider" : "mpesa_offline" + } + }' +-X POST \ No newline at end of file