forked from alvin-kiveu/TINYPESA-STK-PUSH-WITH-PHP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tinypesa.php
33 lines (27 loc) · 909 Bytes
/
tinypesa.php
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
<?php
$amount = '1'; //Amount to transact
$phonenuber = '07xxxxxxx'; // Phone number paying
$Account_no = 'UMESKIA SOFTWARES'; // Enter account number optional
$url = 'https://tinypesa.com/api/v1/express/initialize';
$data = array(
'amount' => $amount,
'msisdn' => $phonenuber,
'account_no'=>$Account_no
);
$headers = array(
'Content-Type: application/x-www-form-urlencoded',
'ApiKey: xxxxxxxxxx' // Replace with your api key
);
$info = http_build_query($data);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $info);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$resp = curl_exec($curl);
$msg_resp = json_decode($resp);
if($msg_resp ->success == 'true'){
echo "WAIT FOR NEVEREST STK POP UP";
}
?>