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

30 lines
803 B
Go

package types
import "errors"
var BuyerEmailOrPhoneRequired = errors.New("Buyer's Email or Phone is required.")
type Buyer struct {
Email string `json:"email,omitempty"`
UserId string `json:"userId,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Company string `json:"company,omitempty"`
Phone string `json:"phone,omitempty"`
// Address Address `json:"address,omitempty"`
ShippingAddress Address `json:"shippingAddress,omitempty"`
BillingAddress Address `json:"billingAddress,omitempty"`
}
func (b Buyer) Name() string {
return b.FirstName + " " + b.LastName
}
func (b Buyer) Validate() (bool, []error) {
if b.Email != "" && b.Phone != "" {
return false, []error{BuyerEmailOrPhoneRequired}
}
return true, nil
}