Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confirmation Email Payment Info Block has total 0.00 #327

Open
rvelhote opened this issue Oct 9, 2018 · 0 comments
Open

Confirmation Email Payment Info Block has total 0.00 #327

rvelhote opened this issue Oct 9, 2018 · 0 comments

Comments

@rvelhote
Copy link
Contributor

rvelhote commented Oct 9, 2018

Hello Ebanx,

Using any payment method the order confirmation email, in the payment block, has the total displayed as 0.00. The total grand total of the order is correct.

screenshot from 2018-10-09 17-11-27

I believe that this happens because the getTotal() in Ebanx_Gateway_Payment uses the ebanx_local_amount field from the payment table before it is defined in the persistPayment() method.

    /**
     * @return float
     */
    public function getTotal()
    {
        $quote = $this->getInfoInstance()->getQuote();
        if (!$quote) {
            return $this->getInfoInstance()->getOrder()->getPayment()->getEbanxLocalAmount();
        }
        return $quote->getGrandTotal();
    }

Changing the return line when !$quote to return $this->getInfoInstance()->getOrder()->getGrandTotal() will solve this issue and display the correct order amount.

I've looked into this issue further and the local amount displays correctly in the case of Brazil (the local amount includes de IOF tax) so I've made a little change as a failsafe.

    /**
     * @return float
     */
    public function getTotal()
    {
        $quote = $this->getInfoInstance()->getQuote();

        if (!$quote) {
            $order = $this->getInfoInstance()->getOrder();
            $amount = $order->getPayment()->getEbanxLocalAmount();

            if ($amount == 0) {
                $amount = $order->getGrandTotal();
            }

            return $amount;
        }

        return $quote->getGrandTotal();
    }

Any caveats to this change? Can you please verify if you can replicate the issue?

Best regards,
Ricardo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant