Checkout Payment Improvements in the Magento 2.1.9 release

Checkout Payment Improvements in the Magento 2.1.9 release
Starting from Magento 2.1.9 release the Magento\Checkout module has been improved. Both guest and logged in scenarios are now passing custom errors messages.

In my previous blog How to Show Payment Errors on the Checkout Payment Page in Magento 2 post I communicated the importance of custom payment messages. Customers expect to see clear messages provided by the Magento 2 in case of exceptional situations. Especially when it comes to payments.

The Magento\Checkout module is responsible for passing error messages when order save operation was not successfull. Magento 2.1.0-2.1.8 releases were providing general message in case payment transaction has been failed. Even though, clear error message is returned back from Payment Service Provider to Magento.

Starting from Magento 2.1.9 release the Magento\Checkout module has been improved. Both guest and logged in scenarios (as we know we have 2 different implementations for logged in customers and guests) are now passing custom errors messages.

The Magento\Checkout\Model\PaymentInformationManagement::savePaymentInformationAndPlaceOrder() and Magento\Checkout\Model\GuestPaymentInformationManagement::savePaymentInformationAndPlaceOrder() methods throw CouldNotSaveException exceptions with the original exception message.

    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 (\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;
    }

This change is a big achievement towards decreasing number of customer queries due to a general "An error occurred on the server. Please try to place the order again." message. Also it reduces couple of extra classes in a custom payment module.

For the websites based on Magento 2.1.0-2.1.8 versions I recommend to update Magento to the latest Magento 2.1 or better Magento 2.2 version to get all the security and conversion improvements.

Additional Information

More about Magento 2.1.9 changes you can read in the Release Notes.

Also, don't forget to check Magento 2.2 Release Information.

magento 2 checkout

Related Articles

Comments

Next Article Previous Article

LinkedIn Twitter Facebook