Skip to main content

Coin Package Purchases

Records every purchase of a coin package by a player. Stores snapshots of package details at the time of purchase for complete audit trail and financial reporting.

Table Comment

This table captures the full state of a package at purchase time, ensuring accurate historical records even if the package is later modified or deactivated.

Relationships

Columns

ColumnTypeNullableDefaultDescription
iduuidNOgen_random_uuid()Primary key
player_iduuidNOFK to players. The purchasing player.
package_iduuidNOFK to coin_packages. The purchased package.
payment_methodvarchar(50)YESPayment method used (e.g., credit_card, paypal, crypto)
payment_referencevarchar(255)YESExternal payment provider reference/transaction ID
statusvarchar(20)NO'completed'Purchase status. Values: completed, pending, failed, refunded
package_namevarchar(100)YESSnapshot: Package name at time of purchase
price_paidnumeric(18)YESSnapshot: Actual price paid (for financial reporting)
price_currencyvarchar(10)YESSnapshot: Currency used at time of purchase
gc_grantednumeric(18)YESSnapshot: GC amount granted (may include VIP store multiplier bonus)
sc_grantednumeric(18)YESSnapshot: SC amount granted
package_snapshotjsonbYESSnapshot: Full package details at time of purchase (complete audit trail)
package_sourcevarchar(20)YESSnapshot: Source of the package (standard, smartico, etc.) for analytics
created_attimestamptzNOCURRENT_TIMESTAMPPurchase timestamp

Key Indexes

IndexColumnsNotes
coin_package_purchases_pkeyidPrimary key
idx_coin_package_purchases_player_idplayer_idPlayer purchase history
idx_coin_package_purchases_package_idpackage_idPackage popularity tracking
idx_coin_package_purchases_created_atcreated_atTime-based reporting
idx_coin_package_purchases_created_at_statuscreated_at, statusRevenue reporting
idx_coin_package_purchases_statusstatusFilter by status
idx_coin_package_purchases_price_currencyprice_currencyCurrency-based reporting

Business Rules

  • Snapshot fields (package_name, price_paid, gc_granted, sc_granted, package_snapshot) preserve the exact state at purchase time
  • The gc_granted and sc_granted may differ from the package's base amounts if a VIP store_multiplier from vip_levels was applied
  • A completed purchase triggers corresponding transactions to credit the player's balances
  • The package_source field enables analytics on which package sources (standard vs. Smartico vs. affiliate) drive the most revenue