Documentation
¶
Index ¶
- Constants
- Variables
- func AutoMigrate(db *gorm.DB) error
- func Connect(config *conf.Configuration) (*gorm.DB, error)
- type Address
- type AddressRequest
- type Configuration
- type InvalidDataType
- type LineItem
- type LineItemMetadata
- type Order
- type OrderData
- type OrderNote
- type PriceItem
- type PriceMetaItem
- type PriceMetadata
- type SiteSettings
- type Tax
- type Transaction
- type User
Constants ¶
View Source
const ( NumberType = iota StringType BoolType )
NumberType | StringType | BoolType are the different types supported in custom data for orders
View Source
const ChargeTransactionType = "charge"
View Source
const FailedState = "failed"
View Source
const PaidState = "paid"
View Source
const PendingState = "pending"
View Source
const RefundTransactionType = "refund"
Variables ¶
View Source
var Namespace string
Namespace puts all tables names under a common namespace. This is useful if you want to use the same database for several services and don't want table names to collide.
Functions ¶
func AutoMigrate ¶ added in v0.2.0
Types ¶
type Address ¶
type AddressRequest ¶ added in v0.2.0
type AddressRequest struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Company string `json:"company"`
Address1 string `json:"address1"`
Address2 string `json:"address2"`
City string `json:"city"`
Country string `json:"country"`
State string `json:"state"`
Zip string `json:"zip"`
}
func (AddressRequest) Validate ¶ added in v0.2.0
func (a AddressRequest) Validate() error
type Configuration ¶
Configuration defines the info necessary to connect to a storage engine
type InvalidDataType ¶
type InvalidDataType struct {
Key string
}
InvalidDataType is an error returned when trying to set an invalid datatype for a user data key
func (*InvalidDataType) Error ¶
func (i *InvalidDataType) Error() string
type LineItem ¶
type LineItem struct {
ID int64 `json:"id"`
OrderID string `json:"-"`
Title string `json:"title"`
SKU string `json:"sku"`
Type string `json:"type"`
Description string `json:"description"`
VAT uint64 `json:"vat"`
Path string `json:"path"`
Price uint64 `json:"price"`
PriceItems []PriceItem
Quantity uint64 `json:"quantity"`
CreatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-"`
}
type LineItemMetadata ¶
type Order ¶
type Order struct {
ID string `json:"id"`
User *User `json:"user,omitempty"`
UserID string `json:"user_id,omitempty"`
SessionID string `json:"-"`
Email string `json:"email"`
LineItems []*LineItem `json:"line_items"`
Currency string `json:"currency"`
Taxes uint64 `json:"taxes"`
Shipping uint64 `json:"shipping"`
SubTotal uint64 `json:"subtotal"`
Total uint64 `json:"total"`
PaymentState string `json:"payment_state"`
FulfillmentState string `json:"fulfillment_state"`
State string `json:"state"`
Transactions []*Transaction `json:"transactions"`
Notes []*OrderNote `json:"notes"`
ShippingAddress Address `json:"shipping_address",gorm:"ForeignKey:ShippingAddressID"`
ShippingAddressID string `json:"shipping_address_id"`
BillingAddress Address `json:"billing_address",gorm:"ForeignKey:BillingAddressID"`
BillingAddressID string `json:"billing_address_id"`
VATNumber string `json:"vatnumber"`
Data []OrderData `json:"-"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"-",sql:"index"`
}
func (*Order) CalculateTotal ¶
func (o *Order) CalculateTotal(settings *SiteSettings)
func (*Order) MarshalJSON ¶
MarshalJSON is a custom JSON marshaller for Users
type OrderData ¶ added in v0.2.0
type OrderData struct {
OrderID string `gorm:"primary_key"`
Key string `gorm:"primary_key"`
Type int
NumericValue float64
StringValue string
BoolValue bool
}
OrderData is the custom data on an Order
type OrderNote ¶
type PriceMetaItem ¶ added in v1.0.0
type PriceMetadata ¶
type PriceMetadata struct {
Amount string `json:"amount"`
Currency string `json:"currency"`
VAT string `json:"vat"`
Items []PriceMetaItem `json:"items"`
// contains filtered or unexported fields
}
type SiteSettings ¶
type SiteSettings struct {
Taxes []*Tax `json:"taxes"`
}
type Transaction ¶
type Transaction struct {
ID string `json:"id"`
Order *Order `json:"-"`
OrderID string `json:"order_id"`
ProcessorID string `json:"processor_id"`
User *User `json:"-"`
UserID string `json:"user_id"`
Amount uint64 `json:"amount"`
Currency string `json:"currency"`
FailureCode string `json:"failure_code"`
FailureDescription string `json:"failure_description"`
Status string `json:"status"`
Type string `json:"type"`
CreatedAt time.Time `json:"created_at"`
DeletedAt *time.Time `json:"-"`
}
Transaction is an transaction with a payment provider
func NewTransaction ¶
func NewTransaction(order *Order) *Transaction
NewTransaction returns a new transaction for an order
func (Transaction) TableName ¶ added in v0.2.0
func (Transaction) TableName() string
Click to show internal directories.
Click to hide internal directories.