Exemple #1
0
 public function AJAXTestCertificate()
 {
     $identifier = $_POST["identifier"];
     $account = \PLUSPEOPLE\PesaPi\Base\AccountFactory::factoryByIdentifier($identifier);
     if (is_object($account)) {
         $settings = $account->getSettings();
         if (trim($settings["CERTIFICATE"]) != "") {
             $cookieFile = tmpfile();
             $curl = curl_init("https://ke.m-pesa.com");
             curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($curl, CURLOPT_COOKIESESSION, true);
             curl_setopt($curl, CURLOPT_COOKIEJAR, $cookieFile);
             curl_setopt($curl, CURLOPT_HEADER, true);
             curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
             curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
             curl_setopt($curl, CURLOPT_SSLCERT, $settings["CERTIFICATE"]);
             curl_setopt($curl, CURLOPT_SSLCERTTYPE, "PEM");
             curl_setopt($curl, CURLOPT_URL, "https://ke.m-pesa.com/ke/");
             curl_setopt($curl, CURLOPT_POST, false);
             curl_setopt($curl, CURLOPT_COOKIEFILE, $cookieFile);
             $searchPage = curl_exec($curl);
             if ($searchPage != "" and stripos($searchPage, 'Welcome to the M-PESA Administration Website') !== FALSE) {
                 print "OK";
                 exit;
             } else {
                 print "FAIL";
                 exit;
             }
         }
     }
     print "FAIL";
     exit;
 }
Exemple #2
0
 public function getAccount($identifier)
 {
     if ($identifier != "") {
         $accounts = array();
         $account = Base\AccountFactory::factoryByIdentifier($identifier);
         if (is_object($account)) {
             $accounts[] = $account;
         }
     } else {
         $accounts = Base\AccountFactory::factoryAll();
     }
     return $accounts;
 }