Closed AbeNalee closed 3 years ago
@AbeNalee . I have issues integration this package. Which Mpesa.php should require on my files so as to instantiate because i cant successfully instantiate like ..$mpesa= new \Safaricom\Mpesa\Mpesa();
Kindly help
@jSoftKenya you should import Safaricom\Mpesa\Mpesa at the top of your class like:
use Safaricom\Mpesa\Mpesa;
You can then use $mpesa = new Mpesa;
Also good to note is that some methods in Mpesa.php are static and others are non static. As such, you can use the Mpesa facade to invoke some methods like Mpesa::c2b
. but I would recommend sticking to the new Mpesa
syntax so that you call a new instance of the class each time.
@AbeNalee Thanks. it works. But I am having trouble registering the confirmation and validation urls for c2b. Any help will be appreciated
Hi @jSoftKenya, Sorry for the late reply. The php sdk cannot register the urls for you. You can use postman to achieve this task using the url for registration. Use the syntax as is in the documentation.
Hi, I totally love how this package has simplified the API and I've been using it for a while now. However, I noted that there was an issue with the result returned by the getDataFromCallback method.
What is expected is a JSON object, but for some reason, the result is a "non-object" that brings up that common error of "trying to get property 'x' of non-object". Upon logging the result, I could swear it looked like an object with accessible properties. Here is an example of a logged result:
{ "TransactionType": "Pay Bill", "TransID": "NCD81H87FU", "TransTime": "20190313163806", "TransAmount": "100.00", "BusinessShortCode": "600364", "BillRefNumber": "0000", "InvoiceNumber": "", "OrgAccountBalance": "129635.00", "ThirdPartyTransID": "", "MSISDN": "254708374149", "FirstName": "John", "MiddleName": "J.", "LastName": "Doe" }
I ended up taking the posted request as it was (an array) and handling it from my controller directly before using the finishTransaction method to send a response to the API.
Could you tell me a way to make it stop bringing up that said error? I'm impartial about retrieving the values from an array due to efficiency issues(even though it works). Any help would be appreciated. Thanks!