onCustomerPurchase
Purpose
Triggered when a customer successfully purchases items from a shop. Use this hook to log purchases, integrate with MDT systems, track economy, or send Discord webhooks.
When It Triggers
Customer completes checkout
Payment is processed successfully
Items are added to customer's inventory
Parameters
data.source
number
Player server ID who made the purchase
data.shopId
string
Unique shop identifier
data.shopType
string
Type of shop (e.g., '247store', 'liquorstore')
data.shopName
string
Display name of the shop
data.isShopOwned
boolean
Whether the shop has a player owner
data.ownerIdentifier
string
Shop owner's identifier (if owned)
data.items
table
Array of purchased items
data.items[i].item
string
Item spawn name
data.items[i].label
string
Item display name
data.items[i].quantity
number
Quantity purchased
data.items[i].price
number
Price per unit (after discounts)
data.items[i].originalPrice
number
Original price per unit
data.items[i].category
string
Item category
data.items[i].metadata
table
Item metadata (if any)
data.totalAmount
number
Final total after all discounts
data.subtotal
number
Original total before discounts
data.paymentMethod
string
'cash', 'bank', 'society', or 'black_money'
data.societyName
string
Society name if using society payment
data.customerIdentifier
string
Customer's player identifier
data.customerName
string
Customer's character name
data.discounts
table
Breakdown of discounts applied
data.discounts.sales
number
Discount from active sales
data.discounts.coupon
number
Discount from coupon
data.discounts.loyalty
number
Discount from loyalty points
data.couponCode
string
Coupon code used (nil if none)
data.couponDiscount
number
Coupon discount percentage
data.saleId
string
Active sale ID (nil if none)
data.saleName
string
Active sale name
data.saleDiscount
number
Sale discount percentage
data.loyaltyPointsEarned
number
Points earned from this purchase
data.loyaltyPointsUsed
number
Points redeemed in this purchase
data.newLoyaltyBalance
number
Customer's new loyalty points balance
data.taxAmount
number
Tax amount applied
data.taxRate
number
Tax rate percentage
data.timestamp
number
Server timestamp (os.time())
Example
Last updated