mollie / magento2

Mollie Payments for Magento 2
https://www.mollie.com
Other
101 stars 53 forks source link

Surcharge is applied to the grand total but when the order is paid, Magento says the customer has to pay the surcharge (amount left) #518

Closed erwinschaap closed 2 years ago

erwinschaap commented 2 years ago

Describe the bug This morning a customer paid via PayPal. We ask for a fee of 3% (configured). The customer for the entire amount but the order states that the customer has to pay the 3% fee.

Total Paid: for example: 100 euro Grand total : 103 euro In the Mollie logs: 103 euro Total due: 3 euro

Used versions Magento 2.4.3 Open Source Mollie version: v2.6.0

To Reproduce Steps to reproduce the behavior:

  1. Choose Paypal as payment method
  2. Add 3% surcharge
  3. There is a paid order and the total paid is not the same as in the mollie logs / grand total

Expected behavior The customer does not have to pay extra surchage because it's already paid. There is no total due.

Actual behavior There is a total due of the total surcharge costs

Screenshots If applicable, add screenshots to help explain your problem. image image

Additional context No addition context

Frank-Magmodules commented 2 years ago

HI @erwinschaap , I just tried to reproduce this but I can't break it on the latest Mollie release. 

As we did some changes regarding the payment fees and the order processing in the latest release, can you please update the plugin to the latest version and try to reproduce this again?

erwinschaap commented 2 years ago

@Frank-Magmodules Could you update the official plugin on the Magento Marketplace? It is outdated

Frank-Magmodules commented 2 years ago

HI @erwinschaap , the latest version is there now! https://marketplace.magento.com/mollie-magento2.html

erwinschaap commented 2 years ago

@Frank-Magmodules We updated the module today but the fee is sometimes good but mostly not. (See screenshot) The following information in the request is not correct. You can see the mollie fee is zero but the grand total differs with subtotal. In this case the mollie payment fee should be 4,50 euro

image

dennisvanderweide commented 2 years ago

I fixed it by saving the Quote after setting the Mollie payment fee in Mollie\Payment\Model\PaymentFee\Quote\Address\Total\PaymentFee::collect and Mollie\Payment\Model\PaymentFee\Quote\Address\Total\PaymentFeeTax::collect

/**
     * @param Quote $quote
     * @param ShippingAssignmentInterface $shippingAssignment
     * @param Total $total
     * @return $this|AbstractTotal
     */
    public function collect(Quote $quote, ShippingAssignmentInterface $shippingAssignment, Total $total)
    {
        ...

        $attributes->setMolliePaymentFee($amount);
        $attributes->setBaseMolliePaymentFee($result->getRoundedAmount());

        $this->quoteResourceModel->save($quote);
        return $this;
    }
jorgb90 commented 2 years ago

@dennisvanderweide Can you help us to add this correctly without getting a "main.CRITICAL: Exception: Notice: Undefined property: Mollie\Payment\Model\PaymentFee\Quote\Address\Total\PaymentFee::$quoteResourceModel" ?

dennisvanderweide commented 2 years ago

@jorgb90 You need to add the Quote ResourceModel class as a dependency in the constructor

/**
 * @var \Magento\Quote\Model\ResourceModel\Quote
 */
private $quoteResourceModel;

public function __construct(
    PaymentFeeConfig $paymentFeeConfig,
    PriceCurrencyInterface $priceCurrency,
    Calculate $calculate,
    \Magento\Quote\Model\ResourceModel\Quote $quoteResourceModel
) {
    $this->paymentFeeConfig = $paymentFeeConfig;
    $this->priceCurrency = $priceCurrency;
    $this->calculate = $calculate;
    $this->quoteResourceModel = $quoteResourceModel;
}
Frank-Magmodules commented 2 years ago

Hi All,

Saving the quote in the totals should not be required. If every total saves the quote the whole checkout will get slow easily. Most likely, something prevents the quote from being saved after the totals are processed.

Would it be possible to provide us with access to your environment so we can investigate this more?

Frank-Magmodules commented 2 years ago

HI @erwinschaap ,

Due to the lack of information and the fact that we can't reproduce this issue, we will close this issue for now. Please feel free to reopen the issue or contact us directly through our contact form so we can investigate this issue further with you.