Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // CreditsURL contains the URL of the Credits API. CreditsURL string // PaymentsURL contains the URL of the Payments API. PaymentsURL string // ApplicationName contains the unique name for this application. Used to track billing operations and keep them // in the same application context. ApplicationName string // Timeout is the amount of time a client can wait until a timeout occurs. Timeout time.Duration // Enabled is set to true if the service should be enabled. Enabled bool // ProfitMargin measures how much profit is generated from a simulation. Defines the amount by which the costs should be // multiplied to generate a profit. ProfitMargin uint }
Config is used to configure new service implementations
type CreateSessionRequest ¶
type CreateSessionRequest struct { // SuccessURL is the url where to redirect users after a payment succeeds. SuccessURL string `json:"success_url"` // CancelURL is the url where to redirect users after a payment fails. CancelURL string `json:"cancel_url"` // Handle is the username of the user that is starting the payment session. Handle string `json:"-"` }
CreateSessionRequest is used to create a new payment session.
type CreateSessionResponse ¶
type CreateSessionResponse apiPayments.CreateSessionResponse
CreateSessionResponse is the response from calling Service.CreateSession.
type GetBalanceResponse ¶
type GetBalanceResponse apiCredits.GetBalanceResponse
GetBalanceResponse is the response from calling Service.GetBalance.
type Service ¶
type Service interface { // GetBalance returns the credits balance of the given user. GetBalance(ctx context.Context, user *users.User) (GetBalanceResponse, error) // CreateSession creates a new payment session. CreateSession(ctx context.Context, in CreateSessionRequest) (CreateSessionResponse, error) // IsEnabled returns true when this service is enabled. IsEnabled() bool // SubtractCredits subtracts the credits from the given user for the amount of time the given simulation has been running. SubtractCredits(ctx context.Context, user *users.User, sim simulations.Simulation) error }
Service holds methods to interact with different billing services.
func NewService ¶
NewService initializes a new Service implementation using the given config.
Click to show internal directories.
Click to hide internal directories.