Documentation
¶
Index ¶
- type IdempotencyKey
- type Module
- func (m *Module) CompensatePayment(ctx context.Context, input any) (any, error)
- func (m *Module) CompensatePaymentStep(sCtx mdk.StepContext) mdk.StepResult
- func (m *Module) FieldResolvers() map[string]any
- func (m *Module) GetPayment(ctx context.Context, id string) (*Payment, error)
- func (m *Module) ID() string
- func (m *Module) Init(ctx context.Context, rt mdk.Runtime) error
- func (m *Module) ListOrderPayments(ctx context.Context, orderID string) ([]*Payment, error)
- func (m *Module) Models() []any
- func (m *Module) Mutations() map[string]any
- func (m *Module) ProcessPayment(ctx context.Context, input any) (any, error)
- func (m *Module) ProcessPaymentStep(sCtx mdk.StepContext) mdk.StepResult
- func (m *Module) Queries() map[string]any
- func (m *Module) Repo() *Repository
- func (m *Module) Routes() []mdk.Route
- func (m *Module) Shutdown(ctx context.Context) error
- type Payment
- type PaymentStatus
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IdempotencyKey ¶
type IdempotencyKey struct {
ID string `gorm:"primaryKey"`
Scope string `gorm:"index:idx_scope_key,unique"`
Key string `gorm:"index:idx_scope_key,unique"`
CreatedAt time.Time
}
IdempotencyKey prevents duplicate processing of the same operation.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module implements the mdk.Module interface for Finance.
func (*Module) CompensatePayment ¶
CompensatePayment handles refunding a payment if a subsequent step fails.
func (*Module) CompensatePaymentStep ¶
func (m *Module) CompensatePaymentStep(sCtx mdk.StepContext) mdk.StepResult
CompensatePaymentStep wraps CompensatePayment to mdk.StepHandler.
func (*Module) FieldResolvers ¶
func (*Module) GetPayment ¶
func (*Module) ListOrderPayments ¶
func (*Module) ProcessPayment ¶
ProcessPayment processes the payment for an order and creates a Payment record.
func (*Module) ProcessPaymentStep ¶
func (m *Module) ProcessPaymentStep(sCtx mdk.StepContext) mdk.StepResult
ProcessPaymentStep wraps ProcessPayment to mdk.StepHandler.
func (*Module) Repo ¶
func (m *Module) Repo() *Repository
type Payment ¶
type Payment struct {
ID string `gorm:"primaryKey" json:"id"`
OrderID string `gorm:"index" json:"order_id"`
Amount float64 `json:"amount"`
Status PaymentStatus `gorm:"not null" json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
Payment represents a financial transaction.
type PaymentStatus ¶
type PaymentStatus string
const ( PaymentPending PaymentStatus = "PENDING" PaymentSuccess PaymentStatus = "SUCCESS" PaymentFailed PaymentStatus = "FAILED" PaymentRefunded PaymentStatus = "REFUNDED" )
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository handles data access for finance models.
func NewRepository ¶
func NewRepository(database *gorm.DB) *Repository
NewRepository creates a new Repository.
func (*Repository) ListByOrderID ¶
ListByOrderID retrieves all payments for an order.
Click to show internal directories.
Click to hide internal directories.