payment

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BankAccountDetails

type BankAccountDetails struct {
	AccountNumber     string `json:"account_number"`
	RoutingNumber     string `json:"routing_number"`
	AccountHolderName string `json:"account_holder_name"`
}

BankAccountDetails contains bank account information for payouts

type GetPaymentStatusParams

type GetPaymentStatusParams struct {
	PaymentID string
}

GetPaymentStatusParams holds the parameters for the GetPaymentStatus method.

type InitiatePaymentParams

type InitiatePaymentParams struct {
	UserID        uuid.UUID
	AccountID     uuid.UUID
	TransactionID uuid.UUID
	Amount        int64
	Currency      string
}

InitiatePaymentParams holds the parameters for the InitiatePayment method.

type InitiatePaymentResponse

type InitiatePaymentResponse struct {
	Status PaymentStatus
	// PaymentID is the ID of the payment in the payment provider
	// (e.g., Stripe Checkout Session ID)
	PaymentID string
}

type InitiatePayoutParams

type InitiatePayoutParams struct {
	UserID            uuid.UUID
	AccountID         uuid.UUID
	PaymentProviderID string
	TransactionID     uuid.UUID
	Amount            int64
	Currency          string
	Destination       PayoutDestination
	Description       string
	Metadata          map[string]string
}

InitiatePayoutParams holds the parameters for initiating a payout

type InitiatePayoutResponse

type InitiatePayoutResponse struct {
	PayoutID             string
	PaymentProviderID    string
	Status               PaymentStatus
	Amount               int64
	Currency             string
	FeeAmount            int64
	FeeCurrency          string
	EstimatedArrivalDate int64 // Unix timestamp
}

InitiatePayoutResponse represents the response from initiating a payout

type Payment

type Payment interface {
	InitiatePayment(
		ctx context.Context,
		params *InitiatePaymentParams,
	) (*InitiatePaymentResponse, error)

	HandleWebhook(
		ctx context.Context,
		payload []byte,
		signature string,
	) (*PaymentEvent, error)

	// InitiatePayout initiates a payout to a connected account
	InitiatePayout(
		ctx context.Context,
		params *InitiatePayoutParams,
	) (*InitiatePayoutResponse, error)
}

Payment is a interface for payment provider

type PaymentEvent

type PaymentEvent struct {
	ID            string
	TransactionID uuid.UUID
	Status        PaymentStatus
	Amount        int64
	Currency      string
	UserID        uuid.UUID
	AccountID     uuid.UUID
	Metadata      map[string]string
}

PaymentEvent represents a payment-related event from the payment provider.

type PaymentEventType

type PaymentEventType string

PaymentEventType represents the type of payment event.

const (
	// EventTypePaymentIntentSucceeded is emitted when a payment intent succeeds.
	EventTypePaymentIntentSucceeded PaymentEventType = "payment_intent.succeeded"
	// EventTypePaymentIntentFailed is emitted when a payment intent fails.
	EventTypePaymentIntentFailed PaymentEventType = "payment_intent.failed"
	// EventTypePayoutPaid is emitted when a payout is paid.
	EventTypePayoutPaid PaymentEventType = "payout.paid"
	// EventTypePayoutFailed is emitted when a payout fails.
	EventTypePayoutFailed PaymentEventType = "payout.failed"
)

type PaymentStatus

type PaymentStatus string

PaymentStatus represents the status of a payment.

const (
	// PaymentPending indicates the payment is still pending.
	PaymentPending PaymentStatus = "pending"
	// PaymentCompleted indicates the payment has completed successfully.
	PaymentCompleted PaymentStatus = "completed"
	// PaymentFailed indicates the payment has failed.
	PaymentFailed PaymentStatus = "failed"
)

type PayoutDestination

type PayoutDestination struct {
	Type           PayoutDestinationType
	BankAccount    *BankAccountDetails `json:"bank_account,omitempty"`
	ExternalWallet *string             `json:"external_wallet,omitempty"`
}

PayoutDestination represents the destination for a payout

type PayoutDestinationType

type PayoutDestinationType string

PayoutDestinationType represents the type of destination for a payout

const (
	// PayoutDestinationBankAccount represents a bank account payout destination
	PayoutDestinationBankAccount PayoutDestinationType = "bank_account"
	// PayoutDestinationExternalWallet represents an external wallet payout destination
	PayoutDestinationExternalWallet PayoutDestinationType = "external_wallet"
)

type UpdatePaymentStatusParams

type UpdatePaymentStatusParams struct {
	TransactionID uuid.UUID
	PaymentID     string
	Status        PaymentStatus
}

UpdatePaymentStatusParams holds the parameters for updating a payment status

Jump to

Keyboard shortcuts

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