question

ryanram avatar image
ryanram asked David Marginian Deactivated edited

Create Payment Record always says unauthorized with lineItemPayments

We have successfully called this api for payments for the entirety of the order, but when we create an order payment record for each line items we getting unauthorized error.


here's the sample line item object array.

JSONObject lineItemPayment = new JSONObject();
lineItemPayment.put("id", lineItem.getId());
lineItemPayment.put("percentage", 100);
lineItemPayments.put(lineItemPayment);


lineItemPayments is a JSONArray, thats added to the request body with the key "lineItemPayments" as per:
https://docs.clover.com/reference/orders-1#ordercreatepaymentfororder-2

anybody can point me in the correct or at least the minimum required properties to pass for each line item object?

Cheers

OrdersPayments
2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image David Marginian ♦♦ commented ·

"we getting unauthorized"? Can you please provide the response you are getting as well as what environment you are making the request in and a merchant or payment/order id.

0 Likes 0 ·
ryanram avatar image ryanram David Marginian ♦♦ commented ·

thanks David,


I'm currently on sandbox, and the response is unauthrorized error on the endpoint:
[POST] https://sandbox.dev.clover.com/v3/merchants/mId/orders/orderId/payments


I have encountered this before and its likely I may have incomplete request body. therefore I would like to know probably there's something wrong with that request I sent? do note that I already filled in all the required params.


here's a sample request body in json:
https://gist.githubusercontent.com/droweed/0effdc101a9971ee9e6719c172c48fe6/raw/89a0770af2adf24ac74d6d4c368fd2c2ef42aad7/clover-request

0 Likes 0 ·

1 Answer

David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated edited

I see your requests in the log and I see a 200 response from the server. So, I don't understand what you are talking about regarding an "Unauthorized" response. I am guessing that the request is successful but the lineItemPayments aren't getting updated. Is that correct?

I don't believe you can update the lineItemPayments with that endpoint, it is for the payment as a whole. I understand that the REST API docs are misleading/inaccurate (similar issue on another endpoint here - https://community.clover.com/questions/24231/sandbox-502-bad-gateway-error-when-adding-modifier.html). Try using this endpoint to update the lineItemPayments - https://docs.clover.com/reference/payments-1#payupdatepayment-2.

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ryanram avatar image ryanram commented ·

thanks David, thanks for that insight, yes I got it working but the line item payments are not yet updated, will check that endpoint you provided. and will get back to you what I've got.


cheers

0 Likes 0 ·

Welcome to the
Clover Developer Community