public Function<Order, Order> getFunction() {
return order -> {
Assert.isTrue(!Arrays
.asList(OrderStatus.PAYMENT_SUCCEEDED, OrderStatus.PAYMENT_PENDING, OrderStatus.PAYMENT_FAILED)
.contains(order.getStatus()), "Payment has already been processed");
<BUG>Assert.isTrue(order.getStatus() == OrderStatus.PAYMENT_CONNECTED, "Payment must be connected to an order");
OrderService orderService = order.getModule(OrderModule.class).getDefaultService();</BUG>
Payment payment = order.getPayment();
order.setStatus(OrderStatus.PAYMENT_PENDING);
order = orderService.update(order);

public Function<Order, Order> getFunction() {
return order -> {
Assert.isTrue(!Arrays
.asList(OrderStatus.PAYMENT_SUCCEEDED, OrderStatus.PAYMENT_PENDING, OrderStatus.PAYMENT_FAILED)
.contains(order.getStatus()), "Payment has already been processed");
Assert.isTrue(order.getStatus() == OrderStatus.PAYMENT_CONNECTED,
"Order must be in a payment connected state");
OrderService orderService = order.getModule(OrderModule.class).getDefaultService();
Payment payment = order.getPayment();
order.setStatus(OrderStatus.PAYMENT_PENDING);
order = orderService.update(order);
