payment

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Payment

type Payment struct {
	// Unique identifier for this payment transaction
	ID string `json:"id"`
	// Unique key used in the idempotency_key field to prevent duplicate payment processing
	IdempotencyKey string `json:"idempotency_key"`
	// The destination_type indicates what entity this payment is being made to (invoice, subscription, etc.)
	DestinationType types.PaymentDestinationType `json:"destination_type"`
	// The destination_id specifies which specific entity is receiving this payment
	DestinationID string `json:"destination_id"`
	// The payment_method_type defines how the payment will be processed (credit_card, bank_transfer, offline, etc.)
	PaymentMethodType types.PaymentMethodType `json:"payment_method_type"`
	// The payment_method_id identifies which specific payment method to use for processing
	PaymentMethodID string `json:"payment_method_id"`
	// The payment_gateway field contains the name of the gateway used to process this transaction (optional)
	PaymentGateway *string `json:"payment_gateway,omitempty"`
	// The gateway_payment_id is the transaction identifier from the external payment gateway (optional)
	GatewayPaymentID *string `json:"gateway_payment_id,omitempty"`
	// The gateway_tracking_id is the tracking identifier from the external payment gateway (optional)
	GatewayTrackingID *string `json:"gateway_tracking_id,omitempty"`
	// The gateway_metadata field contains gateway-specific metadata (optional)
	GatewayMetadata types.Metadata `json:"gateway_metadata,omitempty"`
	// The amount field specifies the payment value in the given currency
	Amount decimal.Decimal `json:"amount"`
	// The currency field uses a three-letter ISO code (USD, EUR, GBP, etc.)
	Currency string `json:"currency"`
	// The payment_status shows the current state of this payment (pending, succeeded, failed, etc.)
	PaymentStatus types.PaymentStatus `json:"payment_status"`
	// The track_attempts flag indicates whether payment processing attempts are being monitored
	TrackAttempts bool `json:"track_attempts"`
	// The metadata field contains additional custom key-value pairs for this payment (optional)
	Metadata types.Metadata `json:"metadata,omitempty"`
	// The succeeded_at timestamp shows when this payment was successfully completed (optional)
	SucceededAt *time.Time `json:"succeeded_at,omitempty"`
	// The failed_at timestamp indicates when this payment failed (optional)
	FailedAt *time.Time `json:"failed_at,omitempty"`
	// The refunded_at timestamp shows when this payment was refunded (optional)
	RefundedAt *time.Time `json:"refunded_at,omitempty"`
	// The recorded_at timestamp indicates when this payment was manually recorded (optional)
	RecordedAt *time.Time `json:"recorded_at,omitempty"`
	// The error_message field provides details about why the payment failed (optional)
	ErrorMessage *string `json:"error_message,omitempty"`
	// The attempts array contains all processing attempts made for this payment (optional)
	Attempts []*PaymentAttempt `json:"attempts,omitempty"`
	// The environment_id identifies which environment this payment belongs to
	EnvironmentID string `json:"environment_id"`

	types.BaseModel
}

Payment represents a payment transaction

func FromEnt

func FromEnt(p *ent.Payment) *Payment

FromEnt converts an Ent payment to a domain payment

func FromEntList

func FromEntList(payments []*ent.Payment) []*Payment

FromEntList converts a list of Ent payments to domain payments

func (*Payment) TableName

func (p *Payment) TableName() string

TableName returns the table name for the payment

func (*Payment) Validate

func (p *Payment) Validate() error

Validate validates the payment

type PaymentAttempt

type PaymentAttempt struct {
	// Unique identifier for this specific payment attempt
	ID string `json:"id"`
	// The payment_id links this attempt to its parent payment transaction
	PaymentID string `json:"payment_id"`
	// The attempt_number shows the sequential order of this processing attempt
	AttemptNumber int `json:"attempt_number"`
	// The payment_status indicates the outcome of this specific attempt (pending, succeeded, failed, etc.)
	PaymentStatus types.PaymentStatus `json:"payment_status"`
	// The gateway_attempt_id is the identifier from the external payment gateway for this attempt (optional)
	GatewayAttemptID *string `json:"gateway_attempt_id,omitempty"`
	// The error_message field explains why this particular attempt failed (optional)
	ErrorMessage *string `json:"error_message,omitempty"`
	// The metadata field stores additional custom data for this attempt (optional)
	Metadata types.Metadata `json:"metadata,omitempty"`
	// The environment_id specifies which environment this attempt belongs to
	EnvironmentID string `json:"environment_id"`

	types.BaseModel
}

PaymentAttempt represents an attempt to process a payment

func FromEntAttempt

func FromEntAttempt(a *ent.PaymentAttempt) *PaymentAttempt

FromEntAttempt converts an Ent payment attempt to a domain payment attempt

func FromEntAttemptList

func FromEntAttemptList(attempts []*ent.PaymentAttempt) []*PaymentAttempt

FromEntAttemptList converts a list of Ent payment attempts to domain payment attempts

func (*PaymentAttempt) TableName

func (pa *PaymentAttempt) TableName() string

TableName returns the table name for the payment attempt

func (*PaymentAttempt) Validate

func (pa *PaymentAttempt) Validate() error

Validate validates the payment attempt

type Repository

type Repository interface {
	// Payment operations
	Create(ctx context.Context, payment *Payment) error
	Get(ctx context.Context, id string) (*Payment, error)
	Update(ctx context.Context, payment *Payment) error
	Delete(ctx context.Context, id string) error
	List(ctx context.Context, filter *types.PaymentFilter) ([]*Payment, error)
	Count(ctx context.Context, filter *types.PaymentFilter) (int, error)
	GetByIdempotencyKey(ctx context.Context, key string) (*Payment, error)

	// Payment attempt operations
	CreateAttempt(ctx context.Context, attempt *PaymentAttempt) error
	GetAttempt(ctx context.Context, id string) (*PaymentAttempt, error)
	UpdateAttempt(ctx context.Context, attempt *PaymentAttempt) error
	ListAttempts(ctx context.Context, paymentID string) ([]*PaymentAttempt, error)
	GetLatestAttempt(ctx context.Context, paymentID string) (*PaymentAttempt, error)
}

Repository defines the interface for payment persistence

Jump to

Keyboard shortcuts

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