All payments goes to @ashwch

Posted in General by Deepak Kundapura Thu Dec 14 2017 19:01:50 GMT+0000 (UTC)·1·Viewed 287 times

Hi. I wanted to integrate Instamojo in my android application. I could follow the instruction in developers guide and could integrate it using devsupport-ai. I also used the sample app for help. I am able to make payments, however all payment goes to @ashwch. I believe that's because the token is returned by "sample-sdk-server.instamojo.com" which is configured for that particular account. Am I right? If yes, how do i fetch order token for my account from access_token.php? Sample code(copied from sample app): private void fetchTokenAndTransactionID() { if (!dialog.isShowing()) { dialog.show(); } OkHttpClient client = new OkHttpClient(); HttpUrl url = getHttpURLBuilder() .addPathSegment("mail") .build(); System.out.println(url.toString()); RequestBody body = new FormBody.Builder() .add("env", currentEnv.toLowerCase()) .build(); System.out.println(body.toString()); okhttp3.Request request = new okhttp3.Request.Builder() .url(url) .post(body) .build(); System.out.println(request.toString()); client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { runOnUiThread(new Runnable() { @Override public void run() { if (dialog != null && dialog.isShowing()) { dialog.dismiss(); } showToast("Failed to fetch the Order Tokens"); } }); } @Override public void onResponse(Call call, Response response) throws IOException { String responseString; String errorMessage = null; String transactionID = null; responseString = response.body().string(); response.body().close(); try { JSONObject responseObject = new JSONObject(responseString); if (responseObject.has("error")) { errorMessage = responseObject.getString("error"); } else { accessToken = responseObject.getString("access_token"); transactionID = responseObject.getString("transaction_id"); } } catch (JSONException e) { errorMessage = "Failed to fetch Order tokens"; } final String finalErrorMessage = errorMessage; final String finalTransactionID = transactionID; runOnUiThread(new Runnable() { @Override public void run() { if (dialog != null && dialog.isShowing()) { dialog.dismiss(); } if (finalErrorMessage != null) { showToast(finalErrorMessage); return; } createOrder(accessToken, finalTransactionID); } }); } }); HTTP Builder: private HttpUrl.Builder getHttpURLBuilder() { return new HttpUrl.Builder() .scheme("https") .host("sample-sdk-server.instamojo.com"); // }
Deepak Kundapura
Dec 15, 2017

I could figure it out myself!! The solution was right on the integration page @ https://docs.instamojo.com/v1.1/page/devsupport-ai-android-integration.

Anyway, Thanks if someone wanted to help!! :)

  
Markdown is allowed