abdulmueid / mpesa-php-api

PHP library for M-Pesa API (Mozambique)
MIT License
44 stars 26 forks source link

Composer issue #7

Closed TelvioSheldon closed 4 years ago

TelvioSheldon commented 4 years ago

Good afternoon Abdul, I'm having a problem with the latest update of your mpesa api sdk. I keep getting this error whenever I try to use composer:

abdulmueid commented 4 years ago

Hi,

Can you please share your composer.json or command that you are running to pull the package?

Thanks

TelvioSheldon commented 4 years ago

I was able to fix the previous error. But now, I always get the responseDescription as being an "MSISDN invalid", I would like to know if that is supposed to happen when I'm in development. PS: I'm not using a production key Thanks

kishannareshpal commented 4 years ago

Hey @TelvioSheldon, Could you show us the snippet of the code so it will be easier to guide you.

Also, as the response clearly states, please check if the msisdn you are providing is a valid msisdn “25884...”

✌🏻

TelvioSheldon commented 4 years ago

snippet

abdulmueid commented 4 years ago

Hi @TelvioSheldon,

You do not have to manually validate/normalize MSISDN as it is done automatically for you when you call any of the transaction functions.

Also, make sure the numbers are formatted correctly either as 84xxxxxxx or 25884xxxxxxx

TelvioSheldon commented 4 years ago

Hello once again @abdulmueid . I followed your instructions, but I'm still getting the same description, I even printed the MSISDN (inside the payment function) to make sure it is valid. response

abdulmueid commented 4 years ago

Hi @TelvioSheldon,

I am unable to replicate the issue you are having. I also notice in your previous screenshot that you are not requiring the library using composer i.e. require_once 'vendor/autoload.php'.

Can you run composer require abdulmueid/mpesa, make sure it pulls 1.0.0 and use the following code:

<?php
require_once "vendor\autoload.php";

$config = new \abdulmueid\mpesa\Config(
    "<PUBLIC_KEY_HERE>",
    "api.sandbox.vm.co.mz",
    "<API_KEY_HERE>",
    "developer.mpesa.vm.co.mz",
    "171717",
    "MPesa2018",
    "Mpesa2019"
);

$transaction = new \abdulmueid\mpesa\Transaction($config);
$result = $transaction->payment("<MSISDN_HERE>", "1", bin2hex(random_bytes(8)), bin2hex(random_bytes(8)));
print_r($result->getResponse());

Replace <*_HERE> params with your details and try again?

abdulmueid commented 4 years ago

Closing due to inactivity