String baseUrl; baseUrl = PreferenceConstant.getCloverBaseUrl(); String gatewayUri = null; String url; url = baseUrl + gatewayUri + WebAPIUtils.ACCESS_TOKEN_STRING + PreferenceConstant.getCloverAuthToken(); final String fuelOrderID = fuelTransactionBean.getOrderNo() != null ? fuelTransactionBean.getOrderNo() : ""; JSONObject empIdJsonObject = new JSONObject(); empIdJsonObject.put(TENDER_ID, PreferenceConstant.getEmployeeIdSharedPreferences()); JSONObject orderIdJsonObject = new JSONObject(); if (order != null) { orderIdJsonObject.put(TENDER_ID, order.getId()); } JSONObject tenderJsonObject = new JSONObject(); tenderJsonObject.put(TENDER_ID, PreferenceConstant.getFuelPaymentTenderId()); JSONObject rootJsonObject = new JSONObject(); rootJsonObject.put(TENDER_NOTE, fuelOrderID + " " + txnMsg); rootJsonObject.put(TENDER_EMPLOYEE, empIdJsonObject); rootJsonObject.put(TENDER_TENDER, tenderJsonObject); rootJsonObject.put(TENDER_ORDER, orderIdJsonObject); if (order != null) { rootJsonObject.put(TENDER_AMOUNT, String.valueOf(order.getTotal())); } JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url, rootJsonObject, response -> { if (response != null) { try { updateFuelDetails(fuelTransactionBean); //added by sree mCloverOrder = null; createNewOrderByPass();//stop removing store item } catch (Exception e) { e.printStackTrace(); } } else { BPS_Logger.d("SREE", "makePaymentInWorkerThread onResponse : == null"); } }, error -> { BPS_Logger.showMessage("Payment API error, wait trying again.... "); recordLog("makePaymentInWorkerThread Error while hitting payment API error " + error.getLocalizedMessage()); BPS_Logger.d("SREE", "makePaymentInWorkerThread Error while hitting payment API error " + error.toString()); new Handler().postDelayed(() -> makePaymentInWorkerThread(merchant, order, orderNo, dispenserNo, txnMsg), 2500); }) //Earlier implementation // { // @Override // public Map getHeaders() { // Map params = new HashMap<>(); // params.put(WebAPIUtils.CONTENT_TYPE, WebAPIUtils.APPLICATION_JSON); // return params; // } // }; { @Override public Map getParams() { Map params = new HashMap<>(); params.put(WebAPIUtils.CONTENT_TYPE, WebAPIUtils.APPLICATION_JSON); return params; } }; //add request to queue jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy( 15000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); // 15 seconds timeout BPS_Application.getBPSApplicationInstance().getRequestQueue().add(jsonObjectRequest);