0

for a while we've been getting an error when checking out with Braintree using a sandbox account. we simply get the error

'An error has occurred on the server, please try again"

The error occurs when hitting the checkout button

I've tried removing the table prefix and running the SQL fix but the error still persists. There is nothing incorrect in the Braintree configuration as the dummy payments are being sent and verified in the sandbox account & our host confirms there are no server errors causing it so it must be a Mage issue.

We're at a point now where we are totally flumuxed on the issue...

4

To know the exact reason why it is happening so, please open below file: vendor/magento/module-checkout/Model/PaymentInformationManagement.php

than comment out the try, catch and put code to place order directly as below:

Replace below function

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

Now, try to place order again. You will be able to see the detailed error in log file or may be in console.

0

For anyone experiencing this it seems certain tables were not created in the SQL!

  1. sequence_order_1
  2. sequence_invoice_1

Once adding these to the database is began to work fine

2
  • 1
    Just for further clarification on this issue, if you have used the UBmigration tool for example and have multiple store views on your M1 install, it doesn't create the sequence tables. You have to create these manually yourself (use EXPLAIN sequence_order_1; so you know correct data types), furthermore if you have migrated your sales data, you need to go into the above tables and update the sequence_value to +1 your latest entity_id value, so if you have 10200 orders, the sequence value will be 10201.
    – evensis
    Jun 16 '17 at 13:49
  • @AdamHall You are right.
    – Saphal Jha
    Sep 14 '17 at 6:44
0

Make sure you have your MD5 Hash in there. I didnt think I needed it (because I had set login and transaction APIs), but you need an MD5 Hash.

I was getting the same error - so I created the MD5 Hash in Authorize.net, put it into Configuration -> payment methods-> Authorize.net in Magento 2.0, and now it works.

Make sure all three are completed - API Login, Transaction API and MD5 Hash

0

Please replace with this code.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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