Skip to main content

Gift Coupons

Gift coupons are a special type of coupon that allows users to purchase content as gifts for others. This feature enables a complete gifting flow from purchase to redemption.

How Gift Coupons Work

Gift coupons operate differently from regular discount coupons:

  • Generated automatically during gift purchase transactions
  • Single-use only with a limit of 1 redemption
  • Linked to specific content via the User Plan system
  • Long expiration (set to 2999-12-31 for practical permanence)
  • Special database flag (gift = 1) to distinguish from regular coupons

Gift Purchase Flow

1. Gift Purchase Eligibility

Not all content can be purchased as gifts:

  • Content must be paid (not free)
  • Content must be on sale (available for purchase)
  • Subscribers-only content is not available to guest buyers
  • The tenant must have at least one gift-compatible payment gateway enabled. PayU and Yuno are not supported for gifts; other gateways (e.g. Mercado Pago, Stripe) are eligible

2. Gift Purchase Process

  1. Customer selects "Buy as Gift" option on eligible content
  2. Proceeds through normal checkout flow
  3. System creates special gift coupon automatically:
    • Unique code generated using standard coupon code generator
    • Amount set to 0 (gifts don't provide discounts)
    • Use limit set to 1
    • Gift flag enabled
    • Associated with buyer through the order and User Plan records

3. Gift Delivery

After successful purchase:

  • Gift purchaser receives confirmation with gift link
  • Gift link contains unique redemption code
  • Link format: /gift/{unique_code}

Gift Redemption Flow

  1. Recipient receives gift link with unique code
  2. Accesses gift redemption page: /gift/{code}
  3. System validates gift code and associated content

2. Authentication Requirement

Gift redemption requires user authentication:

  • Existing users: Directed to login page
  • New users: Directed to registration page
  • Intended URL preserved for post-authentication redirect

3. Redemption Process

  1. System validates gift code exists and is unused
  2. Validates redeemer is not the original gift purchaser
  3. Retrieves associated User Plan and publication details from the gift coupon
  4. After authentication, creates issue_user record for recipient with gifted=1 flag:
    • Record links publication to gift recipient (not purchaser)
    • This is an unusual case where order belongs to buyer but issue_user to recipient
    • This split ownership enables proper access tracking
  5. Marks gift as used (increments uses to 1)
  6. Redirects user directly to content reader

4. Post-Redemption Access

  • Gift purchaser: Can view gift status but cannot re-redeem
  • Gift recipient: Gets full access to gifted content
  • Others: Cannot access gift information (404 error)

Gift Validation Rules

Access Control

  • Gift can only be redeemed once
  • Only recipient or purchaser can access after redemption
  • Authentication required for all gift operations
  • Cannot be used in standard coupon redemption flow

Technical Validation

  • Gift code must exist in database
  • Associated User Plan must be valid
  • Content must still be available
  • User must be authenticated

Business Rules

  • Gifts are excluded from regular coupon listings in admin dashboard
  • Gift coupons don't count toward tenant coupon limits
  • No refunds available for gift purchases
  • No modifications allowed after gift creation

Administrative Considerations

Gift Management

  • Gifts appear in separate admin filters (not in main coupon list)

  • Gift transactions tracked in order system

  • Gift status visible in User Plan details

  • Activity logging captures gift creation and redemption:

    -- Find gift logs
    SELECT * FROM activity_log
    WHERE subject_type = 'App\\Domains\\Commerce\\Models\\Coupon'
    AND JSON_EXTRACT_JSON(JSON_EXTRACT_JSON(properties, 'attributes'), 'gift') = "true"
    ORDER BY created_at DESC;

Reporting

  • Gift purchases appear in sales reports
  • Gift redemptions tracked separately from regular purchases
  • Gift codes excluded from coupon usage statistics

Error Handling

Common Gift Errors

  • Gift already redeemed: Only original redeemer can access
  • Invalid gift code: Code doesn't exist or is malformed
  • Authentication required: User must log in to redeem
  • Content unavailable: Associated content no longer accessible

Error Messages

  • "Gift has expired" - when gift already redeemed by someone else
  • Standard 404 errors for invalid or inaccessible gifts
  • Authentication prompts for unauthenticated access attempts
X

Graph View