billing

package
v0.0.0-...-e0d82eb Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const TaskQueue = "billing"

TaskQueue is the default task queue for the Billing system.

Variables

This section is empty.

Functions

func ChargeWorkflowID

func ChargeWorkflowID(input ChargeInput) string

ChargeWorkflowID returns the workflow ID for a Charge workflow.

func Router

func Router(c client.Client, logger *slog.Logger) http.Handler

Router implements the http.Handler interface for the Billing API

func RunWorker

func RunWorker(ctx context.Context, config config.AppConfig, client client.Client) error

RunWorker runs a Workflow and Activity worker for the Billing system.

Types

type Activities

type Activities struct {
	FraudCheckURL string
}

Activities implements the billing package's Activities. Any state shared by the worker among the activities is stored here.

func (*Activities) ChargeCustomer

func (a *Activities) ChargeCustomer(ctx context.Context, input *ChargeCustomerInput) (*ChargeCustomerResult, error)

ChargeCustomer activity charges a customer for a fulfillment.

func (*Activities) GenerateInvoice

func (a *Activities) GenerateInvoice(ctx context.Context, input *GenerateInvoiceInput) (*GenerateInvoiceResult, error)

GenerateInvoice activity creates an invoice for a fulfillment.

type ChargeCustomerInput

type ChargeCustomerInput struct {
	CustomerID string `json:"customerId"`
	Reference  string `json:"reference"`
	Charge     int32  `json:"charge"`
}

ChargeCustomerInput is the input for the ChargeCustomer activity.

type ChargeCustomerResult

type ChargeCustomerResult struct {
	Success  bool   `json:"success"`
	AuthCode string `json:"authCode"`
}

ChargeCustomerResult is the result for the GenerateInvoice activity.

type ChargeInput

type ChargeInput struct {
	CustomerID     string `json:"customerId"`
	Reference      string `json:"orderReference"`
	Items          []Item `json:"items"`
	IdempotencyKey string `json:"idempotencyKey,omitempty"`
}

ChargeInput is the input for the Charge workflow.

type ChargeResult

type ChargeResult struct {
	InvoiceReference string `json:"invoiceReference"`
	SubTotal         int32  `json:"subTotal"`
	Shipping         int32  `json:"shipping"`
	Tax              int32  `json:"tax"`
	Total            int32  `json:"total"`

	Success  bool   `json:"success"`
	AuthCode string `json:"authCode"`
}

ChargeResult is the result for the Charge workflow.

func Charge

func Charge(ctx workflow.Context, input *ChargeInput) (*ChargeResult, error)

Charge Workflow invoices and processes payment for a fulfillment.

type GenerateInvoiceInput

type GenerateInvoiceInput struct {
	CustomerID string `json:"customerId"`
	Reference  string `json:"orderReference"`
	Items      []Item `json:"items"`
}

GenerateInvoiceInput is the input for the GenerateInvoice activity.

type GenerateInvoiceResult

type GenerateInvoiceResult struct {
	InvoiceReference string `json:"invoiceReference"`
	SubTotal         int32  `json:"subTotal"`
	Shipping         int32  `json:"shipping"`
	Tax              int32  `json:"tax"`
	Total            int32  `json:"total"`
}

GenerateInvoiceResult is the result for the GenerateInvoice activity.

type Item

type Item struct {
	SKU      string `json:"sku"`
	Quantity int32  `json:"quantity"`
}

Item represents an item being ordered.

Jump to

Keyboard shortcuts

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