question

Chris H avatar image
Chris H asked David Marginian Deactivated commented

voiding a line item with v3 of api doesn't reflect the total in the ecommerce api

1. we create an order with the following line item initially against the ecommerce api using the below object to create a "shell order" for line items to be

added later.


items[

{

amount = 100,

currency = "usd",

description = "<line item text>",

quantity = 1

}

]


post object


items = items,

currency = "usd",

customer = custid,

email = email


"/v1/orders", Method.POST


This is successful and creates a shell ecommerce order with a total of 1 dollar.

2. Line items are added by a user on the Clover endpoint. We do not add any further line items.


3. Before we use the ecommerce order/pay endpoint we want to void the the same line item using the following endpoint

/v3/merchants/" + _merchantId + "/orders/" + order_id + "/line_items/"+ item_id, Method.DELETE


The problem is that the total of the ecommerce order is not subtracted 1 dollar so the user is always charged 1 dollar than the order should have a total for.


What's the correct way to accomplish removing the line item and subtracting the dollar before paying out the order?

REST API
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 Deactivated answered Chris H commented

I would recommend you look at using the atomic order endpoints - https://docs.clover.com/docs/working-with-orders. If you want to continue with the current approach my question would be are you setting an order total?

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.

Chris H avatar image Chris H commented ·

Hi david, Ill take a look at the atomic order ep.

We are creating the order and the merchant is adding the line items. Previously when we've voided the initial line item (only used to create the initial order shell), before pay its subtracted from total and the user was left with the balance. It just seems something has changed.

0 Likes 0 ·
David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated edited

Why do you create a bogus line item? You create the order via API then the merchant adds items to it via a Clover device? Then it is paid for card not present? Seems like a very strange flow. The order/pay endpoint only calculates the total if a total has not already been set. In your case there will be a total (because the merchant is adding items via a Clover device). So, after you remove the line item you will need to properly update the total (to reflect the removed item) if you want to continue to do this (which, once again seems very odd to me).

10 |2000

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

Chris H avatar image
Chris H answered David Marginian Deactivated commented

hi david, I think what I'm getting at is that previously when we voided a line item using the v3 api it would sync with the ecommerce data and remove the charge, thus providing the correct total. This behavior has changed.

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.

David Marginian avatar image David Marginian ♦♦ commented ·

The orders/pay endpoint has always only set a total if a total wasn't previously set. This hasn't changed. From your description it sounds like a total would be set, and thus you would need to properly update the total after the line item has been removed. I recommend you look into this, because I really don't think anything changed.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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

Welcome to the
Clover Developer Community