Documentation
¶
Index ¶
- Constants
- Variables
- func AutoMigrate(db *gorm.DB) error
- func Connect(config *conf.Configuration) (*gorm.DB, error)
- func LogEvent(db *gorm.DB, ip, userID, orderID string, eventType EventType, changes []string)
- func RunHooks(db *gorm.DB, log *logrus.Entry, secret string)
- type AddonItem
- type AddonMetaItem
- type Address
- type AddressRequest
- type Configuration
- type Coupon
- type Download
- type Event
- type EventType
- type FixedAmount
- type Hook
- type LineItem
- func (l *LineItem) AfterFind() (err error)
- func (l *LineItem) BeforeUpdate() (err error)
- func (i *LineItem) FixedVAT() uint64
- func (i *LineItem) GetQuantity() uint64
- func (i *LineItem) PriceInLowestUnit() uint64
- func (i *LineItem) Process(userClaims map[string]interface{}, order *Order, meta *LineItemMetadata) error
- func (i *LineItem) ProductType() string
- func (LineItem) TableName() string
- func (i *LineItem) TaxableItems() []calculator.Item
- type LineItemMetadata
- type Order
- type OrderNote
- type PriceItem
- type PriceMetaItem
- type PriceMetadata
- 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 MaxConcurrentHooks = 5
View Source
const MaxRetries = 5
View Source
const PaidState = "paid"
View Source
const PendingState = "pending"
View Source
const RefundTransactionType = "refund"
View Source
const RetryPeriod = 30 * time.Second
View Source
const ShippedState = "shipped"
View Source
const SignatureExpiration = 5 * time.Minute
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
func Connect ¶
func Connect(config *conf.Configuration) (*gorm.DB, error)
Connect will connect to that storage engine
Types ¶
type AddonItem ¶ added in v1.1.0
type AddonMetaItem ¶ added in v1.1.0
type AddonMetaItem struct {
Sku string `json:"sku"`
Title string `json:"title"`
Description string `json:"description"`
Prices []PriceMetadata `json:"prices"`
}
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 Coupon ¶ added in v1.1.0
type Coupon struct {
Code string `json:"code"`
StartDate *time.Time `json:"start_date,omitempty"`
EndDate *time.Time `json:"end_date,omitempty"`
Percentage uint64 `json:"percentage,omitempty"`
FixedAmount []*FixedAmount `json:"fixed,omitempty"`
ProductTypes []string `json:"product_types,omitempty"`
Claims map[string]interface{} `json:"claims,omitempty"`
}
func (*Coupon) FixedDiscount ¶ added in v1.1.0
func (*Coupon) PercentageDiscount ¶ added in v1.1.0
func (*Coupon) ValidForPrice ¶ added in v1.1.0
func (*Coupon) ValidForType ¶ added in v1.1.0
type Download ¶ added in v1.1.0
type Download struct {
ID string `json:"id"`
OrderID string `json:"order_id"`
LineItemID int64 `json:"line_item_id"`
Title string `json:"title"`
Sku string `json:"sku"`
Format string `json:"format"`
URL string `json:"url"`
DownloadCount uint64 `json:"downloads"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"-",sql:"index"`
}
type Event ¶ added in v1.1.0
type Event struct {
ID uint64 `json:"id"`
IP string `json:"ip"`
User *User `json:"user,omitempty"`
UserID string `json:"user_id,omitempty"`
Order *Order `json:"order,omitempty"`
OrderID string `json:"order_id,omitempty"`
Type string `json:"type"`
Changes string `json:"data"`
CreatedAt time.Time `json:"created_at"`
}
type FixedAmount ¶ added in v1.1.0
type Hook ¶ added in v1.1.0
type Hook struct {
ID uint64
UserID string
Type string
Done bool
Failed bool
URL string
Payload string
ResponseStatus string
ResponseHeaders string
ResponseBody string
ErrorMessage *string
Tries int
CreatedAt time.Time
RunAfter *time.Time
LockedAt *time.Time
LockedBy *string
CompletedAt *time.Time
}
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"`
Path string `json:"path"`
Price uint64 `json:"price"`
VAT uint64 `json:"vat"`
PriceItems []*PriceItem `json:"price_items"`
AddonItems []*AddonItem `json:"addons"`
AddonPrice uint64 `json:"addon_price"`
Quantity uint64 `json:"quantity"`
MetaData map[string]interface{} `sql:"-" json:"meta"`
RawMetaData string `json:"-"`
CreatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-"`
}
func (*LineItem) BeforeUpdate ¶ added in v1.1.0
func (*LineItem) GetQuantity ¶ added in v1.1.0
func (*LineItem) PriceInLowestUnit ¶ added in v1.1.0
Make sure LineItem is a valid Item for the calculator
func (*LineItem) Process ¶
func (i *LineItem) Process(userClaims map[string]interface{}, order *Order, meta *LineItemMetadata) error
func (*LineItem) ProductType ¶ added in v1.1.0
func (*LineItem) TaxableItems ¶ added in v1.1.0
func (i *LineItem) TaxableItems() []calculator.Item
type LineItemMetadata ¶
type LineItemMetadata struct {
Sku string `json:"sku"`
Title string `json:"title"`
Description string `json:"description"`
VAT uint64 `json:"vat"`
Prices []PriceMetadata `json:"prices"`
Type string `json:"type"`
Downloads []Download `json:"downloads"`
Addons []AddonMetaItem `json:"addons"`
Webhook string `json:"webhook"`
}
type Order ¶
type Order struct {
ID string `json:"id"`
IP string `json:"ip"`
User *User `json:"user,omitempty"`
UserID string `json:"user_id,omitempty"`
SessionID string `json:"-"`
Email string `json:"email"`
LineItems []*LineItem `json:"line_items"`
Downloads []Download `json:"downloads"`
Currency string `json:"currency"`
Taxes uint64 `json:"taxes"`
Shipping uint64 `json:"shipping"`
SubTotal uint64 `json:"subtotal"`
Discount uint64 `json:"discount"`
Total uint64 `json:"total"`
PaymentState string `json:"payment_state"`
FulfillmentState string `json:"fulfillment_state"`
State string `json:"state"`
PaymentProcessor string `json:"payment_processor"`
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"`
MetaData map[string]interface{} `sql:"-" json:"meta"`
RawMetaData string `json:"-"`
CouponCode string `json:"coupon_code,omitempty"`
Coupon *Coupon `json:"coupon,omitempty" sql:"-"`
RawCoupon string `json:"-"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"-",sql:"index"`
}
func (*Order) BeforeUpdate ¶ added in v1.1.0
func (*Order) CalculateTotal ¶
func (o *Order) CalculateTotal(settings *calculator.Settings, claims map[string]interface{})
type OrderNote ¶
type PriceItem ¶ added in v1.0.0
type PriceItem struct {
ID int64 `json:"id"`
Amount uint64 `json:"amount"`
Type string `json:"type"`
VAT uint64 `json:"vat"`
}
func (*PriceItem) GetQuantity ¶ added in v1.1.0
func (*PriceItem) PriceInLowestUnit ¶ added in v1.1.0
Make sure a PriceItem fullfils the calculator Item interface
func (*PriceItem) ProductType ¶ added in v1.1.0
func (*PriceItem) TaxableItems ¶ added in v1.1.0
func (i *PriceItem) TaxableItems() []calculator.Item
type PriceMetaItem ¶ added in v1.0.0
type PriceMetadata ¶
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.