if (order != null) {
String orderId = order.getString("orderId");
// check for a financial state change
FinancialOrderState oldFin = info.getPreviousFinancialOrderState();
FinancialOrderState newFin = info.getNewFinancialOrderState();
if (!oldFin.equals(newFin)) {
// financial state change
if (newFin.equals(FinancialOrderState.CANCELLED) || newFin.equals(FinancialOrderState.CANCELLED_BY_GOOGLE)) {
// cancel the order
if (!"ORDER_CANCELLED".equals(order.getString("statusId"))) {
OrderChangeHelper.cancelOrder(dispatcher, system, orderId);
}
} else if (newFin.equals(FinancialOrderState.CHARGEABLE) && oldFin.equals(FinancialOrderState.REVIEWING)) {
// approve the order
if (!"ORDER_APPROVED".equals(order.getString("statusId"))) {
OrderChangeHelper.approveOrder(dispatcher, system, orderId, hasHoldOrderNotes(orderId));
}
} else if (newFin.equals(FinancialOrderState.PAYMENT_DECLINED)) {
// reject the order
if (!"ORDER_REJECTED".equals(order.getString("statusId"))) {
OrderChangeHelper.rejectOrder(dispatcher, system, orderId);
}
}