Skip to content
This repository has been archived by the owner on Nov 30, 2019. It is now read-only.

secondbit/whipround-paymentlog

Repository files navigation

paymentlog

import "code.whipround.net/paymentlog"

Constants

const (
    SourceBalanced = "balanced"
    StatusPending  = "pending"
    CurrencyUSD    = "usd"
)

Variables

var (
    MissingID          = errors.New("Missing payment log ID.")
    MissingAmount      = errors.New("Missing payment log amount.")
    MissingSource      = errors.New("Missing payment log source.")
    MissingSourceID    = errors.New("Missing payment log source ID.")
    MissingCreated     = errors.New("Missing payment log created timestamp.")
    MissingStatus      = errors.New("Missing payment log status.")
    MissingCurrency    = errors.New("Missing payment log currency.")
    MissingProjectID   = errors.New("Missing payment log campaign ID.")
    MissingUserID      = errors.New("Missing payment log user ID.")
    MissingAccountType = errors.New("Missing payment log account type.")
    MissingAccountID   = errors.New("Missing payment log account ID.")

    AlreadyExists = errors.New("Payment log already exists.")
    LogNotFound   = errors.New("Payment log not found.")
)

func SortFailureLogs

func SortFailureLogs(logs []FailureLog) []FailureLog

func SortLogsByCreated

func SortLogsByCreated(logs []PaymentLog) []PaymentLog

type FailureLog

type FailureLog struct {
    ID                string
    PaymentLogID      string
    FailureReason     string
    FailureReasonCode string
    Timestamp         time.Time
}

type LogStore

type LogStore interface {
    StorePaymentLog(log PaymentLog) error
    UpdatePaymentLog(id string, change PaymentLogChange) error
    DeletePaymentLog(id string) error
    GetPaymentLog(id string) (PaymentLog, error)
    ListPaymentLogsByProject(campaignID string, num, offset int) ([]PaymentLog, error)
    ListPaymentLogsByUser(userID string, num, offset int) ([]PaymentLog, error)
    ListPaymentLogs(num, offset int) ([]PaymentLog, error)

    StoreFailureLog(failure FailureLog) error
    ListFailureLogs(num, offset int) ([]FailureLog, error)
    ListFailureLogsSince(timestamp time.Time) ([]FailureLog, error)
}

type MemoryStore

type MemoryStore struct {
    sync.Mutex
    // contains filtered or unexported fields
}

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) DeletePaymentLog

func (store *MemoryStore) DeletePaymentLog(id string) error

func (*MemoryStore) GetPaymentLog

func (store *MemoryStore) GetPaymentLog(id string) (PaymentLog, error)

func (*MemoryStore) ListFailureLogs

func (store *MemoryStore) ListFailureLogs(num, offset int) ([]FailureLog, error)

func (*MemoryStore) ListFailureLogsSince

func (store *MemoryStore) ListFailureLogsSince(timestamp time.Time) ([]FailureLog, error)

func (*MemoryStore) ListPaymentLogs

func (store *MemoryStore) ListPaymentLogs(num, offset int) ([]PaymentLog, error)

func (*MemoryStore) ListPaymentLogsByProject

func (store *MemoryStore) ListPaymentLogsByProject(id string, num, offset int) ([]PaymentLog, error)

func (*MemoryStore) ListPaymentLogsByUser

func (store *MemoryStore) ListPaymentLogsByUser(id string, num, offset int) ([]PaymentLog, error)

func (*MemoryStore) StoreFailureLog

func (store *MemoryStore) StoreFailureLog(log FailureLog) error

func (*MemoryStore) StorePaymentLog

func (store *MemoryStore) StorePaymentLog(log PaymentLog) error

func (*MemoryStore) UpdatePaymentLog

func (store *MemoryStore) UpdatePaymentLog(id string, change PaymentLogChange) error

type PaymentLog

type PaymentLog struct {
    ID          string
    Amount      uint
    Description string
    Source      string
    SourceID    string
    Created     time.Time
    Updated     time.Time
    Status      string
    Currency    string
    ProjectID   string
    UserID      string
    AccountID   string
    AccountType string
}

func (PaymentLog) Validate

func (p PaymentLog) Validate() error

type PaymentLogChange

type PaymentLogChange struct {
    Amount      *uint
    Description *string
    Source      *string
    SourceID    *string
    Created     *time.Time
    Updated     *time.Time
    Status      *string
    Currency    *string
}

Generated by godoc2md

About

A service to store payment logs from various payment providers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published