@Override
 public boolean check(final OrderModel order) {
   if (!order.getCalculated().booleanValue()) {
     // Order must be calculated
     return false;
   }
   if (order.getEntries().isEmpty()) {
     // Order must have some lines
     return false;
   } else if (order.getPaymentInfo() == null) {
     // Order must have some payment info to use in the process
     return false;
   } else {
     // Order delivery options must be valid
     return checkDeliveryOptions(order);
   }
 }
  @Override
  public Transition executeAction(final OrderProcessModel process) {
    final OrderModel order = process.getOrder();

    if (order != null) {
      if (order.getPaymentInfo() instanceof InvoicePaymentInfoModel) {
        return Transition.OK;
      } else {
        for (final PaymentTransactionModel transaction : order.getPaymentTransactions()) {
          for (final PaymentTransactionEntryModel entry : transaction.getEntries()) {
            if (entry.getType().equals(PaymentTransactionType.AUTHORIZATION)
                && TransactionStatus.ACCEPTED.name().equals(entry.getTransactionStatus())) {
              order.setStatus(OrderStatus.PAYMENT_AUTHORIZED);
              modelService.save(order);
              return Transition.OK;
            }
          }
        }
      }
    }
    return Transition.NOK;
  }