[Checkout] Implement behavior for discount codes
Feature
Apply a discount code at checkout
Scenario 1: Valid code
Given a cart worth €80 and an active code SPRING20 for 20% off
When the customer applies SPRING20
Then the order total shows €64 and the discount appears as its own line item
Scenario 2: Expired code
Given a code SUMMER10 that expired yesterday
When the customer applies SUMMER10
Then the total is unchanged and the message "This code has expired" is shown
Scenario 3: Second code
Given an order that already has SPRING20 applied
When the customer applies another code
Then the second code is rejected with "Only one code per order" and SPRING20 stays applied
Technical Notes
- Edge cases: codes are case-insensitive; trim surrounding spaces
- Recalculate the discount when cart items change after the code was applied
- API paths affected: POST /cart/discount, DELETE /cart/discount