REST API returns item quantity as integer instead of string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I get an exception in the JAVA API.
Unable to parse Json Can not set java.lang.String field com.paypal.sdk.v1.payments.Item.quantity to java.lang.Integer
The root cause of this though is that the REST returns the item quantity as an integer, while it is supposed to be a string. Here is part of the JSON response I got when setting a breakpoint where this exception occurs:
{"id":"PAY-REDACTED", "intent":"sale", "state":"created", "payer":{"payment_method":"paypal"}, "transactions":[{ "amount":{"total":"551.70","currency":"EUR"}, "item_list":{ "items":[ {"name":"Product Name 1","sku":"A47834","price":"2.70","currency":"EUR","quantity":1}, {"name":"Product Name 2","sku":"B41665","price":"549.00","currency":"EUR","quantity":1} ]}, "related_resources":[]}], "create_time":"2018-05-18T13:08:51Z", "links":[ {"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-REDACTED","rel":"self","method":"GET"}, {"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-REDACTED","rel":"approval_url","method":"REDIRECT"}, {"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-REDACTED/execute","rel":"execute","method":"POST"} ]}
See the "quantity" at the end of each item line? That should be a string and in fact it has to be a string when passed to the REST API when creating the payment. But it is returned as an integer in the response. Leaving out the items is not an option for me as I am trying to integrate Paypal Plus, which requires item lines.
Any suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
BTW, if anyone ever finds this in search for help. I actually fixed this and filed a pull request against the paypal api on Github one month ago and this pull request remains just as ignored as this post here.
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- SetExpressCheckout 10003 error with ITEMCATEGORY=Digital in NVP/SOAP APIs
- Add Others data in SDKs
- Shipping options are not appearing in my cart through link or button. in PayPal Payments Standard
- I need to create a Pay Now / Buy Now button that retrieves a price from a simple shopping cart. in PayPal Payments Standard
- User is asked for shipping address when creating a credit card order in REST APIs