-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Parent Issue
Part of #96 — Add promotional discount code feature to checkout flow
Service
src/checkout (Go)
Scope
Discount Code Store
- Create an in-memory discount code store with the following codes:
Code Type Rule SAVE10Percentage 10% off entire order subtotal FREESHIPShipping Set shipping cost to $0 ASTRO20Conditional 20% off when subtotal > $100 - Only one discount code allowed per order
Validation Logic
- Validate the discount code from
PlaceOrderRequest - For
ASTRO20, check that the subtotal (after currency conversion) exceeds $100 equivalent - Return appropriate error if code is invalid or conditions are not met
Price Adjustment in PlaceOrder()
- Apply discount after currency conversion but before calling the Payment service
- For percentage discounts: calculate discount on item subtotal (excluding shipping)
- For
FREESHIP: zero out the shipping cost from the Shipping service quote - Pass the adjusted total to the Payment service
Charge()call - Include discount details in the
OrderResultresponse
OpenTelemetry Instrumentation
- Add a span for discount code validation (
discount.validate) - Record span attributes:
discount.code,discount.type,discount.amount,discount.valid - Add a metric counter for discount code usage (by code and success/failure)
Acceptance Criteria
- In-memory store holds all three discount codes
-
SAVE10correctly applies 10% off the item subtotal -
FREESHIPsets shipping to $0 -
ASTRO20applies 20% off only when subtotal > $100; returns error otherwise - Invalid codes return a descriptive gRPC error
- Payment service receives the correctly adjusted total
-
OrderResultincludes discount information - OpenTelemetry spans and metrics are recorded for discount operations
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels