File tree Expand file tree Collapse file tree 4 files changed +92
-0
lines changed
src/doc/payments/payment-methods/mobile-mpesa-till Expand file tree Collapse file tree 4 files changed +92
-0
lines changed Original file line number Diff line number Diff line change 1+ languages :
2+ - sh
3+ - js
4+ - php
Original file line number Diff line number Diff line change 1+ const https = require ( 'https' )
2+
3+ const params = JSON . stringify ( {
4+ "amount" : 100 ,
5+ 6+ "currency" : "KES" ,
7+ "mobile_money" : {
8+ "account" : "1234567" ,
9+ "provider" : "mptill"
10+ }
11+ } )
12+
13+ const options = {
14+ hostname : 'api.paystack.co' ,
15+ port : 443 ,
16+ path : '/charge' ,
17+ method : 'POST' ,
18+ headers : {
19+ Authorization : 'Bearer SECRET_KEY' ,
20+ 'Content-Type' : 'application/json'
21+ }
22+ }
23+
24+ const req = https . request ( options , res => {
25+ let data = ''
26+
27+ res . on ( 'data' , ( chunk ) => {
28+ data += chunk
29+ } ) ;
30+
31+ res . on ( 'end' , ( ) => {
32+ console . log ( JSON . parse ( data ) )
33+ } )
34+ } ) . on ( 'error' , error => {
35+ console . error ( error )
36+ } )
37+
38+ req . write ( params )
39+ req . end ( )
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ $ curl = curl_init ();
4+
5+ curl_setopt_array ($ curl , array (
6+ CURLOPT_URL => "https://api.paystack.co/charge " ,
7+ CURLOPT_RETURNTRANSFER => true ,
8+ CURLOPT_ENCODING => "" ,
9+ CURLOPT_MAXREDIRS => 10 ,
10+ CURLOPT_TIMEOUT => 30 ,
11+ CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1 ,
12+ CURLOPT_CUSTOMREQUEST => "POST " ,
13+ CURLOPT_POSTFIELDS => [
14+ "amount " => 100 ,
15+ 16+ "currency " => "KES " ,
17+ "mobile_money " => [
18+ "account " => "1234567 " ,
19+ "provider " => "mptill "
20+ ]
21+ ],
22+ CURLOPT_HTTPHEADER => array (
23+ "Authorization: Bearer SECRET_KEY " ,
24+ "Content-Type: application/json "
25+ ),
26+ ));
27+
28+ $ response = curl_exec ($ curl );
29+ $ err = curl_error ($ curl );
30+
31+ curl_close ($ curl );
32+
33+ if ($ err ) {
34+ echo "cURL Error #: " . $ err ;
35+ } else {
36+ echo $ response ;
37+ }
Original file line number Diff line number Diff line change 1+ curl https://api.paystack.co/charge
2+ -H " Authorization: Bearer YOUR_SECRET_KEY"
3+ -H " Content-Type: application/json"
4+ -d ' { "amount": 100,
5+ 6+ "currency": "KES",
7+ "mobile_money": {
8+ "account" : "1234567",
9+ "provider" : "mptill"
10+ }
11+ }'
12+ -X POST
You can’t perform that action at this time.
0 commit comments