0

I have tried to get auth Access token using below code.and based on this code ,we will get Full transaction detail of Paypal. Below code is working fine in Lollipop and above, but when we run my app in lolipop below version then not getting any response from Paypal SDK.I did lot of R&D for this issue.Please give me solution of this. My Working Code in Lollipop and above:

public void getAcessToken(final String PayID) {

        base64 = "Basic " + Base64.encodeToString((URLs.PAYPAL_CLIENTID + ":" + URLs.PAYPAL_SECRET_KEY).getBytes(), Base64.NO_WRAP);
        Log.i("TAG", "Base64=" + base64);
        if (!CM.isInternetAvailable(this)) {
            CM.showPopupCommonValidation(this, getResources().getString(R.string.internet_unavailable_msg), false);
            return;
        }
        showDialog();
        String url = "https://api.sandbox.paypal.com/v1/oauth2/token";
        Log.i("WebCalls", url);
        StringRequest stringRequest = new StringRequest(Request.Method.POST,
                url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        KcsLog.i("WebCalls", response.toString());
                        String AccessToken = CM.getValueFromJson("access_token", response);
                        String token_type = CM.getValueFromJson("token_type", response);
                        GetTransactionID(token_type + " " + AccessToken, PayID);
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                dismissDialog();
                CM.showVolleyErrorMessage(error, ViewGiftCode.this, "", false);
            }
        }) {
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String, String> post = new HashMap<String, String>();
                post.put("grant_type", "client_credentials");
                return post;
            }

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> post = new HashMap<String, String>();
                post.put("Accept", "application/json");
                post.put("Accept-Language", "en_US");
                post.put("Content-Type", "application/x-www-form-urlencoded");
                post.put("Authorization", base64);
                return post;
            }
        };
        ((MainApplications) getApplicationContext()).volley.addToRequestQueue(stringRequest);
    }

Please give me solution for below lollipop.

4

0 回答 0