Files
zeekay 1943f1c093 Hanzo Commerce
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
2026-09-23 21:52:16 -07:00

54 lines
1.2 KiB
Go

package subscription
import (
"math/rand"
"time"
"github.com/hanzoai/commerce/datastore"
"github.com/hanzoai/commerce/models/deprecated/plan"
"github.com/hanzoai/commerce/models/types/accounts"
"github.com/hanzoai/commerce/util/fake"
. "github.com/hanzoai/commerce/types"
)
func Fake(db *datastore.Datastore) *Subscription {
sub := New(db)
sub.PlanId = fake.Id()
sub.UserId = fake.Id()
sub.FeePercent = fake.Percent
sub.PeriodStart = time.Now()
sub.PeriodEnd = time.Now().AddDate(0, 0, 30)
sub.Canceled = false
sub.Quantity = rand.Intn(10)
sub.Status = Active
sub.Plan = *plan.Fake(db)
sub.Buyer = Buyer{
Email: fake.EmailAddress(),
FirstName: fake.FirstName(),
LastName: fake.LastName(),
BillingAddress: Address{
Line1: fake.Street(),
City: fake.City(),
State: fake.State(),
PostalCode: fake.Zip(),
Country: "US",
},
ShippingAddress: Address{
Line1: fake.Street(),
City: fake.City(),
State: fake.State(),
PostalCode: fake.Zip(),
Country: "US",
},
}
sub.Account.Type = accounts.StripeType
sub.Account.Number = "4242424242424242"
sub.Account.CVC = "424"
sub.Account.Month = 12
sub.Account.Year = 2024
return sub
}