1

Hi, I'm having a problem removing a discount that I previously applied to an order. When I call OrderConnector.deleteDiscounts() I always get a ClientException. For testing purposes I'm currently trying to apply a discount and remove it straight away. Can anyone see a problem with this code:

Discount discount = new Discount();

discount.setPercentage(5L);

discount.setName("5% Discount");

discount.setId("123");

mOrderConnector.addDiscount(orderId, discount);

List<string> discounts = new ArrayList<>();

discounts.add("123");

mOrderConnector.deleteDiscounts(orderId, discounts);

Thanks, Steve

asked 2015-10-27 06:34:52 -0500

Steve gravatar image

1 answer

Sort by  
0

At first glance I see that you are setting the discount id yourself this id will not correspond to the ID in our database. I believe your call on mOrderConnector.addDiscount(orderId, discount) will return an Order. You should be able to do order.getDiscounts() to get a list of Discounts. In your case we expect one discount in the list, get the ID for that discount and add that to your list.

answered 2015-10-27 13:28:01 -0500

Voski gravatar image
Comments

Thanks Voski.....that solved my problem

Steve gravatar image
Steve 2015-10-28 11:48:43 -0500

@Steve glad it worked if you want check this as the correct answer so it will be visible to others. Cheers

Voski gravatar image
Voski 2015-10-28 17:34:42 -0500