Developer API Integration

Accept airtime as payment on your website. Integration is simple and seamless. A business account is required for the API.

- Sample HTML form with Notification
- RESTFUL API with Notification

The Parameters

merchant_id - This is your merchant ID. Log in to your account and click the BUSINESS menu for your merchant ID
product_name - Name of product. This parameter is required.
product_desc - Description of product. This parameter is required.
product_price - Product price i.e. amount. Price is between 100 and 5000. This parameter is required.
product_ref - This parameter can be used to store any data and can be retrieved later with the transaction details i.e. amount. This parameter is recommended.
notify_url - A notification would be sent to this URL without redirection. The transaction ID (transid) will be sent to this URL. This parameter is optional.
complete_url - Buyers will be automatically redirected to this URL. This parameter is optional.

Sample HTML form with Notification

<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>
                            

Once the transaction ID (transid) is pushed to your notify_url, you can the use the transaction ID to query the status of the transaction.
The result of the transaction query is a text (string) separated with pipe (|). See format below;
status|product_ref|amount

For successful response; success|xxx|200
where xxx = product_ref

For failed response; failed|xxxx|200
Download Sample PHP file for notify URL and to query transaction here

RESTFUL API

Ipayairtime RESTful API with JSON response.
To initiate airtime deposit request with PHP. It is important and necessary to first initiate a deposit request.
		
	$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;

		

Responses
	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" }


Sample Notify URL in PHP
After a successful deposit, a notification will be sent to the notify_url. The notification is the transaction ID (transid) and you can use it to confirm the status of the transaction.
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');
}