Dhl Cargo Erpnext
DHL eCommerce (MNG Kargo) REST API integration for ERPNext — automates shipment creation and barcode generation from Delivery Notes.
- Author: logedosoft
- Repository: https://github.com/logedosoft/DHL-Cargo-ERPNext
- GitHub stars: 2
- Forks: 1
- License: MIT
- Category: Other
- Maintenance: Actively Maintained
- Frappe versions: develop
Install Dhl Cargo Erpnext
bench get-app https://github.com/logedosoft/DHL-Cargo-ERPNext
Tags
- cargo-integration
- dhl
- dhl-api
- dhl-ecommerce
- erpnext-application
- erpnext-shipping
- shipment-automation
Add the Frappe Gems badge to your README
Maintain Dhl Cargo Erpnext? Paste this into your README:
[](https://frappegems.com/gems/apps/logedosoft/DHL-Cargo-ERPNext)
About Dhl Cargo Erpnext
DHL eCommerce Integration for ERPNext
Automate DHL eCommerce (MNG Kargo) shipment creation, barcode label generation, and ZPL printing directly from ERPNext Delivery Notes — with a single click.
What This App Does
This Frappe/ERPNext app connects your ERPNext instance to the DHL eCommerce REST API (powered by MNG Kargo infrastructure in Turkey) to:
- 🔐 Authenticate via JWT Bearer token (auto-refreshed every 8 hours)
- 📦 Create shipment orders from ERPNext Delivery Notes with one click
- 🖨️ Print or download shipping labels directly from the Delivery Note form
- 📋 Log every API call for traceability and debugging
- ⚙️ Manage credentials securely in an ERPNext Settings DocType
Why Use This Integration?
| Problem | This App Solves It |
|---|---|
| Manual shipment entry in MNG portal | Auto-creates orders from ERPNext Delivery Note on submit |
| Copy-pasting tracking numbers | referenceId and barcode stored on the Delivery Note |
| Lost shipping labels | ZPL string saved to the document; reprint anytime |
| Expired JWT tokens | Automatic token refresh with expiry caching |
Supported API Endpoints
| Step | Endpoint | Description |
|---|---|---|
| 1 | POST /mngapi/api/token |
Obtain Bearer JWT (valid 8 hours) |
| 2 | POST /mngapi/api/standardcmdapi/createOrder |
Create shipment order |
| 3 | POST /mngapi/api/barcodecmdapi/createbarcode |
Generate ZPL label |
| Optional | POST /mngapi/api/pluscmdapi/createRecipient |
Pre-register recipient for branch detection |
Base URLs:
- Test: https://testapi.mngkargo.com.tr
- Production: https://api.mngkargo.com.tr
Requirements
- Frappe Framework v14 or v15
- ERPNext v14 or v15
- Python 3.10+
- A valid DHL eCommerce / MNG Kargo customer account
- API credentials
Configuration
1. Open DHL Cargo Settings
Go to ERPNext → DHL Cargo Settings and fill in:
| Field | Description |
|---|---|
| Customer Number | Your MNG Kargo customer number |
| Password | Your MNG Kargo API password |
| IBM Client ID | x-ibm-client-id from ApiZone portal |
| IBM Client Secret | x-ibm-client-secret from ApiZone portal |
| Use Test Environment | Enable for sandbox testing |
⚠️ Never hardcode credentials. All sensitive values are stored in the Settings DocType and never committed to version control.
2. Get Your API Credentials
For Testing (Sandbox):
1. Register at https://sandbox.mngkargo.com.tr
2. Create an application under Applications → New Application
3. Copy the Client ID and Secret Key shown once on screen
4. Subscribe to: Identity API, Standart Command API, Barcode Command API
For Production:
1. Register at https://apizone.mngkargo.com.tr
2. Email entegrasyon@mngkargo.com.tr with your app name, static IP, and customer number
3. Await approval, then subscribe to the same three APIs
Usage
Creating a Shipment from a Delivery Note
- Open a Delivery Note in ERPNext
- Click Create DHL Shipment button (added by this app)
- The app will:
- Fetch or refresh the JWT token
- Call
createOrderwith recipient and package data - Call
createBarcodewith the returnedreferenceId - Store the ZPL label string on the Delivery Note
- Click Print Label to send to your Zebra printer
Desi Calculation
Volumetric weight is calculated automatically: desi = (widthcm × lengthcm × height_cm) / 3000
text
Key Field Rules
referenceId— UPPERCASE, unique per order, max 20 charactersbarcode— must equalreferenceIdcityCode/districtCode— set to0; when0,cityNameanddistrictNametext fields are mandatorycustomerId/refCustomerIdin recipient — always empty string""printReferenceBarcodeOnError— set to1to prevent operation halt on barcode errors
Architecture
dhlecommerceintegration/ ├── dhlecommerceintegration/ │ ├── doctype/ │ │ ├── dhlcargosettings/ # Credentials + JWT cache │ │ └── dhlcargolog/ # API request/response audit log │ ├── api/ │ │ ├── token.py # JWT fetch + refresh logic │ │ ├── createorder.py # createOrder endpoint wrapper │ │ └── createbarcode.py # createBarcode endpoint wrapper │ └── hooks.py # Delivery Note on_submit trigger ├── README.md └── setup.py
text
ERPNext DocTypes Added
DHL Cargo Settings
Stores all credentials and JWT cache. One record per site.
Troubleshooting
| Error | Likely Cause | Fix |
|---|---|---|
401 Unauthorized |
Expired or missing JWT | Token auto-refreshes; check customerNumber/password |
Branch not found |
Recipient district unknown | Use createRecipient first; contact MNG for manual branch mapping |
referenceId duplicate |
Same ID used twice | Ensure unique ID per Delivery Note (use DN name + timestamp) |
| ZPL label blank | barcodes[].value empty |
Check printReferenceBarcodeOnError = 1; review Error Log |
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
Keywords
erpnext-shipping · dhl-ecommerce · mng-kargo · frappe-app · cargo-integration · zpl-label · shipment-automation · turkey-logistics · erpnext-plugin · barcode-generation
Related Projects
- frappe/erpnext-shipping — Official ERPNext Shipping app (FedEx, Sendcloud, LetMeShip)
- Frappe Framework Docs
- ERPNext Docs
Related Other apps for Frappe & ERPNext
- Erpnext — Free and Open Source Enterprise Resource Planning (ERP)
- Helpdesk — Modern, Streamlined, Free and Open Source Customer Service Software
- Print Designer — Visual print designer for Frappe / ERPNext
- Ctr — CTR模型代码和学习笔记总结
- Whitelabel — Whitelabel ERPNext
- Fossunited — fossunited.org
- Helm — Helm Chart Repository for Frappe/ERPNext
- Frappe Attachments S3 — A frappe app to upload file attachments in doctypes to s3.