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='' />
  <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='' />
  <input type='hidden' name='complete_url' value='' />

  <input type='submit' alt='Submit' value='Pay with Airtime' />

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;

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


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:/';
	   $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' => '', //sender email
		'notify_url' => '' //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);
	///////////////////////////Decide what you do with the responses
	print $curl_response;


	Example 1
		"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.

	$curl = curl_init();
	// Set some options - we are passing in a useragent too here
	curl_setopt_array($curl, array(
		CURLOPT_URL => "$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
		$result = json_decode($resp, true);
		if($status == 'success'){
			//Do anything you want with the transaction details						
			//It's up to you to decide		
	die ('No transaction');