Problem

When creating shipments with transport insurance (Transportversicherung) or cash on delivery (Nachnahme), this error occurs:


Hard validation error occured. Bitte geben Sie einen gültigen Betrag an


In English:


Hard validation error occured. Please enter a valid amount


Cause

If the order amount is 1000 EUR or higher, Magento will add a comma as thousands-separator to the amount. However, the DHL Webservice (API) cannot process this correctly.


Solution

This problem applies to the DHL Versenden module for Magento 1 up to version 1.3.0. It is resolved in later versions.


As a quick fix, the following can be done:


Go into this file:

  • lib/Dhl/Versenden/Bcs/Api/Webservice/Adapter/Soap/ServiceType.php


Look for this line:

$insuranceAmount = $requestData->getInsurance();


and replace it with this:

$insuranceAmount = str_replace(',', '', $requestData->getInsurance());


Then, in the same file, look for this line:

$codAmount = $requestData->getCod();


and enter this instead:

$codAmount = str_replace(',', '', $requestData->getCod());


These changes will fix the problem for transport insurance and cash on delivery shipments.


Save the file, flush all Magento caches, and execute the transmission to DHL again.