Skip to content

Billing Address exception validation messages are lost in another exception #6795

@hostep

Description

@hostep

Preconditions

  1. Magento CE 2.1.1
  2. PHP 7.0.10

Steps to reproduce

  1. Login as an existing customer in the shop
  2. Add something to your cart and go to the checkout
  3. Somehow manage to have invalid data in your billing address
  4. Pick a payment method and click the "Place Order" button

Expected result

  1. A useful message telling you why your billing address isn't valid

Actual result

  1. An error message which isn't clear at all: An error occurred on the server. Please try to place the order again.

Discussion

In the response of the ajax call to {store-code}/rest/nl/V1/carts/mine/payment-information I see this:

{
    "message": "An error occurred on the server. Please try to place the order again.",
    "trace": "
        #0 /Volumes/Projects/magento2/some-project/vendor/magento/framework/Interception/Interceptor.php(146): Magento\\Checkout\\Model\\PaymentInformationManagement->savePaymentInformationAndPlaceOrder(35, Object(Magento\\Quote\\Model\\Quote\\Payment), Object(Magento\\Quote\\Model\\Quote\\Address))\n
        #1 /Volumes/Projects/magento2/some-project/var/generation/Magento/Checkout/Model/PaymentInformationManagement/Interceptor.php(26): Magento\\Checkout\\Model\\PaymentInformationManagement\\Interceptor->___callPlugins('savePaymentInfo...', Array, Array)\n
        #2 [internal function]: Magento\\Checkout\\Model\\PaymentInformationManagement\\Interceptor->savePaymentInformationAndPlaceOrder(35, Object(Magento\\Quote\\Model\\Quote\\Payment), Object(Magento\\Quote\\Model\\Quote\\Address))\n
        #3 /Volumes/Projects/magento2/some-project/vendor/magento/module-webapi/Controller/Rest.php(307): call_user_func_array(Array, Array)\n
        #4 /Volumes/Projects/magento2/some-project/vendor/magento/module-webapi/Controller/Rest.php(216): Magento\\Webapi\\Controller\\Rest->processApiRequest()\n
        #5 /Volumes/Projects/magento2/some-project/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(37): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n
        #6 /Volumes/Projects/magento2/some-project/vendor/magento/framework/App/Http.php(135): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n
        #7 /Volumes/Projects/magento2/some-project/vendor/magento/framework/App/Bootstrap.php(258): Magento\\Framework\\App\\Http->launch()\n
        #8 /Volumes/Projects/magento2/some-project/pub/index.php(37): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http))\n
        #9 {main}"
}

The actual useful info about why your billing address is invalid gets inserted over here:

throw new \Magento\Framework\Exception\LocalizedException(
__(
'Please check the billing address information. %1',
implode(' ', $quote->getBillingAddress()->validate())
)
);

But then this LocalizedException gets encapsulated by a CouldNotSaveException exception in:

throw new CouldNotSaveException(
__('An error occurred on the server. Please try to place the order again.'),
$e
);

And then I stopped digging any further.

It would be great if instead of the generic An error occurred on the server. Please try to place the order again. message, a more detailed message could get displayed to the user why his/her billing address isn't valid.

Metadata

Metadata

Labels

Issue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentbug report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions