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
30 lines
803 B
Go
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
|
|
}
|