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.setName("5% Discount");


mOrderConnector.addDiscount(orderId, discount);

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


mOrderConnector.deleteDiscounts(orderId, discounts);

Thanks, Steve

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

Steve gravatar image

1 answer

Sort by  

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

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