1.2 How to post your parameters to iPay for processing



We need to generate the hash signature id that is to be sent to the iPay system for authentication against the transaction values that are also to be received on the same URL call.

We are using the hash_hmac function in PHP to digitally sign the transaction data.

Depending on the programming language of your choice, please feel free to use it or the equivalent HMAC function in your programming language.

Here is a PHP example below: There are two important parameters that are required by this function.

  1. The secret and private key - $hashkey - this key is generated by you. Please also send it to us for registration in your iPay account.
  2. The string to be hashed - $datastring - this string is composed of ALL the parameters you are passing to iPay in the following CONCATENATED format. The order of the transaction variables is VERY IMPORTANT and MUST be followed. There are NO SPACES between the different values below.

=  $live.$order_id.$invoice.$total.$phone.$email.$vid.$curr.$p1.$p2.$p3.$p4.$cbk.$cst.$crl;
$hashkey "yoursecuritykey"//Supply to us during iPay account registration;
$datastring//This is a string generated from the data to be posted (see above)
$hashid hash_hmac("sha1"$datastring$hashkey); //Set hashing algorithm to SHA1;
If you are having trouble implementing this function, see Section 2.5 below.

Sample POST Formwith (PHP)

This is a sample PHP script of how you would ideally integrate with iPay Payments Gateway and also handling the 
callback from iPay and doing the IPN check

            ************(A.) INTEGRATING WITH iPAY ***********************************************
//Data needed by iPay a fair share of it obtained from the user from a form e.g email, number etc...
$fields = array("live"=> "0",
"oid"=> "112",
"inv"=> "112020102292999",
"ttl"=> "900",
"tel"=> "256712375678",
"eml"=> "kajuej@gmailo.com",
"vid"=> "demo",
"curr"=> "KES",
"p1"=> "airtel",
"p2"=> "020102292999",
"p3"=> "",
"p4"=> "900",
"cst"=> "1",
"crl"=> "2"
************(b.) GENERATING THE HASH PARAMETER FROM THE DATASTRING *********************************

The datastring IS concatenated from the data above
$datastring =  $fields['live'].$fields['oid'].$fields['inv'].$fields['ttl'].$fields['tel'].$fields['eml'].$fields['vid'].$fields['curr'].$fields['p1'].$fields['p2'].$fields['p3'].$fields['p4'].$fields['cbk'].$fields['cst'].$fields['crl'];
$hashkey ="demo";//use "demo" for testing where vid also is set to "demo"

* Generating the HashString sample
$generated_hash hash_hmac('sha1',$datastring $hashkey);

<!--    Generate the form BELOW   -->
   <form method="post" action="https://payments.ipayafrica.com/v3/ke">

foreach ($fields as $key => $value) {
'&nbsp;:<input name="'.$key.'" type="text" value="'.$value.'"></br>';
?>hsh:&nbsp;<input name="hsh" type="text" value="<?php echo $generated_hash ?>" ></td>

<button type="submit">&nbsp;Lipa&nbsp;</button>