Closed benimachira closed 4 years ago
If you are in the sandbox make sure to to initialize like Mpesa.with(context, CONSUMER_KEY, CONSUMER_SECRET, Mode.SANDBOX);
That i have , have you tried to use the app(with test credentials ) it is like there is an issue with the test credentials provided by safaricom. Since the error is still the same, since that methods is being executed and success is ok. ` @Override public void onAuthSuccess() { Toast.makeText(context,"Auth succes ",Toast.LENGTH_LONG).show();
pay.setEnabled(true);
}`
Ok. Let me look at it. It must have been a recent change then since I have always keep a tabs with the documentation.
A tip for the next guy, just incase you get this error, when you creating the app on daraja dashboard, ensure that Lipa na Mpesa is selected when creating the app
When i click pay i get Invalid Access Token. My Access token in Daraja Dashboard is active and have not yet expired.
I am using the test details from the dashboard as below
public static final String BUSINESS_SHORT_CODE = "174379"; public static final String PASSKEY = "bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919";
`private void pay(String phone, int amount){ dialog.show();
// SharedPreferences sharedPreferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE); // String token = sharedPreferences.getString("InstanceID", "");
the OnError method is the one that returns that message.
@Override public void onMpesaError(Pair<Integer, String> result) { Toast.makeText(context,"Auth error: "+result.message,Toast.LENGTH_LONG).show(); dialog.dismiss(); }
What would be causing this Since i am on the sandbox. And in the code there is no option of inputting the access key generated from daraja dashboard
{ "access_token": "", "expires_in": "3599" }