Instamojo / instamojo-java

Java wrapper for Instamojo API
MIT License
15 stars 20 forks source link

JSON Error in getPaymentOrderDetails Response #8

Open aditya2592 opened 7 years ago

aditya2592 commented 7 years ago

Hi,

I am getting an error while trying to collect the response from a getPaymentOrderDetails call. It seems that the API is not able to convert the response to JSON. Log is shown below. Any help would be greatly appreciated.

INFO  [2017-04-18 18:33:33,736] com.instamojo.wrapper.util.HttpUtils: Sending GET request to the url https://test.instamojo.com/v2/gateway/orders/id:MOJO7418005J69013940/
ERROR [2017-04-18 18:33:35,661] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: 9b908f70e6e0ef68
! java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
! at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:388) ~[gson-2.6.2.jar:na]
! at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:209) ~[gson-2.6.2.jar:na]
! ... 64 common frames omitted
! Causing: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
! at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) ~[gson-2.6.2.jar:na]
! at com.google.gson.Gson.fromJson(Gson.java:879) ~[gson-2.6.2.jar:na]
! at com.google.gson.Gson.fromJson(Gson.java:844) ~[gson-2.6.2.jar:na]
! at com.google.gson.Gson.fromJson(Gson.java:793) ~[gson-2.6.2.jar:na]
! at com.google.gson.Gson.fromJson(Gson.java:765) ~[gson-2.6.2.jar:na]
! at com.instamojo.wrapper.util.JsonUtils.convertJsonStringToObject(JsonUtils.java:27) ~[instamojo-java-1.0.1.jar:na]
! at com.instamojo.wrapper.api.InstamojoImpl.getPaymentOrderDetails(InstamojoImpl.java:257) ~[instamojo-java-1.0.1.jar:na]
! at com.quinetechnologies.cartServer.views.PaymentRedirectView.<init>(PaymentRedirectView.java:25) ~[main/:na]
jaseemabid commented 7 years ago

cc: @vedhavyas

vedhavyas commented 7 years ago

@aditya2592 would be very helpful if you could paste the response here

aditya2592 commented 7 years ago

Hi, this is the response obtained using Postman for the same payment ID :

  "payment": {
    "payment_id": "MOJO7418005J69013940",
    "quantity": 1,
    "status": "Credit",
    "link_slug": null,
    "link_title": null,
    "buyer_name": "Aditya Agarwal",
    "buyer_phone": "9972455233",
    "buyer_email": "darkhell99@gmail.com",
    "currency": "INR",
    "unit_price": "10.00",
    "amount": "10.00",
    "fees": "0.19",
    "shipping_address": null,
    "shipping_city": null,
    "shipping_state": null,
    "shipping_zip": null,
    "shipping_country": null,
    "discount_code": null,
    "discount_amount_off": null,
    "variants": [],
    "custom_fields": {},
    "affiliate_id": null,
    "affiliate_commission": "0",
    "created_at": "2017-04-18T14:26:52.442476Z",
    "payment_request": "https://test.instamojo.com/api/1.1/payment-requests/7067a337286245799fcdef087ce930c6/"
  },
  "success": true
}
aditya2592 commented 7 years ago

What are we supposed to provide as argument to below call? The README says payment order ID but the java class looks more like that of a "Get request details" instead of "Get payment details". So should be provide payment request ID?

PaymentOrderDetailsResponse paymentOrderDetailsResponse = api.getPaymentOrderDetails("[PAYMENT_ORDER_ID]");
vedhavyas commented 7 years ago

Should be PaymentRequestID @aditya2592