Skip to content

fix(dhl): use getGatewayURL() for sandbox mode support in XML quotes#40502

Open
lbajsarowicz wants to merge 1 commit intomagento:2.4-developfrom
lbajsarowicz:fix/40249-dhl-sandbox-mode
Open

fix(dhl): use getGatewayURL() for sandbox mode support in XML quotes#40502
lbajsarowicz wants to merge 1 commit intomagento:2.4-developfrom
lbajsarowicz:fix/40249-dhl-sandbox-mode

Conversation

@lbajsarowicz
Copy link
Contributor

Description

Replace hardcoded gateway_xml_url config with getGatewayURL() method call in _getQuotes().

The getGatewayURL() method correctly handles sandbox mode by checking sandbox_mode config and returning the appropriate URL:

  • Production: gateway_xml_url
  • Sandbox: sandbox_xml_url

Root cause: Line 1092 in _getQuotes() used $this->getConfigData('gateway_xml_url') directly, bypassing the sandbox mode logic in getGatewayURL().

Related Pull Requests

None

Fixed Issues (if relevant)

  1. Fixes Sandbox mode does not work for DHL (XML) #40249

Manual testing scenarios

  1. Enable DHL shipping method in Admin > Stores > Configuration > Sales > Shipping Methods > DHL
  2. Enable Sandbox Mode and configure sandbox credentials
  3. Add a product to cart and proceed to checkout
  4. Enter shipping address and request shipping rates
  5. Before fix: DHL returns "Validation Failure: Site Id is wrong" (production URL used with sandbox credentials)
  6. After fix: DHL returns valid shipping rates from sandbox environment

Questions or comments

The getGatewayURL() method already exists and handles sandbox mode correctly for other DHL operations. This fix ensures _getQuotes() uses the same logic.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

⭐ Support my work

Do you like the fix? Remember to react with "👍🏻" to get it merged faster,
Then Sponsor me on Github so I can spend more time on fixing issues like this one.

Learn more at https://github.com/sponsors/lbajsarowicz

Replace hardcoded gateway_xml_url config with getGatewayURL() method
call in _getQuotes(). The getGatewayURL() method correctly handles
sandbox mode by returning sandbox_xml_url when sandbox_mode is enabled.

Without this fix, DHL always returns "Validation Failure: Site Id is
wrong" when sandbox mode is enabled because it uses production URL
with sandbox credentials.

Fixes magento#40249
@m2-assistant
Copy link

m2-assistant bot commented Feb 3, 2026

Hi @lbajsarowicz. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@lbajsarowicz
Copy link
Contributor Author

@magento run all tests

@lbajsarowicz
Copy link
Contributor Author

@magento run Functional Tests B2B, Functional Tests EE, Functional Tests CE

@engcom-Bravo engcom-Bravo added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Feb 10, 2026
@github-project-automation github-project-automation bot moved this to Pending Review in Pull Requests Dashboard Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

Sandbox mode does not work for DHL (XML)

2 participants