Look at this. It may give you an idea how to "pull" payment info about a transaction whose code the user has entered in a form. This is assuming that you have set up everything with Safcom as needed, including giving them an IP to be sending your IPN information to :
public static function pull($terminal_msisdn, $password, $code)
{
$post_string = "<soapenv:Envelope xmlns:soapenv=\"
http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ipn=\"
http://ipn/\">
<soapenv:Header/>
<soapenv:Body>
<ipn:retrieveTransaction>
<transactionCode>{$code}</transactionCode>
<senderMsisdn></senderMsisdn>
<terminalMsisdn>{$terminal_msisdn}</terminalMsisdn>
<password>{$password}</password>
</ipn:retrieveTransaction>
</soapenv:Body>
</soapenv:Envelope>";
$url = "
https://www.safaricom.co.ke/IPN/IpnWebRetrieval";
$response = curl::post($url, $post_string);
$xml = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response);
$xml = simplexml_load_string($xml);
if (isset($xml->soapBody->ns2retrieveTransactionResponse->transaction)) {
return $xml->soapBody->ns2retrieveTransactionResponse->transaction;
}
return false;
}
json_decode() 'ing the returned value will give you an object with all the info you need about the payer.
$terminal_msisdn, $password are you LIPA-NA-MPESA's real msisdn and password assigned by Safcom.