function process($name, $phone, $amount, $receipt) { $this->response_arr = array('RESULT' => 0, 'RESPONCE' => '', 'id' => 0); try { $pesa = new PLUSPEOPLE\PesaPi\PesaPi(); $transactions = $pesa->locateByReceipt($receipt); dmp($transactions[0]); if (count($transactions) == 0) { $this->response_arr = array('RESULT' => '1', 'RESPONCE' => 'Pending, Incoming Mobile Money Transaction Not found '); throw new Exception('Pending, Incoming Mobile Money Transaction Not found '); } else { $transaction = $transactions[0]; if ($transaction->getPhonenumber() != $phone) { $this->response_arr = array('RESULT' => '8', 'RESPONCE' => 'Invalid phone'); throw new Exception('Invalid phone'); } else { if ($transaction->getName() != $name) { $this->response_arr = array('RESULT' => '7', 'RESPONCE' => 'Invalid name'); throw new Exception('Invalid name'); } else { if ($transaction->getAmount() < $amount) { $this->response_arr = array('RESULT' => '3', 'RESPONCE' => 'Pending, Incoming Mobile Money Transaction Not found '); throw new Exception('Pending, Incoming Mobile Money Transaction Not found'); } else { if ($transaction->getAmount() > $amount) { $this->response_arr = array('RESULT' => '4', 'RESPONCE' => 'Pending, Incoming Mobile Money Transaction Not found '); throw new Exception('Pending, Incoming Mobile Money Transaction Not found'); } } } } $this->response_arr['id'] = $transaction->getId(); } } catch (Exception $e) { throw $e; } return $this->response_arr; }
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. File originally by Michael Pedersen <*****@*****.**> */ set_include_path("../local_include:../include:" . get_include_path()); require_once "PLUSPEOPLE/autoload.php"; // Define constants $payloadSuccess = "OK|"; $payloadFailure = 'FAIL|'; $pesa = new PLUSPEOPLE\PesaPi\PesaPi(); // Identifier $identifier = $_GET["business_number"]; $accounts = $pesa->getAccount($identifier); if (is_object($accounts[0]) and $accounts[0]->getIdentifier() == $identifier) { $transaction = $accounts[0]->importIPN($_GET); if (is_object($transaction)) { print $payloadSuccess; exit; } } print $payloadSuccess; // NOT DONE
All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of PLUSPEOPLE nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ set_include_path("../include:" . get_include_path()); require_once "PLUSPEOPLE/autoload.php"; // Simple syncronisation example $pesa = new PLUSPEOPLE\PesaPi\PesaPi(); $pesa->forceSyncronisation();
<?php set_include_path("../../local_include:../../include:" . get_include_path()); require_once "PLUSPEOPLE/autoload.php"; // Simple syncronisation example $pesa = new PLUSPEOPLE\PesaPi\PesaPi(); print "Available balance: " . $pesa->availableBalance() . "\n";
<?php session_start(); //This page is here for the user to input an Mpesa receipt number //This number will be used to confirm whether he has carried out an Mpesa transaction //and that indeed the Mpesa transaction amount conforms with the package chosen $path = 'F:\\Dropbox\\Projects\\LipaNaPesaPi\\pesaPi\\php\\include'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); require_once "F:\\Dropbox\\Projects\\LipaNaPesaPi\\pesaPi\\php\\include\\PLUSPEOPLE\\autoload.php"; //require_once("hotspot.php"); $pesa = new PLUSPEOPLE\PesaPi\PesaPi(); //retrieve the package chosen from the hostpot.php page if (isset($_POST["package"])) { //SET SESSION VARIABLES $_SESSION["package"] = $_POST["package"]; // $_SESSION["name"] = "name"; // $_SESSION["email"] = "email"; // $_SESSION["phone"] = "phone"; } //draw the receipt input box ?> <html> <body> <form method="POST" action="buy2.php"> <input type="text" name="receipt" value=""><br> <input type= submit id="confirmation" value="Confirm"> </form> </body> </html> <?php //check whether the receipt matches with database and conforms with the selected package