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 http://demo.pesapal.com. Use this to test your developement and when you are ready to go live change to https://www.pesapal.com. */ $consumer_key = 'd77qEnLfsbAfaqPVFl1HTLFOHitUtA6J';//Register a merchant account on //demo.pesapal.com 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 www.pesapal.com! $consumer_secret = 'JihNJmm93qkDanEaYbi3wxg1JUk=';// Use the secret from your test //account on demo.pesapal.com. When you are ready to go live make sure you //change the secret to the live account registered on www.pesapal.com! $signature_method = new OAuthSignatureMethod_HMAC_SHA1(); $iframelink = 'https://www.pesapal.com/API/PostPesapalDirectOrderV4';//change to //https://www.pesapal.com/API/PostPesapalDirectOrderV4 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 = 'http://www.africanature.or.ke/redirect.php'; //redirect url, the page that will handle the response from pesapal. $post_xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><PesapalDirectOrderInfo xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" Amount=\"".$amount."\" Description=\"".$desc."\" Type=\"".$type."\" Reference=\"".$reference."\" FirstName=\"".$first_name."\" LastName=\"".$last_name."\" Email=\"".$email."\" PhoneNumber=\"".$phonenumber."\" xmlns=\"http://www.pesapal.com\" />"; $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

729 comments

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

Telephone:
+254 (20) 2606100
+254 721 114 958

Email:(Info)
This email address is being protected from spambots. You need JavaScript enabled to view it.

University of Nairobi