# Check discount code validity Validates a discount code for a specific customer before checkout. When to use this: - During checkout when customer enters a loyalty discount code - Before applying discount to verify it belongs to the customer - To check discount status and expiry - To retrieve discount details (type, value, restrictions) Request body: - customerId: Shopify customer ID (required) - discountCode: The discount code to validate (required, case-insensitive) What this endpoint checks: - Discount code exists in the system - Code belongs to the specified customer - Code status is "UNUSED" or "ACTIVE" - Code has not expired - Code is valid for current context Response includes: - Discount type (PERCENTAGE, FIXED_AMOUNT, FREE_SHIPPING, FREE_PRODUCT) - Discount value (percentage or fixed amount) - Expiry date - Usage restrictions (minimum purchase, specific products, etc.) - Points that were redeemed for this code - Shopify discount code ID for reference Discount statuses: - UNUSED: Code has not been used yet (valid) - ACTIVE: Code is being used in an active subscription (valid for renewals) - USED: Code has already been redeemed (invalid) - EXPIRED: Code has passed expiry date (invalid) Integration pattern: 1. Customer enters loyalty code at checkout 2. Call this endpoint to validate the code 3. If 200 response, apply discount in checkout 4. After order is placed, call update-discount to mark as USED 5. Handle 400/404 by showing error message to customer Common scenarios: - Valid code: 200 with full discount details - Wrong customer: 404 (code exists but for different customer) - Already used: 400 with "Discount already used" message - Expired: 400 with expiry information - Invalid code: 404 (code doesn't exist) Endpoint: PUT /api/external/check-discount ## Request fields (application/json): - `customerId` (integer, required) Shopify customer ID (numeric). Identifies which customer is attempting to use the discount code. Used to verify the discount code belongs to this customer. Example: 67890 Example: 67890 - `discountCode` (string, required) The discount code to validate. Case-insensitive. This is the code the customer enters at checkout. System will check if: - Code exists in loyalty system - Code belongs to this customer - Code status is UNUSED or ACTIVE - Code has not expired Examples: "LOYALTY15OFF", "VIP20", "WELCOME10" Example: "LOYALTY15OFF" ## Response 200 fields (application/json): - `id` (integer) - `shop` (string, required) - `customerId` (integer, required) - `description` (string) - `pointTransactionId` (integer) - `pointRedeemRuleId` (integer) - `discountCode` (string, required) - `usedAt` (string) - `orderId` (integer) - `orderName` (string) - `status` (string, required) Enum: "USED", "UNUSED", "REFUNDED", "EXPIRED", "SUBSCRIPTION_ACTIVE" - `createAt` (string, required) - `expireDate` (string) - `variantId` (integer) - `discountCodeId` (string) - `productData` (string) - `usageCount` (integer) - `amount` (number) - `rewardType` (string) Enum: "STORE_CREDIT", "DISCOUNT_CODE", "POINTS" - `lastExpiryReminderSentDate` (string)