service

package
v0.0.0-...-8f31e64 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigPath = "etc/librefund.yaml"

Variables

This section is empty.

Functions

func CancelObjectiveTxs

func CancelObjectiveTxs(
	transactions librefund.TransactionStorer,
	obj *librefund.Objective,
) ([]librefund.Transaction, error)

func ClaimObjectiveTxs

func ClaimObjectiveTxs(
	transactions librefund.TransactionStorer,
	obj *librefund.Objective,
	maintainerAccount string,
) ([]librefund.Transaction, error)

func TransferMethodFor

func TransferMethodFor(cfg *librefund.Config, curCode string) (string, error)

TransferMethodFor returns the supported transfer method for the given currency.

May be updated to return an multiple options.

Types

type Contribution

type Contribution struct {
	Project       *librefund.Project      `json:"project"`
	Objective     *librefund.Objective    `json:"objective"`
	TransactionID librefund.TransactionID `json:"transactionID"`
	RedirectURL   string                  `json:"redirectUrl,omitempty"`
}

type ContributionReq

type ContributionReq struct {
	AgreeToTerms   bool
	Amount         string
	Bitcoin        *bitcoin.TransferInfo
	TransferMethod string
}

type Email

type Email struct {
	Body    string
	Subject string
	To      []string
}

func (Email) Bytes

func (s Email) Bytes() []byte

type PaymentStarted

type PaymentStarted struct {
	Event     string    `json:"event"`
	CreatedAt time.Time `json:"createdAt"`

	PaymentID  string            `json:"paymentId"`
	ObjVersion librefund.Version `json:"objVersion"`
	Method     string            `json:"method"`
}

func (*PaymentStarted) Name

func (s *PaymentStarted) Name() string

func (*PaymentStarted) New

func (s *PaymentStarted) New() interface{}

type PaymentStore

type PaymentStore struct {
	// contains filtered or unexported fields
}

func NewPaymentStore

func NewPaymentStore(
	eventLog *librefund.EventLog,
) *PaymentStore

func (*PaymentStore) GetObjVersion

func (s *PaymentStore) GetObjVersion(paymentID string) (librefund.Version, bool)

func (*PaymentStore) GetTransferMethod

func (s *PaymentStore) GetTransferMethod(paymentID string) (string, bool)

func (*PaymentStore) PaymentStarted

func (s *PaymentStore) PaymentStarted(
	paymentID string,
	method string,
	objVersion librefund.Version,
) error

type QuotePricer

type QuotePricer interface {
	QuotePrice(curCode string, base *librefund.Money) (*librefund.Money, error)
}

QuotePricer returns the conversion amount of a given currency amount.

type SMTPNotifier

type SMTPNotifier struct {
	Config *librefund.Config
}

func NewSMTPNotifier

func NewSMTPNotifier(cfg *librefund.Config) (*SMTPNotifier, error)

func (*SMTPNotifier) NotifyContribution

func (s *SMTPNotifier) NotifyContribution(
	tx *librefund.Transaction,
	obj *librefund.Objective,
) error

NotifyContribution emails configured recipients about a new contribution.

type ScheduledFunc

type ScheduledFunc func()

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

func NewScheduler

func NewScheduler() *Scheduler

func (*Scheduler) RunEvery

func (s *Scheduler) RunEvery(
	dur time.Duration,
	run ScheduledFunc)

func (*Scheduler) Start

func (s *Scheduler) Start() error

func (*Scheduler) Stop

func (s *Scheduler) Stop()

type Service

type Service struct {
	Config librefund.Config
	// contains filtered or unexported fields
}

func NewService

func NewService(cfg librefund.Config) (*Service, error)

func (*Service) CancelObjective

func (s *Service) CancelObjective(
	projName string,
	objName string,
) error

func (*Service) ClaimObjective

func (s *Service) ClaimObjective(
	projName string,
	objName string,
) error

TODO: Ensure ClaimObjective is idempotent

func (*Service) Contribute

func (s *Service) Contribute(
	project string,
	objVersion librefund.Version,
	fullfillmentURL *string,
	details ContributionReq,
) (*Contribution, error)

func (*Service) ContributeBitcoin

func (s *Service) ContributeBitcoin(
	paymentID string,
) (*bitcoin.PaymentInfo, error)

func (*Service) CreateQRCode

func (s *Service) CreateQRCode(
	address string,
) ([]byte, error)

CreateQRCode writes a QR code for Bitcoin Addresses to the given output.

func (*Service) GetObjective

func (s *Service) GetObjective(
	project string,
	name string,
) (*librefund.Objective, error)

func (*Service) GetObjectiveByVersion

func (s *Service) GetObjectiveByVersion(
	version librefund.Version,
) (*librefund.Objective, error)

func (*Service) GetProject

func (s *Service) GetProject(name string) (*librefund.Project, error)

func (*Service) GetProjectContributions

func (s *Service) GetProjectContributions(
	project string,
	count, offset int,
) ([]*librefund.Contribution, error)

func (*Service) GetProjectContributionsTotal

func (s *Service) GetProjectContributionsTotal(
	name string,
) (int, error)

func (*Service) GetProjectUpdates

func (s *Service) GetProjectUpdates(
	name string,
	count, offset int,
) ([]librefund.Update, error)

func (*Service) GetProjectUpdatesTotal

func (s *Service) GetProjectUpdatesTotal(
	name string,
) (int, error)

func (*Service) GetTermsAndConditions

func (s *Service) GetTermsAndConditions() (string, error)

func (*Service) GetTransaction

func (s *Service) GetTransaction(
	txID librefund.TransactionID,
) (*librefund.Transaction, error)

func (*Service) ListObjectives

func (s *Service) ListObjectives(name string) ([]*librefund.Objective, error)

func (*Service) Projects

func (s *Service) Projects(name string) (*librefund.Project, bool)

func (*Service) QuotePrice

func (s *Service) QuotePrice(curCode string, base *librefund.Money) (*librefund.Money, error)

QuotePrice returns the last known quoted conversion amount to the given currency.

func (*Service) SetLogger

func (s *Service) SetLogger(log librefund.Logger)

func (*Service) Start

func (s *Service) Start() error

func (*Service) Stop

func (s *Service) Stop()

Jump to

Keyboard shortcuts

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