<form method='POST' id='ipayform' action='https://ipayairtime.com/vpay/' /> <input type='hidden' name='merchant_id' value='wydf1234' /> <input type='hidden' name='product_name' value='iPay Stickers' /> <input type='hidden' name='product_desc' value='Order for Stickers on iPayAirtime' /> <input type='hidden' name='product_price' value='200' /> <input type='hidden' name='product_ref' value='08103966224' /> <input type='hidden' name='notify_url' value='http://www.yourdomain.com/notify.php' /> <input type='hidden' name='complete_url' value='http://www.yourdomain.com/complete.php' /> <input type='submit' alt='Submit' value='Pay with Airtime' /> </form>
$service_url = 'https:/ipayairtime.com/vpay-v/'; $curl = curl_init($service_url); $curl_post_data = array ( 'merchant_id' => 'your_merchant_id', 'product_ref' => 'xxxxxx', //reference no, unique id 'product_price' => 200, 'sender' => '08139170491', //MTN phone of sender 'email' => 'xxx@yyy.com', //sender email 'notify_url' => 'http://yourdomain.com/notify.php' //transaction ID will be sent to this URL ); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data); $curl_response = curl_exec($curl); curl_close($curl); ///////////////////////////Decide what you do with the responses print $curl_response;
Example 1 { "status":"success", "sim_support":"08169567985", "message":"Transfer N105 from 08139170491 to 08169567985 within 10minutes" }Example 2 { "status":"failed", "message":"Invalid price. Minimum is 200 and maximum is 5000" }
if(isset($_POST['transid'])){ $curl = curl_init(); $transid=$_POST['transid']; // Set some options - we are passing in a useragent too here curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => "https://ipayairtime.com/vp_transaction?tid=$transid", CURLOPT_USERAGENT => 'Codular Sample cURL Request' )); // Send the request & save response to $resp $resp = curl_exec($curl); // Close request to clear up some resources curl_close($curl); if($resp){ $result = json_decode($resp, true); $status=$result['status']; $transid=$result['transid']; $refno=$result['refno']; $amount=$result['price']; if($status == 'success'){ //Do anything you want with the transaction details } else{ //It's up to you to decide } } } else{ die ('No transaction'); }
$str=file_get_contents("https://ipayairtime.com/ip_transaction?merchant_id=xxxx&refno=XXXX"); print_r ($str);
{ "status":"success", "transid":"123456", "refno":"891099", "price":500, }