question

Eduardo Quiroz avatar image
Eduardo Quiroz asked Eduardo Quiroz commented

orderConnector.addDiscount fails with 400 when I create a discount with setAmount

I am unable to apply discounts with setAmount, the call to orderConnector addDiscount throws an exception of

com.clover.sdk.v1.ClientException: status code: 400 .....

However I can successfully apply a discount with setPercentage.


Any help is greatly appreciated.

OrdersClover Android SDKDiscounts
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 Eduardo Quiroz commented

The discount amount needs to be a negative value.

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.

Thank you, this worked!

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

Can you include the code you are using please?

10 |2000

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

Eduardo Quiroz avatar image
Eduardo Quiroz answered David Marginian Deactivated converted comment to answer
        ....
        long value = 12;
        Discount discount = new Discount();
        discount.setName(getName());

        if(type == DiscountGroupType.DOLLAR) {
            discount.setAmount(value);
        } else if(type == DiscountGroupType.PERCENTAGE) {
            discount.setPercentage(value);
        }

        orderConnector.addDiscount(orderId, discount);
        orderConnector.updateOrder(currentOrder);

With setPercentage it works no problem, with setAmount it fails with that error.

I've also tried value = 1200 (as in 12 dollars and 0 cents) with setAmount but that still fails.

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