Appearance
DPD Integration
The DPD integration enables shipment creation, PDF label generation, and parcel tracking via the DPD/BRT REST API.
Components
| Component | File | Role |
|---|---|---|
DpdApi | src/CoreBundle/Api/DpdApi.php | REST API client for DPD |
DpdService | src/CoreBundle/Services/DpdService.php | Shipment business logic |
DpdController | src/AppBundle/Controller/DpdController.php | Dashboard and web routes |
| Configuration | app/config/parameters.yml.dist | Connection parameters |
Configuration
Required parameters in parameters.yml:
yaml
dpd:
api_url: "https://api.dpd.fr"
user_id: "..."
password: "..."
customer_code: "..."
departure_depot: "..."
operating_mode: "..."Parameter injection pattern
Symfony does not allow accessing nested parameters (%dpd.api_url%). The service receives the full %dpd% array and extracts keys in PHP. This pattern is consistent with other carrier integrations (Geodis, etc.).
Data Flow
View diagram source
sequenceDiagram
participant UI as DPD Dashboard
participant CTRL as DpdController
participant SVC as DpdService
participant API as DpdApi
participant DPD as DPD REST API
participant SP as SaleProduct
UI->>CTRL: Create shipment
CTRL->>SVC: createShipment(saleProducts)
SVC->>API: createShipment(data)
API->>DPD: POST /shipments
DPD-->>API: JSON response + PDF
API-->>SVC: Label PDF + data
SVC->>SVC: Save PDF to /web/pdf_dpd/
SVC->>SP: Update carrier/tracking/shipment
SVC->>SVC: ShipmentTrackingSynchronizer
Dashboard Features
- Shipment list with DataTables (server-side pagination)
- Advanced filters (store, dates, tracking number, order number)
- Batch shipment creation
- PDF label download
- Retry for failed shipments
- Tracking synchronization
API Error Codes
| Code | Meaning |
|---|---|
| -1 | General error |
| -3 | Invalid parameters |
| -5 | Authentication failed |
| -10 | Unknown depot |
| -11 | Unknown customer code |
| -21 | Shipment not found |
| -22 | Shipment already confirmed |
| -30 | Service unavailable |
Integration Phases
Phase 1 -- API and Backend Services
- REST API client (
DpdApi) - Business logic service (
DpdService) - PDF label storage
SaleProductupdates
Phase 2 -- User Interface
- DPD dashboard with DataTables
- AJAX routes for creation and tracking
- Integration into the "Processing Not Printed" flow
- Filters and carrier-based search
Phase 3 (optional)
- Automated batch printing
- Automatic tracking synchronization command
- Email notifications
- Webhooks
- Statistics dashboard
Troubleshooting
ParameterNotFoundException for %dpd.api_url%
The service must receive %dpd% (the full array), not individual keys. Verify that services.yml passes %dpd% and that the DpdApi constructor accepts array $config.
Dashboard inaccessible
- Clear cache:
php bin/console cache:clear - Check the service:
php bin/console debug:container mz.dpd.api - Test the API connection manually