package domain import ( "errors" "math" ) var ErrInvalidCoursePricing = errors.New("course price must be nonnegative with at most two decimal places and currency must be three uppercase letters") func ValidateCoursePricing(price float64, currency string) error { if math.IsNaN(price) || math.IsInf(price, 0) || price < 0 || price > 9999999999.99 || math.Abs(price-math.Round(price*100)/100) > 1e-9 { return ErrInvalidCoursePricing } if len(currency) != 3 { return ErrInvalidCoursePricing } for _, ch := range currency { if ch < 'A' || ch > 'Z' { return ErrInvalidCoursePricing } } return nil } // CourseContentAccess is resolved from storage so every consumption path uses the same policy. type CourseContentAccess struct { CourseID int64 Tier ContentAccessTier Published bool } type CourseCheckoutRequest struct { ReferralCode string `json:"referral_code,omitempty"` Phone string `json:"phone,omitempty"` } type CourseCheckoutResponse struct { PaymentID int64 `json:"payment_id"` SessionID string `json:"session_id"` PaymentURL string `json:"payment_url"` CourseID int64 `json:"course_id"` Amount float64 `json:"amount"` Currency string `json:"currency"` }