Overview
Gift cards provide a flexible way to offer prepaid credit that clients can use for any services or products. Each gift card has a unique code, tracks balance usage, and can have an optional expiration date.Key Features
- Unique codes: Each gift card has a unique identifier code
- Balance tracking: Monitors initial and current balance separately
- Flexible redemption: Can be partially used across multiple transactions
- Expiration dates: Optional expiration for time-limited offers
- Status management: Track active, used, and expired states
Gift Card Model
Unique identifier for the gift card (UUID)
Unique redemption code (e.g., “GC-2026-ABC123”)
Original balance when the gift card was created
Remaining balance available for use
When the gift card was issued
When the gift card expires (null for no expiration)
Gift card status:
active: Can be used for purchasesused: Fully redeemed (current_balance = 0)expired: Past expiration date
Optional reference to the client who purchased or owns the gift card
Timestamp when the gift card was created
Timestamp when the gift card was last updated
List Gift Cards
Retrieve all gift cards in the system.Query Parameters
Search gift cards by code
Response
Returns an array of gift card objects ordered by creation date (newest first).Create Gift Card
Issue a new gift card.Request Body
Unique gift card code. Must be unique across all gift cards.Format recommendations:
- Include prefix (e.g., “GC-”)
- Add year for tracking
- Use random alphanumeric string
- Example:
GC-2026-ABC123XYZ
Starting balance in currency units (e.g., €100.00)Validation:
- Must be positive
- Typically ranges from €25 to €500
Date the gift card was issued. Defaults to current timestamp if not provided.
Optional expiration date. Gift card cannot be used after this date.Common expiration periods:
- 1 year: Standard for most retail
- 2 years: Extended validity
- No expiration: Maximum flexibility
UUID of the client purchasing or receiving the gift card
Initial status: typically
activeResponse
Returns the created gift card object withcurrent_balance automatically set to initial_balance.
Automatic Field Initialization
current_balanceis automatically set to equalinitial_balanceissue_datedefaults to current timestamp if not providedgiftcard_idis automatically generated as UUID
Get Gift Card
Retrieve a specific gift card by ID or code.Path Parameters
The unique identifier of the gift card
Response
Returns the complete gift card object.Error Responses
HTTP status code
400: Gift card ID is required404: Gift card not found
Error message describing the issue
Update Gift Card
Update gift card properties, typically used for balance adjustments or status changes.Path Parameters
The unique identifier of the gift card to update
Request Body
All fields are optional. Only include fields you want to update.Update the gift card code (must remain unique)
Update the initial balance (use cautiously)
Update remaining balanceUse cases:
- Manual balance adjustments
- Refunds or credits
- Administrative corrections
Update issue date
Update or remove expiration date (set to null for no expiration)
Update status:
active: Enable for useused: Mark as fully redeemedexpired: Mark as expired
Associate or change client ownership
Response
Returns the updated gift card object.Delete Gift Card
Permanently delete a gift card from the system.Path Parameters
The unique identifier of the gift card to delete
Response
Returns
true if the deletion was successfulValidation Rules
Code Uniqueness
Thecode field must be unique across all gift cards. Recommended format:
- Prefix: “GC-” or “GIFT-”
- Year: “2026”
- Random string: 6-12 alphanumeric characters
- Example:
GC-2026-X7K9M2P5
Balance Rules
initial_balancemust be positivecurrent_balancecannot exceedinitial_balancecurrent_balancecannot be negative- When
current_balancereaches 0, status should be updated toused
Date Validation
issue_datecannot be in the futureexpiration_datemust be afterissue_date- Common validity periods: 1-2 years from issue date
- Some jurisdictions require minimum validity periods
Status Management
Active:current_balance > 0 AND not expired
- Can be applied to purchases
- Balance can be partially or fully redeemed
current_balance = 0
- Fully redeemed
- Cannot be used for new purchases
- Preserved for transaction history
expiration_date
- Cannot be used regardless of balance
- May have remaining balance
- Consider refund policies for expired cards with balance
Business Logic
Balance Tracking
Gift cards maintain two balance fields:Partial Redemption
Gift cards can be used across multiple transactions:-
First purchase (€34.50):
- Original balance: €100.00
- Purchase amount: €34.50
- Remaining: €65.50
-
Second purchase (€75.00):
- Available balance: €65.50
- Gift card applies: €65.50
- Additional payment needed: €9.50
- Remaining: €0.00
- Status:
used
Cart Integration
Gift cards are applied during checkout:-
Validate gift card:
- Exists and code matches
- Status is
active - Not expired (
expiration_date> now) - Has available balance (
current_balance> 0)
-
Calculate discount:
- If
current_balance≥ cart total: Apply full amount - If
current_balance< cart total: Apply available balance
- If
-
Update gift card:
- Deduct used amount from
current_balance - If balance reaches 0, set status to
used - Store gift card code in cart’s
applied_giftcardfield
- Deduct used amount from
-
Update cart:
- Add discount amount to cart’s
discountfield - Recalculate cart
total
- Add discount amount to cart’s
Expiration Management
Background job recommendations:- 30 days before expiration: First reminder
- 7 days before expiration: Final reminder
- Day of expiration: Expiration notice
Selling Gift Cards
Gift cards are sold as cart items:- Generate unique code
-
Create Giftcard record:
code: Generated unique codeinitial_balance: Purchase amountcurrent_balance: Purchase amountissue_date: Current timestampexpiration_date: issue_date + 1 yearstatus: “active”client_id: Purchaser’s ID
- Email gift card details to purchaser
- Optionally email to recipient if gift
Reporting and Analytics
Key Metrics
Outstanding liability:Transaction History
Consider implementing a separateGiftcardTransaction table to track usage:
- Detailed audit trail
- Dispute resolution capability
- Client transaction history
- Financial reconciliation