7

When user want to checkout sometimes i got below message.

enter image description here

After correction of Billing & Shipping Address Sometimes user able to place order some times not.

Due to this customer not able to order.

What will be the perfect solution for this?

7
  • Please add the error you see in your logs file in here
    – PassTeT
    Commented Dec 9, 2016 at 3:30
  • @Ankit Shah, I am facing this issue so if you found the solution for this kindly share here
    – Vigna S
    Commented May 9, 2017 at 9:59
  • @Vigna Since last few months not getting this error. If there is error due to your custom module. So need to check var/log & solves issue
    – Jackson
    Commented May 9, 2017 at 10:01
  • ok, I will check!!!
    – Vigna S
    Commented May 9, 2017 at 10:54
  • the following link is not a solution but a way to debug your cause > codeblog.experius.nl/magento-2-checkout-debuggen Commented Sep 15, 2017 at 11:33

12 Answers 12

8

You may echo the actual error message on this file: vendor/magento/module-payment/view/frontend/templates/transparent/iframe.phtml if you did not extend the file yet or if you did you may edit this on app/design/[vendor]/[theme]/ go to line 42 and replace this

   message: $t('An error occurred on the server. Please try to place the order again.')

with this

    message: $t('<?php echo $params['error_msg'];?>')

In my case, when the customer purchased using Credit card via Payapal Gateway I was able to trace the error message on this file vendor/magento/module-paypal/Model/Payflow/Service/Response/Validator/ResponseValidator.php

The payment was actualy declined with the response code ESPONSE_CODE_FRAUDSERVICE_FILTER but magento will display the default error message instead of showing Fraud Error message.

4
  • after vendor / theme/ what is the following folder? Magento_Payment / templates??
    – styzzz
    Commented May 19, 2018 at 2:06
  • @styzzz it will be like app/design/frontend/[Vendor]/[theme]/Magento_Payment/templates/transparent/iframe.phtml
    – Abbas
    Commented Jun 8, 2018 at 1:37
  • it's working fine Commented Nov 28, 2019 at 5:49
  • what would be the solution here
    – Jdprasad V
    Commented Jun 11, 2020 at 3:48
6

If the magento version is > 2.4 then check service elasticsearch is in running state.

4

Please go to vendor/magento/module-checkout/Model/PaymentInformationManagement.php Functions: savePaymentInformationAndPlaceOrder() Change line 85 and 90 with follow code:

throw new CouldNotSaveException( __($e->getMessage()), $e );

After that, please try to checkout and you can see the error message.

1
  • Thank you very much. You saved my day!
    – Thowzif
    Commented Dec 8, 2020 at 15:15
1

The solution that worked for me, was to change the generic "An Error Occured on the Server", to "Credit Card Declined. Please check credit card details and billing address". . .

To do this, you need to edit

/app/design/frontend/THEME/VENDOR/Magento_Payment/templates/transparent/iframe.phtml

edit line:

message: $t('An error occurred on the server. Please try to place the order again.')

You can find a copy of iframe.html in vendor/magento and move it to your theme to make this change.

1
  • no luck after change vendor to theme
    – matinict
    Commented Jul 25, 2022 at 9:05
1

It is possible to display the real error by editing the model files based on the error ajax call

Edit the function savePaymentInformationAndPlaceOrder in

vendor/magento/module-checkout/Model/PaymentInformationManagement.php

or for Guest orders in

vendor/magento/module-checkout/Model/GuestPaymentInformationManagement.php

Change the function from:

public function savePaymentInformationAndPlaceOrder(
    $cartId,
    $email,
    \Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
    \Magento\Quote\Api\Data\AddressInterface $billingAddress = null
) {
    $this->savePaymentInformation($cartId, $email, $paymentMethod, $billingAddress);
    try {
        $orderId = $this->cartManagement->placeOrder($cartId);
    } catch (\Exception $e) {
        throw new CouldNotSaveException(
            __('An error occurred on the server. Please try to place the order again.'),
            $e
        );
    }
    return $orderId;
}

to:

public function savePaymentInformationAndPlaceOrder(
    $cartId,
    $email,
    \Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
    \Magento\Quote\Api\Data\AddressInterface $billingAddress = null
) {
    $this->savePaymentInformation($cartId, $email, $paymentMethod, $billingAddress);
    try {
        $orderId = $this->cartManagement->placeOrder($cartId);
    } catch (\Exception $e) {
        throw new CouldNotSaveException(
            __($e->getMessage()),
            $e
        );
    }
    return $orderId;
}

Now you get the actual error and you should find the full exception in the exception.log file

Thanks :)

0

This means that an exception was thrown somewhere in your application, execution was terminated and the exception was handled. I believe the exception is being thrown in vendor/magento/module-checkout/Model/PaymentInformationManagement.php.

If you inspect the response of the rest call in your network tab you will see that there was a json object returned that should have a stack trace of where the error was generated. If you want the actual error to display, you can update this exception handling to output $e->getMessage() instead of the generic display message or inject the Psr/logger and log it out to your log directory.

The best way for you to prevent this is to track down what is throwing an exception and resolve the exception.

0

We have also seen this same error when a person's credit card fails. A very generic error.

In our case since we sell overseas... it is usually the card holder needs to call their bank and just let them know it is a legitimate payment transaction they are trying to submit.

0

In my case enabling single-store mode then disabling it solved the problem.

  1. Go to Stores -> Configuration -> General Set 'Enable Single-Store Mode' to Yes.
  2. Go to System -> Cache Management and click 'Flush Magento Cache'.
  3. Go to Stores -> Configuration -> General Set 'Enable Single-Store Mode' to No.
0

This is occurs due your third party extension or your own custom module syntax error present in module files.

If you want to see the actual error in your code, you can run the command on terminal.

  sudo php bin/magento setup:di:compile 

enter image description here

enter image description here

In my case syntax error mention by red circle in above snapshot (semicolon is not use in array).

I have replaced semicolon to comma.

Note : After remove syntax error again run command.

    sudo php bin/magento setup:di:compile 

Now clear cache.

Note : If above solution is not working, the disable your custom or third party extension

        sudo php bin/magento --clear-static-content module:disable Module_Name

enter image description here

2
0

I got same issue and it was a silly md5 hash code mistake. Please use shorter md5 code. I was using too long md5 string so it wasn't working after make it shorter it is working perfectly!

2
  • Where did you change? may i know the path? Thank You @Mukesh Ojha
    – zus
    Commented Aug 10, 2020 at 5:03
  • @zus I have set Merchant MD5 in authorized.net payment method. Please check if any payment method configured using MD5 then make it short Commented Aug 11, 2020 at 6:26
0

If you are upgrading to version 2.4.4 from older version, this error is likely due to deprecated functionality in external modules that are not detected while compiling. I had this issue. Check log files for deprecated functionality errors.

-1

In my case problem was in State/Province/Region field in address. After filling this field the order was placed correctly.

Solution:

  • set required on Region field

or

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.