abdulmueid / mpesa-php-api

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

openssl_public_encrypt(): key parameter is not a valid public key #4

Closed herquiloidehele closed 5 years ago

herquiloidehele commented 5 years ago

Estou com problemas no método getBearerToken() da class Config. Não é possível gerar o Authorization Token através dessa função.

Mas consigo autenticar-me a API com o Authorization Token disponibilizado no exemplo da documentação oficial.

Thanks in advance!

abdulmueid commented 5 years ago

Hi,

Are you working with the v1x branch of the API? I just tried the code and it's producing the token, and the token works fine. Can you share your code perhaps (without the keys).

osvaldoM commented 5 years ago

I also just wrote a simple snippet for someone using the lib and it seemed to work fine for me too.

herquiloidehele commented 5 years ago

Hi,

Are you working with the v1x branch of the API? I just tried the code and it's producing the token, and the token works fine. Can you share your code perhaps (without the keys).

First of all, sorry for the delay

No, i was using the master one. But right now i am working with v1x branch and it works smoothly on local environment, when it comes to implement it on an hosted application (on the server) it returns this error message. Failed to connect to api.sandbox.vm.co.mz port 18352: Connection refused

My code snipet2

The response snipet3

Thank you.

abdulmueid commented 5 years ago

Can you ping api.sandbox.vm.co.mz from your server? What is your server IP address?

herquiloidehele commented 5 years ago

The ping result: Request Timed Out oing

My server IP address: 160.153.140.95

abdulmueid commented 5 years ago

I notice ping responses are disabled. Can you run the following from the server:

curl -X POST https://api.sandbox.vm.co.mz:18352/ipg/v1x/c2bPayment/singleStage/

You should get an output saying bearer token missing, meaning connection is successful and headers/parameters are missing.

herquiloidehele commented 5 years ago

Output: curl: (7) could not connect to the host from my server. But from others machines I got this output bearer token missing I think there is something wrong with my own server, maybe a port problem.

I am using an Godaddy VPS .

herquiloidehele commented 5 years ago

Thanks for your help.