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
54 lines
1.2 KiB
Go
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
|
|
}
|