lipisha / lipisha-java-sdk

Lipisha Java SDK
Apache License 2.0
2 stars 10 forks source link

com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) #3

Closed Edijae closed 7 years ago

Edijae commented 7 years ago

I'm getting com.google.gson.stream.MalformedJsonException: when trying to call lipisha method authorizeCardTransaction

lipishaClient = new LipishaClient(API_KEY,API_SIGNATURE,
        "1.3.0","Callback",AUTHORIZE_URL);

    Call<CardTransactionResponse> call = lipishaClient.authorizeCardTransaction(
        FLOAT_ACCOUNT_NUMBER, CARD_NUMBER, CARD_ADDRESS_1,
        "0712345678", "022018", "John Doe",
        "NAIROBI", "KENYA", "1000",
        "003", (float) 1000, "KES");
    Response<CardTransactionResponse> response = call.execute();

Below is the full stacktrace

com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
    at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1573)
    at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1423)
    at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:587)
    at com.google.gson.stream.JsonReader.peek(JsonReader.java:429)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:181)
    at com.google.gson.TypeAdapter.fromJson(TypeAdapter.java:256)
    at retrofit2.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:33)
    at retrofit2.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:23)
    at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:117)
    at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211)
    at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)

How can i solve it?

Edijae commented 7 years ago

I was using production URL instead of Sandbox URL which made the above error to be thrown