question

mkonnekt avatar image
mkonnekt asked mkonnekt commented

Do Clover discount APIs convert decimals to whole numbers?

The line item wise discount API converts all our discounts amounts with decimals to whole numbers. It is impractical for merchants. Hence wrong discount amounts gets sent to Clover and therefore applied to line items. This is the API we are using - https://docs.clover.com/build/web-app.... Please help. There is no option for us but to send convenience, delivery fees as line items & these can have a discount in the case of our merchants.

We had earlier tried using serviceCharge to send delivery and convenience fee but again serviceCharge didn't accept percentages with decimals and only accepted the whole number part of these charges. That is not practical from a merchant's point of view.

7 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.

q-factor avatar image q-factor commented ·

If you mean percentage discounts, yes I think Clover only accepts whole number percentages. One work around would be to convert them into actual dollar discounts, which accepts decimals, and then send it, if that is possible in your case.

0 Likes 0 ·
mkonnekt avatar image mkonnekt commented ·

Even for number discounts, the only option in the APIs is to send "long" data type and this "long" doesn't accept decimal numbers. Please see the APIs we are using below. If there are other APIs with different number formats, please direct us to those. 1. https://www.clover.com/apidocs#!/orders/CreateDiscount 2. https://www.clover.com/apidocs#!/orders/CreateDiscount0 3. https://www.clover.com/apidocs#!/orders/ApplyServiceCharge

0 Likes 0 ·
q-factor avatar image q-factor commented ·

I believe that you need to multiply you dollar amount with a 100 and then send it over for the long data type to include the cents.

0 Likes 0 ·
mkonnekt avatar image mkonnekt commented ·

I get this error: {"message": "Invalid value '1.5' for long"} when I send "amount" :"1.5" for line item discount API https://www.clover.com/apidocs#!/orders/CreateDiscount0

0 Likes 0 ·
mkonnekt avatar image mkonnekt commented ·

Ok but then does Clover divide the dollar amount by 100 before applying the discount to line items? I want to ensure 100 times the discount doesn't get applied to line items

0 Likes 0 ·
Show more comments

1 Answer

anthonypinto avatar image
anthonypinto answered

Amount discounts have an 'amount' field, which is based on the 'cent' value of the merchant currency, so '150' is equal to $1.50 for a US merchant. You can read more about amounts in the Overview of that page here: https://docs.clover.com/build/web-app...

Percentage discounts have a 'percentage' field, which is a whole percentage, so '20' is equal to 20%

10 |2000

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