Courier request: align pickup time with DPD's slot contract, fix crash on JSON API responses - #181
Merged
Conversation
…ontract DPD's live pickupOrderSave_ endpoint now rejects any pickup time that is not one of its fixed pickupTimeFrom/pickupTimeTo slots, and answers with a JSON object instead of the legacy plain-text response. Request side: - The 'Desired pick-up time' / 'Last pick-up time' datetime inputs are replaced with a pick-up date field and two slot dropdowns constrained to DPD's whitelists, so an invalid value can no longer be submitted. - Defaults are slot-aligned (next available slot today, or tomorrow 08:00) instead of the raw 'now + 30 min' value DPD always rejected. - CourierRequestValidator rejects non-whitelisted slots server-side. - The API request now carries pickupDate/pickupTimeFrom/pickupTimeTo alongside the legacy pickupTime/senderWorkUntil datetimes, which are kept for DPD endpoints still running the old contract and for the module's own entity. Response side: - CourierRequestResponseParser accepts both response shapes: the legacy '<p>DONE' / '402 Error:' strings and the new JSON object, whose body->message (or errlog) is surfaced to the merchant. Previously the JSON object reached strpos() and fatally crashed the admin page on PHP 8. The unit-test bootstrap now defines _PS_VERSION_, without which every test touching module classes silently exits on the file guards. Requires invertus/dpdbaltics-api with CourierRequestRequest slot setters (companion PR on that repo); composer.lock to be bumped once it lands on the developer branch.
GantasG
marked this pull request as ready for review
August 31, 2026 11:01
GytisZum
changed the base branch from
main
to
DGS-446-courier-request-pickup-time-slots
August 31, 2026 11:19
GytisZum
merged commit Aug 31, 2026
8ac62dd
into
DPDBaltics:DGS-446-courier-request-pickup-time-slots
1 of 2 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since DPD's live API contract change, no courier request can be created through the module (reported in #179; tracked internally as DGS-444 / DGS-446):
pickupOrderSave_endpoint now requires apickupTimeFrom/pickupTimeToslot pair from fixed whitelists; the module still sends a single free-formpickupTimedatetime, so every request is rejected:strpos()as if it were a string — on PHP 8 that's a fatalTypeErroratCourierRequestService.php:109, so the BO crashes with a 500 instead of showing DPD's message.Both reproduced on stock v3.3.1 (PS 8.2.7 / PHP 8.1) with the live endpoint's exact rejection replayed by a local stub.
What changed
Request side:
CourierRequestValidator::validatePickupTimeSlots()re-checks the whitelist server-side.pickupDate/pickupTimeFrom/pickupTimeToalongside the legacypickupTime/senderWorkUntildatetimes — kept for DPD endpoints still on the old contract (EE/LV) and for the module's ownDPDCourierRequestentity (no DB schema change; stored columns are composed from the slot fields).Response side:
CourierRequestResponseParseraccepts both response shapes: legacy<p>DONE/402 Error:strings and the new JSON object, whosebody->message(orerrlog) is shown to the merchant instead of crashing.Tests:
CourierRequestResponseParserTest(8 tests, incl. a stdClass fixture of the exact live rejection),PickupTimeSlotUtilityTest(4),CourierRequestValidatorTest(6) — green on PHP 8.1 / PHPUnit 8.5. The unit-test bootstrap now defines_PS_VERSION_, without which any test touching module classes silently exits on the file guards.Depends on
✅ Invertus/dpdbaltics-api#6 — adds the slot setters to
CourierRequestRequest(that package'sjsonSerialize()builds the payload, so the new params can't reach the wire from module code alone). Merged intodeveloper;composer.lockhere is bumped to that commit (e372e0b). A freshcomposer installof this branch now pulls the updated DTO.Verification (local PS 8.2.7 / PHP 8.1, live LT endpoint stubbed)
Captured outgoing request after the fix:
<p>DONE) → 'Successful creation', record saved, list view unchanged.Verdict: ship with follow-ups (below).
Needs human verification
integracijos.dpd.ltwith production credentials. The new param names match DPD's current API data model and the live error message, but the new ws-mapper contract isn't publicly documented and DPD's sandbox doesn't enforce it, so the exact wire naming is unverified against production. If DPD expects different naming, the merchant now sees DPD's answer as a readable error instead of a crash.DONEstrings as success and any JSON object as a surfaced error; if the live endpoint starts answering success as JSON, that shape needs adding.Confidence: 75%