Parameter provided is invalid when creating Order

Hi There,

I am trying to create an order on the Poynt client by binding to the IPoyntOrderService.

when I try to send the test order using :

orderService.createOrder(createTestOrder(),"ybeiuhf737hf7h7hekfuihih6g86ggy", orderListener);

In my IPoyntOrderServiceListener it states as my poyntError.getReason() that ‘Parameter provided is invalid’.

My order is taken from the discount sample app:

public Order createTestOrder(){
Order order = new Order();
order.setId(UUID.randomUUID());
List<OrderItem> items = new ArrayList<OrderItem>();
// create some dummy items to display in second screen
items = new ArrayList<OrderItem>();
OrderItem item1 = new OrderItem();
// these are the only required fields for second screen display
item1.setName("Item1");
item1.setUnitPrice(100l);
item1.setQuantity(1.0f);
items.add(item1);

OrderItem item2 = new OrderItem();
// these are the only required fields for second screen display
item2.setName("Item2");
item2.setUnitPrice(100l);
item2.setQuantity(1.0f);
items.add(item2);

OrderItem item3 = new OrderItem();
// these are the only required fields for second screen display
item3.setName("Item3");
item3.setUnitPrice(100l);
item3.setQuantity(2.0f);
items.add(item3);
order.setItems(items);
BigDecimal subTotal = new BigDecimal(0);
for (OrderItem item : items) {

BigDecimal price = new BigDecimal(item.getUnitPrice());
price.setScale(2, RoundingMode.HALF_UP);
price = price.multiply(new BigDecimal(item.getQuantity()));
subTotal = subTotal.add(price);
}

OrderAmounts amounts = new OrderAmounts();
amounts.setCurrency("USD");
amounts.setSubTotal(subTotal.longValue());
order.setAmounts(amounts);

order.setContext(new ClientContext());
return order;

}

Is there something I am missing…?

Thanks in advance.

Hi there,

The generated order in that sample was intended to be used to display items on the second screen and demo the discount service, but it is missing a few required fields if you want to use it with OrderService. Use this instead:

private Order generateOrder() {

    Order order = new Order();
    order.setId(UUID.randomUUID());
    List<OrderItem> items = new ArrayList<OrderItem>();
    // create some dummy items to display in second screen
    items = new ArrayList<OrderItem>();
    OrderItem item1 = new OrderItem();
    // these are the only required fields for second screen display
    item1.setName("Item1");
    item1.setUnitPrice(100l);
    item1.setQuantity(1.0f);
    item1.setUnitOfMeasure(UnitOfMeasure.EACH);
    item1.setStatus(OrderItemStatus.ORDERED);
    item1.setTax(0l);
    items.add(item1);

    OrderItem item2 = new OrderItem();
    // these are the only required fields for second screen display
    item2.setName("Item2");
    item2.setUnitPrice(100l);
    item2.setQuantity(1.0f);
    item2.setTax(0l);
    item2.setUnitOfMeasure(UnitOfMeasure.EACH);
    item2.setStatus(OrderItemStatus.ORDERED);
    items.add(item2);

    OrderItem item3 = new OrderItem();
    // these are the only required fields for second screen display
    item3.setName("Item3");
    item3.setUnitPrice(100l);
    item3.setQuantity(2.0f);
    item3.setStatus(OrderItemStatus.ORDERED);
    item3.setUnitOfMeasure(UnitOfMeasure.EACH);
    item3.setTax(0l);
    items.add(item3);
    order.setItems(items);

    BigDecimal subTotal = new BigDecimal(0);
    for (OrderItem item : items) {
        BigDecimal price = new BigDecimal(item.getUnitPrice());
        price.setScale(2, RoundingMode.HALF_UP);
        price = price.multiply(new BigDecimal(item.getQuantity()));
        subTotal = subTotal.add(price);
    }

    OrderAmounts amounts = new OrderAmounts();
    amounts.setCurrency("USD");
    amounts.setSubTotal(subTotal.longValue());
    order.setAmounts(amounts);

    OrderStatuses orderStatuses = new OrderStatuses();
    orderStatuses.setStatus(OrderStatus.OPENED);
    order.setStatuses(orderStatuses);
    return order;
}

Great Thanks, worked like a charm.
Is there a write up any where on minimum required parameters regarding using the SDK?

All available docs are currently on https://poynt.github.io/developer/.
Please feel free to continue asking questions on this discussion board and we will do our best to respond in a timely manner.

It would be great if the PoyntError in the service listeners could give feedback on what parameter is invalid and why it is invalid.

Thanks for the feedback. I’ll see if we can implement this soon.