purchases

package
v0.0.0-...-769f8fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CREATED          = "CREATED"
	WAITING_PAYMENT  = "WAITING_PAYMENT"
	COMPLETED        = "COMPLETED"
	DOCUMENTED       = "DOCUMENTED"
	PAYMENT_REJECTED = "PAYMENT_REJECTED"
	CANCELLED        = "CANCELLED"
)

Variables

This section is empty.

Functions

func CreateCartPurchase

func CreateCartPurchase(w http.ResponseWriter, r *http.Request)

func CreateProductPurchase

func CreateProductPurchase(w http.ResponseWriter, r *http.Request)

func ListPurchases

func ListPurchases(w http.ResponseWriter, r *http.Request)

func ReceiveMercadoPagoNotification

func ReceiveMercadoPagoNotification(w http.ResponseWriter, r *http.Request)

Types

type Pack

type Pack struct {
	PurchaseID string           `json:"purchaseId" gorm:"primaryKey"`
	ProductSku string           `json:"productSku" gorm:"primaryKey`
	Product    products.Product `json:"product" gorm:"foreignKey:ProductSku"`
	Quantity   int64            `json:"quantity"`
	Amount     float64          `json:"amount"`
}

type Payment

type Payment struct {
	PurchaseID       string `json:"purchaseId" gorm:"primaryKey"`
	MercadoPagoURL   string `json:"mercadoPagoURL"`
	MercadoPagoOrder int64  `json:"mercadoPagoOrder,omitempty"`
}

type Purchase

type Purchase struct {
	ID        string    `json:"id" gorm:"primaryKey"`
	UserID    string    `json:"userId"`
	Amount    float64   `json:"amount"`
	Status    string    `json:"status"`
	Payment   Payment   `json:"payment" gorm:"foreignkey:PurchaseID"`
	Packs     []Pack    `json:"packs" gorm:"foreignkey:PurchaseID"`
	InvoiceID string    `json:"invoiceId"`
	CreatedAt time.Time `json:"createdAt" gorm:"autoUpdateTime"`
	UpdatedAt time.Time `json:"updatedAt" gorm:"autoCreateTime"`
}

type PurchaseStatus

type PurchaseStatus string

type Usecases

type Usecases struct{}

func (Usecases) BuyCart

func (u Usecases) BuyCart(userId string) (*Purchase, error)

func (Usecases) BuyProduct

func (u Usecases) BuyProduct(userId, productSku string) (*Purchase, error)

func (Usecases) GetPurchases

func (u Usecases) GetPurchases(userId string, page int) (responses.PaginatedResponse, error)

func (Usecases) ReceiveMercadoPagoNotification

func (u Usecases) ReceiveMercadoPagoNotification(topic, id string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL