Saturday, 12 January 2013 11:32

Pesapal Iframe

Written by 
Rate this item
(0 votes)

?php include_once('OAuth.php'); //pesapal params $token = $params = NULL; /* PesaPal Sandbox is at Use this to test your developement and when you are ready to go live change to */ $consumer_key = 'd77qEnLfsbAfaqPVFl1HTLFOHitUtA6J';//Register a merchant account on // and use the merchant key for testing. //When you are ready to go live make sure you change the key to the live account //registered on! $consumer_secret = 'JihNJmm93qkDanEaYbi3wxg1JUk=';// Use the secret from your test //account on When you are ready to go live make sure you //change the secret to the live account registered on! $signature_method = new OAuthSignatureMethod_HMAC_SHA1(); $iframelink = '';//change to // when you are ready to go live! //get form details $amount = $_POST['amount']; $amount = number_format($amount, 2);//format amount to 2 decimal places $desc = $_POST['description']; $type = $_POST['type']; //default value = MERCHANT $reference = $_POST['reference'];//unique order id of the transaction, generated by merchant $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $phonenumber = '';//ONE of email or phonenumber is required $callback_url = ''; //redirect url, the page that will handle the response from pesapal. $post_xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><PesapalDirectOrderInfo xmlns:xsi=\"\" xmlns:xsd=\"\" Amount=\"".$amount."\" Description=\"".$desc."\" Type=\"".$type."\" Reference=\"".$reference."\" FirstName=\"".$first_name."\" LastName=\"".$last_name."\" Email=\"".$email."\" PhoneNumber=\"".$phonenumber."\" xmlns=\"\" />"; $post_xml = htmlentities($post_xml); $consumer = new OAuthConsumer($consumer_key, $consumer_secret); //post transaction to pesapal $iframe_src = OAuthRequest::from_consumer_and_token($consumer, $token, "GET", $iframelink, $params); $iframe_src->set_parameter("oauth_callback", $callback_url); $iframe_src->set_parameter("pesapal_request_data", $post_xml); $iframe_src->sign_request($signature_method, $consumer, $token); //display pesapal - iframe and pass iframe_src ?> <iframe src="/" width="100%" height="620px" scrolling="no" frameBorder="0"> <p>Browser unable to load iFrame</p> </iframe>'

Read 166018 times Last modified on Sunday, 13 January 2013 08:34
More in this category: « Contact Us


Leave a comment

Make sure you enter the (*) required information where indicated.Basic HTML code is allowed.

Online Shopping

Lipa Na M-Pesa

About Us

The Africa Nature Organization is a not-for-profit non-governmental organization registered in Kenya. Read More..

Contact Us

+254 (20) 2606100
+254 721 114 958

This email address is being protected from spambots. You need JavaScript enabled to view it.

University of Nairobi