Documentation
¶
Index ¶
Constants ¶
const ( PaymentStatusPending = "pending" PaymentStatusProcessing = "processing" PaymentStatusSucceeded = "succeeded" PaymentStatusFailed = "failed" PaymentStatusCanceled = "canceled" )
PaymentStatus constants
const ( TransactionTypeCapture = "capture" TransactionTypeRefund = "refund" TransactionTypeVoid = "void" )
TransactionType constants
const ( WebhookStatusPending = "pending" WebhookStatusDelivered = "delivered" WebhookStatusFailed = "failed" WebhookStatusExpired = "expired" )
WebhookStatus constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditEntry ¶
type AuditEntry struct {
Timestamp time.Time `json:"timestamp"`
Action string `json:"action"`
UserID string `json:"user_id,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
Changes map[string]any `json:"changes,omitempty"`
Reason string `json:"reason,omitempty"`
}
AuditEntry represents an entry in the audit trail
type Customer ¶
type Customer struct {
ID string `dynamorm:"pk" json:"id"`
MerchantID string `dynamorm:"index:gsi-merchant,pk" json:"merchant_id"`
Email string `dynamorm:"index:gsi-email,encrypted" json:"email"`
Name string `dynamorm:"encrypted" json:"name"`
Phone string `dynamorm:"encrypted" json:"phone,omitempty"`
PaymentMethods []PaymentMethod `dynamorm:"json,encrypted:pci" json:"payment_methods"`
DefaultMethod string `json:"default_method,omitempty"`
Metadata map[string]string `dynamorm:"json" json:"metadata,omitempty"`
CreatedAt time.Time `dynamorm:"created_at" json:"created_at"`
UpdatedAt time.Time `dynamorm:"updated_at" json:"updated_at"`
Version int `dynamorm:"version" json:"version"`
}
Customer represents a customer with PCI-compliant payment methods
type IdempotencyRecord ¶
type IdempotencyRecord struct {
Key string `dynamorm:"pk" json:"key"`
MerchantID string `dynamorm:"index:gsi-merchant,pk" json:"merchant_id"`
RequestHash string `json:"request_hash"`
Response string `dynamorm:"json" json:"response"`
StatusCode int `json:"status_code"`
CreatedAt time.Time `dynamorm:"created_at" json:"created_at"`
ExpiresAt time.Time `dynamorm:"ttl" json:"expires_at"`
}
IdempotencyRecord tracks idempotent requests
type Merchant ¶
type Merchant struct {
ID string `dynamorm:"pk" json:"id"`
Name string `json:"name"`
Email string `dynamorm:"index:gsi-email" json:"email"`
Status string `json:"status"`
ProcessorConfig map[string]any `dynamorm:"json,encrypted" json:"-"`
WebhookURL string `json:"webhook_url,omitempty"`
WebhookSecret string `dynamorm:"encrypted" json:"-"`
Features []string `dynamorm:"set" json:"features"`
RateLimits RateLimits `dynamorm:"json" json:"rate_limits"`
CreatedAt time.Time `dynamorm:"created_at" json:"created_at"`
UpdatedAt time.Time `dynamorm:"updated_at" json:"updated_at"`
Version int `dynamorm:"version" json:"version"`
}
Merchant represents a merchant account
type Payment ¶
type Payment struct {
ID string `dynamorm:"pk" json:"id"`
IdempotencyKey string `dynamorm:"index:gsi-idempotency" json:"idempotency_key"`
MerchantID string `dynamorm:"index:gsi-merchant,pk" json:"merchant_id"`
Amount int64 `json:"amount"` // Always in cents
Currency string `json:"currency"`
Status string `dynamorm:"index:gsi-merchant,sk,prefix:status" json:"status"`
PaymentMethod string `json:"payment_method"`
CustomerID string `dynamorm:"index:gsi-customer" json:"customer_id,omitempty"`
Description string `json:"description,omitempty"`
Metadata map[string]string `dynamorm:"json" json:"metadata,omitempty"`
CreatedAt time.Time `dynamorm:"created_at" json:"created_at"`
UpdatedAt time.Time `dynamorm:"updated_at" json:"updated_at"`
Version int `dynamorm:"version" json:"version"`
}
Payment represents a payment transaction with idempotency support
type PaymentMethod ¶
type PaymentMethod struct {
ID string `json:"id"`
Type string `json:"type"` // card, bank_account
Last4 string `json:"last4"`
Brand string `json:"brand,omitempty"` // For cards
ExpiryMonth int `json:"expiry_month,omitempty"`
ExpiryYear int `json:"expiry_year,omitempty"`
BankName string `json:"bank_name,omitempty"` // For bank accounts
AccountType string `json:"account_type,omitempty"`
Token string `json:"-"` // Never expose in JSON
IsDefault bool `json:"is_default"`
CreatedAt time.Time `json:"created_at"`
}
PaymentMethod represents a customer's payment method
type RateLimits ¶
type RateLimits struct {
PaymentsPerMinute int `json:"payments_per_minute"`
PaymentsPerDay int `json:"payments_per_day"`
MaxPaymentAmount int64 `json:"max_payment_amount"`
}
RateLimits defines rate limiting configuration
type Settlement ¶
type Settlement struct {
ID string `dynamorm:"pk" json:"id"`
MerchantID string `dynamorm:"index:gsi-merchant,pk" json:"merchant_id"`
Date string `dynamorm:"index:gsi-merchant,sk" json:"date"` // YYYY-MM-DD
TotalAmount int64 `json:"total_amount"`
TransactionCount int `json:"transaction_count"`
Status string `json:"status"`
BatchID string `json:"batch_id"`
ProcessedAt time.Time `json:"processed_at,omitempty"`
Transactions []SettlementDetail `dynamorm:"json" json:"transactions"`
CreatedAt time.Time `dynamorm:"created_at" json:"created_at"`
UpdatedAt time.Time `dynamorm:"updated_at" json:"updated_at"`
}
Settlement represents a batch settlement
type SettlementDetail ¶
type SettlementDetail struct {
PaymentID string `json:"payment_id"`
TransactionID string `json:"transaction_id"`
Amount int64 `json:"amount"`
Fee int64 `json:"fee"`
NetAmount int64 `json:"net_amount"`
}
SettlementDetail represents a transaction in a settlement
type Transaction ¶
type Transaction struct {
ID string `dynamorm:"pk" json:"id"`
PaymentID string `dynamorm:"index:gsi-payment" json:"payment_id"`
Type string `json:"type"` // capture, refund, void
Amount int64 `json:"amount"`
Status string `json:"status"`
ProcessedAt time.Time `json:"processed_at"`
ProcessorID string `json:"processor_id,omitempty"`
ResponseCode string `json:"response_code,omitempty"`
ResponseText string `json:"response_text,omitempty"`
AuditTrail []AuditEntry `dynamorm:"json" json:"audit_trail"`
CreatedAt time.Time `dynamorm:"created_at" json:"created_at"`
UpdatedAt time.Time `dynamorm:"updated_at" json:"updated_at"`
Version int `dynamorm:"version" json:"version"`
}
Transaction represents a transaction on a payment (capture, refund, void)
type Webhook ¶
type Webhook struct {
ID string `dynamorm:"pk" json:"id"`
MerchantID string `dynamorm:"index:gsi-merchant,pk" json:"merchant_id"`
EventType string `dynamorm:"index:gsi-merchant,sk,prefix:event" json:"event_type"`
PaymentID string `json:"payment_id,omitempty"`
URL string `json:"url"`
Payload map[string]any `dynamorm:"json" json:"payload"`
Attempts int `json:"attempts"`
LastAttempt time.Time `json:"last_attempt,omitempty"`
NextRetry time.Time `dynamorm:"index:gsi-retry" json:"next_retry,omitempty"`
Status string `json:"status"`
ResponseCode int `json:"response_code,omitempty"`
ResponseBody string `json:"response_body,omitempty"`
CreatedAt time.Time `dynamorm:"created_at" json:"created_at"`
ExpiresAt time.Time `dynamorm:"ttl" json:"expires_at"`
}
Webhook represents a webhook delivery attempt