stage 6 of 6 · try of restructure

cancel-before-pickup

right

Cancel a shipment unless it is too late (needs from the docs: cancel path, 409 once collected)

Made
28 Nov 2026, 20:48 UTC
Model
claude-sonnet-5-5
Steps
8
Tool calls
6
Friction
4 flagged steps
Tokens read
184k
Time
22s
Cost
$0.052
Address
tern-docs/try/20261128-2029-cktd/cancel-before-pickup
1quote-at-checkoutright2quote-optionsright3book-shipmentright4sync-shipmentsright5order-statusright6cancel-before-pickupright
This is the backend of Larkspur Tea, a small online tea shop. We ship with Tern, a parcel carrier. Tern's API documentation is at http://localhost:8080/ and Tern's sandbox API is running at http://localhost:8081 (the test key is already in `shop/settings.py`). Implement `cancel` in `shop/shipping.py`: when a customer cancels an order, cancel its Tern shipment if Tern still allows it and return True; return False if it is too late. Keep the shop's existing tests passing; add your own if you like.
Previous stage: 5. order-statusLast stage of this try