mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
27 lines
724 B
Go
27 lines
724 B
Go
package fixtures
|
|
|
|
import (
|
|
"github.com/zap-proto/zip"
|
|
|
|
"github.com/hanzoai/commerce/models/referralprogram"
|
|
"github.com/hanzoai/commerce/models/referrer"
|
|
"github.com/hanzoai/commerce/models/types/currency"
|
|
)
|
|
|
|
var Referrer = New("referrer", func(c *zip.Ctx) *referrer.Referrer {
|
|
// Get namespaced db
|
|
db := getNamespaceDb(c)
|
|
|
|
u := User(c)
|
|
|
|
ref := referrer.New(db)
|
|
ref.UserId = u.Id()
|
|
ref.GetOrCreate("UserId=", ref.UserId)
|
|
ref.Program.Triggers = []int{0}
|
|
ref.Program.Actions = []referralprogram.Action{referralprogram.Action{Type: referralprogram.StoreCredit}}
|
|
ref.Program.Actions[0].CreditAction = referralprogram.CreditAction{Currency: currency.USD, Amount: currency.Cents(1000)}
|
|
ref.MustPut()
|
|
|
|
return ref
|
|
})
|