I am using the code provided elsewhere as an example for telling that an order is fully paid.
public static long getAmountLeftToPay(Order order) {
long paymentTotal = 0;
if (order.isNotNullPayments()) {
for (Payment p : order.getPayments()) {
paymentTotal += p.getAmount();
}
}
return new OrderCalc(order).getTotal(null) - paymentTotal + amountRefundedWithoutTip(order);
}
etc
Anyway, I need to perform an action once when the order is fully paid. However, using this logic, if I refund a payment and add a new payment, this code triggers a second time. Any suggestions for how to handle this scenario?