protected function calculateTotalByState(PaymentSubjectInterface $subject, $state)
    {
        PaymentStates::isValidState($state, true);

        $currency = $subject->getCurrency()->getCode();

        $total = 0;

        foreach ($subject->getPayments() as $payment) {
            if ($payment->getState() === $state) {
                $total += $this->convertPaymentAmount($payment, $currency);
            }
        }

        return $total;
    }
protected function calculateTotalByState(PaymentSubjectInterface $subject, $state)
    {
        PaymentStates::isValidState($state, true);

        $currency = $subject->getCurrency()->getCode();

        $total = 0;

        foreach ($subject->getPayments() as $payment) {
            if ($payment->getState() === $state) {
                $total += $this->convertPaymentAmount($payment, $currency);
            }
        }

        return $total;
    }
protected function calculateTotalByState ( PaymentSubjectInterface $ subject , $ state ) { PaymentStates :: isValidState ( $ state , true ) ; $ currency = $ subject -> getCurrency ( ) -> getCode ( ) ; $ total = 0 ; foreach ( $ subject -> getPayments ( ) as $ payment ) { if ( $ payment -> getState ( ) === $ state ) { $ total += $ this -> convertPaymentAmount ( $ payment , $ currency ) ; } } return $ total ; }
Calculates the payments total by state.

@param PaymentSubjectInterface $subject
@param string                  $state

@return float
Calculates the payments total by state .