Documentation
¶
Index ¶
- Constants
- Variables
- func DisplayCents(cents int) string
- func InitPayPal(client, secret string, development bool) (*paypalsdk.Client, error)
- func UniqueHash(phrase string) string
- type Cart
- type CartItem
- type CartService
- type Config
- type Email
- type EmailService
- type Link
- type LinkService
- type NullInt64
- type NullString
- type Order
- type OrderProduct
- type OrderService
- type Product
- type ProductService
- type Promocode
- type PromocodeService
- type Services
- type Session
- type SessionService
- type User
- type UserService
Constants ¶
const ( // OrderCanceled represents the order canceled status. OrderCanceled = -1 // OrderPaymentWaiting represents an waiting payment status. OrderPaymentWaiting = 0 // OrderPaymentDone represents the payment done status. OrderPaymentDone = 1 // OrderPaymentFailed represents the failed payment status. OrderPaymentFailed = 2 // OrderUnfulfilled represents a unfulfilled order. OrderUnfulfilled = 0 // OrderFulfilled represents a fulfilled order. OrderFulfilled = 1 )
const (
// UpdateAll is used as a placeholder to update all of the fields
UpdateAll = "#update#"
)
Variables ¶
Functions ¶
func InitPayPal ¶
InitPayPal configures the paypal client variable
func UniqueHash ¶
UniqueHash returns a SHA256 hash based on the string and on the current time
Types ¶
type Cart ¶
Cart does exactly what is says
func (*Cart) FillProducts ¶
func (c *Cart) FillProducts(service ProductService) error
FillProducts ...
func (Cart) GetDescription ¶
GetDescription is used for the payment procedure
type CartService ¶
type CartService interface { Save(w http.ResponseWriter, c *Cart) error Get(w http.ResponseWriter, r *http.Request) (*Cart, error) Reset(w http.ResponseWriter) error }
CartService ...
type Config ¶
type Config struct { DefaultInvites int InviteOnly bool Port string BaseAddress string Templates string Domain string Scheme string Assets string CookieStore *securecookie.SecureCookie PayPal *paypalsdk.Client Logger *log.Logger Services *Services }
Config ...
type EmailService ¶
type EmailService interface { UseTemplate(e *Email, data interface{}, template string) error Send(e *Email) error }
EmailService ...
type Link ¶
type Link struct { Hash string `db:"hash"` User int `db:"user_id"` Path string `db:"path"` Used bool `db:"used"` Time *time.Time `db:"time"` Expires *time.Time `db:"expires"` }
Link ...
type LinkService ¶
type LinkService interface { Get(hash string) (*Link, error) Gets(first, limit int, order string) ([]*Link, error) Create(l *Link) error Update(l *Link, fields ...string) error Delete(hash string) error }
LinkService ...
type NullInt64 ¶
NullInt64 is a wraper for sql.NullInt64 that works with JSON Unmarshal
func (NullInt64) MarshalJSON ¶
MarshalJSON wraps the json.Marshal function
func (*NullInt64) UnmarshalJSON ¶
UnmarshalJSON wraps the json.Unmarshal function
type NullString ¶
type NullString struct {
sql.NullString
}
NullString is a wraper for sql.NullString that works with JSON Unmarshal
func (NullString) MarshalJSON ¶
func (v NullString) MarshalJSON() ([]byte, error)
MarshalJSON wraps the json.Marshal function
func (*NullString) UnmarshalJSON ¶
func (v *NullString) UnmarshalJSON(data []byte) error
UnmarshalJSON wraps the json.Unmarshal function
type Order ¶
type Order struct { ID int PayPal string Value int PaymentStatus int16 FulfillmentStatus int16 Credits int User *User Promocode *Promocode Products []*OrderProduct }
Order ...
func (*Order) FulfillmentStatusText ¶
FulfillmentStatusText returns the text corresponding to the status variable.
func (*Order) PaymentStatusText ¶
PaymentStatusText returns the text corresponding to the status variable.
type OrderProduct ¶
OrderProduct ...
type OrderService ¶
type OrderService interface { Get(id int) (*Order, error) GetByPayPal(token string) (*Order, error) Gets(first, limit int, order string) ([]*Order, error) GetsWhere(first, limit int, order, where, sth string) ([]*Order, error) Total() (int, error) Create(o *Order) error Update(o *Order, fields ...string) error Delete(id int) error }
OrderService ...
type Product ¶
type Product struct { ID int `db:"id"` Name string `db:"name"` Description string `db:"description"` Price int `db:"price"` Picture string `db:"picture"` Deactivated bool `db:"deactivated"` }
Product ...
type ProductService ¶
type ProductService interface { Get(id int) (*Product, error) Gets(first, limit int, order string) ([]*Product, error) GetsWhere(first, limit int, order, where, sth string) ([]*Product, error) GetsWhereIn(first, limit int, order, where, in string) ([]*Product, error) Total() (int, error) Create(p *Product) error Update(p *Product, fields ...string) error Delete(id int) error }
ProductService ...
type Promocode ¶
type Promocode struct { ID int `db:"id"` Code string `db:"code"` Expires *time.Time `db:"expires"` Discount int `db:"discount"` Percentage bool `db:"percentage"` Used int `db:"used"` MaxUsage int `db:"maxusage"` Deactivated bool `db:"deactivated"` }
Promocode ...
type PromocodeService ¶
type PromocodeService interface { Get(id int) (*Promocode, error) GetByCode(code string) (*Promocode, error) Gets(first, limit int, order string) ([]*Promocode, error) Total() (int, error) Create(p *Promocode) error Update(p *Promocode, fields ...string) error Delete(id int) error }
PromocodeService ...
type Services ¶
type Services struct { Order OrderService Product ProductService Promocode PromocodeService User UserService Link LinkService Email EmailService Session SessionService Cart CartService }
Services ...
type SessionService ¶
type SessionService interface { Save(w http.ResponseWriter, sess *Session) error Get(w http.ResponseWriter, r *http.Request) (*Session, error) Reset(w http.ResponseWriter) error }
SessionService ...
type User ¶
type User struct { ID int `db:"id"` FirstName string `db:"first_name"` LastName string `db:"last_name"` Email string `db:"email"` Address NullString `db:"address"` Invites int `db:"invites"` Credit int `db:"credit"` Confirmed bool `db:"confirmed"` Admin bool `db:"admin"` Referral string `db:"referral"` Referrer NullInt64 `db:"referrer"` PasswordSalt string `db:"password_salt" json:"-"` PasswordHash string `db:"password_hash" json:"-"` Deactivated bool `db:"deactivated"` }
User contains the information of an User
func (*User) CheckPassword ¶
CheckPassword checks if the password of the user is correct
func (*User) SetPassword ¶
SetPassword generates the salt and the hash of the user password
type UserService ¶
type UserService interface { Get(id int) (*User, error) GetByEmail(email string) (*User, error) GetByReferral(referral string) (*User, error) Gets(first, limit int, order string) ([]*User, error) Total() (int, error) Create(u *User) error Update(u *User, fields ...string) error Delete(id int) error }
UserService ...