Documentation
¶
Overview ¶
Package credit provides reusable starter credit logic. Shared between api/billing handlers and middleware/iammiddleware.
Index ¶
Constants ¶
const ( StarterCreditCents = 500 // $5.00 USD StarterCreditDays = 30 // expires in 30 days StarterCreditTag = "starter-credit" )
Starter credit constants.
Variables ¶
This section is empty.
Functions ¶
func GrantIfEligible ¶
GrantIfEligible checks if the user already has a starter credit and grants one if not. It is idempotent: duplicate calls for the same user are safe. The trigger parameter records what initiated the grant (e.g. "payment-method-added", "org-created").
The check-and-create runs inside a transaction to prevent race conditions where concurrent goroutines could both pass the existence check and grant duplicate credits.
This function is intended to be called from a goroutine; it only logs on failure and never panics.
Types ¶
This section is empty.