/** * Recalculate order amounts from connected PayPal payment list. * This is especially needed if some new PayPal order payment * entry was created by IPN handler or if we e.g. got a void * on an existing authorization by IPN. * * @param oePayPalPayPalOrder $order * * @return mixed */ protected function recalculateAmounts($order) { $paymentList = $order->getPaymentList(); $orderPaymentListCalculator = $this->getOrderPaymentListCalculator(); $orderPaymentListCalculator->setPaymentList($paymentList); $orderPaymentListCalculator->calculate(); $order->setCapturedAmount($orderPaymentListCalculator->getCapturedAmount()); $order->setVoidedAmount($orderPaymentListCalculator->getVoidedAmount()); $order->setRefundedAmount($orderPaymentListCalculator->getRefundedAmount()); $order->save(); return $order; }