Payment Processing System - TableTheory Example
This example demonstrates payment-processing patterns with TableTheory: transactions, consistency, audit logging, error handling, merchant policy, and safe notification delivery. It is source/local-fixture code, not a provisioned payments product.
Why This Example Matters
This demonstrates:
- ✅ DynamoDB Transactions - ACID compliance for financial operations
- ✅ Consistency Patterns - Handle eventual consistency properly
- ✅ Audit Logging - Complete transaction history
- ✅ Error Handling - Example-grade error scenarios
- ✅ Testing Strategy - Complex business logic testing
- ✅ Security Patterns - Safe financial operations
Perfect for: learning payment-domain TableTheory patterns, financial systems, and advanced transaction usage
Merchant Policy and Delivery Safety
The process handler applies these rules before it reserves an idempotency key or
writes payment state:
- The stored merchant must exist and have
status: "active".
- The JWT must contain the exact permission
payments:write. Prefixes, casing
variants, and aliases do not match.
MaxPaymentAmount must be positive and the payment amount must not exceed it.
PaymentsPerMinute and PaymentsPerDay must both be positive.
Zero or negative limits are fail-closed: they deny positive payments and are not
an unlimited legacy mode. Minute and day usage counters are incremented with a
conditional ADD in the same DynamoDB transaction as the payment and
transaction records, so concurrent requests cannot overshoot. A merchant-policy
refusal before the idempotency reservation leaves no payment, transaction,
counter, webhook, or idempotency record behind. A rate-limit refusal rolls back
the payment, transaction, and counter writes and records the 429 against the
idempotency key for replay.
Idempotency keys are bound to a deterministic hash of the validated request
payload. Reusing a key with a different payload is refused with HTTP 409 before
any payment, transaction, counter, webhook, or idempotency write; legacy rows
without a stored hash fail closed the same way.
Merchant webhooks are public HTTPS only. The sender validates the URL and every
DNS answer before record creation, before each attempt, and on every redirect;
it dials the validated address and checks it again at the socket boundary.
Loopback, link-local, private, unspecified, site-local, 6bone, 6to4, IPv6
benchmarking, CGNAT, documentation, multicast, and reserved destinations
(including the deprecated 6to4 relay anycast prefix) are refused before request
bytes. There is no private-network or environment override.
Migration and Rollback
- Existing merchants with a zero or negative limit now fail closed. Configure
all three limits to positive values before enabling payments.
- Existing non-HTTPS or private-network webhook URLs stop receiving deliveries.
Move them to public HTTPS.
UsageCounters rows are additive and harmless if unused. Reverting the checks
restores the original exposure; roll forward with corrected policy rather than
restoring unsafe behavior.
- Idempotency rows written before request-hash binding have no stored hash and
fail closed with HTTP 409. Retry with a new idempotency key or wait for the
row to expire; the stored outcome cannot be verified.
- Payment, transaction, audit, idempotency, and webhook rows are not migrated or
deleted. Retain them through any rollback.
📋 Domain Models (CRITICAL for AI)
Account Model - Financial Account Management
// CANONICAL PATTERN: Financial account with audit fields
// AI NOTE: Use this EXACT pattern for financial accounts
package models
import "time"
type Account struct {
// REQUIRED: Partition key
ID string `theorydb:"pk" json:"id"`
// Account identification
AccountNumber string `theorydb:"sk" json:"account_number"`
// GSI for customer queries
CustomerID string `theorydb:"index:customer-index,pk" json:"customer_id"`
// GSI for status/type queries
Status string `theorydb:"index:status-index,pk" json:"status"`
AccountType string `theorydb:"index:status-index,sk" json:"account_type"`
// Financial fields (stored as cents to avoid float precision issues)
Balance int64 `json:"balance"` // Amount in cents
Currency string `json:"currency"` // USD, EUR, etc.
// Audit fields
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Version int `json:"version"` // Optimistic locking
}
// Business logic methods
func (a *Account) IsActive() bool {
return a.Status == "active"
}
func (a *Account) CanDebit(amount int64) bool {
return a.IsActive() && a.Balance >= amount
}
func (a *Account) FormatBalance() string {
return fmt.Sprintf("%.2f %s", float64(a.Balance)/100, a.Currency)
}
// AI NOTE: This account model follows financial best practices:
// - Store amounts as integers (cents) to avoid float precision issues
// - Include version field for optimistic locking
// - Separate status and type for different query patterns
// - Include comprehensive audit fields
Payment Model - Transaction Records
// CANONICAL PATTERN: Payment transaction with complete audit trail
// AI NOTE: Use this EXACT pattern for payment transactions
type Payment struct {
// REQUIRED: Partition key (unique payment ID)
ID string `theorydb:"pk" json:"id"`
// REQUIRED: Sort key (timestamp for ordering)
Timestamp string `theorydb:"sk" json:"timestamp"`
// GSI for customer payment history
CustomerID string `theorydb:"index:customer-index,pk" json:"customer_id"`
CreatedAt time.Time `theorydb:"index:customer-index,sk" json:"created_at"`
// GSI for merchant queries
MerchantID string `theorydb:"index:merchant-index,pk" json:"merchant_id"`
// GSI for status monitoring
Status string `theorydb:"index:status-index,pk" json:"status"`
// Payment details
Amount int64 `json:"amount"` // Amount in cents
Currency string `json:"currency"`
Description string `json:"description"`
// Account references
FromAccountID string `json:"from_account_id"`
ToAccountID string `json:"to_account_id"`
// Processing details
ProcessedAt *time.Time `json:"processed_at,omitempty"`
FailureReason string `json:"failure_reason,omitempty"`
// Audit fields
UpdatedAt time.Time `json:"updated_at"`
Version int `json:"version"`
}
// Payment status constants
const (
PaymentStatusPending = "pending"
PaymentStatusProcessed = "processed"
PaymentStatusFailed = "failed"
PaymentStatusCanceled = "canceled"
)
func (p *Payment) IsProcessed() bool {
return p.Status == PaymentStatusProcessed
}
func (p *Payment) CanCancel() bool {
return p.Status == PaymentStatusPending
}
// AI NOTE: This payment model includes:
// - Timestamp as sort key for chronological ordering
// - Multiple GSIs for different access patterns
// - Complete audit trail with status transitions
// - References to source and destination accounts
Audit Log Model - Complete Transaction History
// CANONICAL PATTERN: Audit log for financial compliance
// AI NOTE: Use this EXACT pattern for audit logging
type AuditLog struct {
// REQUIRED: Entity ID as partition key
EntityID string `theorydb:"pk" json:"entity_id"`
// REQUIRED: Timestamp as sort key for chronological order
Timestamp string `theorydb:"sk" json:"timestamp"`
// GSI for action type queries
Action string `theorydb:"index:action-index,pk" json:"action"`
// GSI for user activity tracking
UserID string `theorydb:"index:user-index,pk" json:"user_id"`
// Audit details
EntityType string `json:"entity_type"`
OldValues map[string]interface{} `json:"old_values,omitempty"`
NewValues map[string]interface{} `json:"new_values,omitempty"`
Changes []string `json:"changes"`
// Context information
IPAddress string `json:"ip_address,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
RequestID string `json:"request_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
// AI NOTE: Audit logs are CRITICAL for financial systems:
// - Every change must be recorded
// - Include both old and new values
// - Capture context for forensic analysis
// - Never delete audit records
💰 Core Payment Service (Production Pattern)
// CANONICAL PATTERN: Production payment service with comprehensive error handling
// AI NOTE: Use this EXACT pattern for financial services
package services
import (
"fmt"
"time"
"context"
"github.com/google/uuid"
"github.com/theory-cloud/tabletheory/v6/pkg/core"
"payment-system/models"
)
type PaymentService struct {
db core.DB
auditor AuditService
}
func NewPaymentService(db core.DB, auditor AuditService) *PaymentService {
return &PaymentService{
db: db,
auditor: auditor,
}
}
// CANONICAL PATTERN: Transfer funds with complete transaction safety
func (s *PaymentService) TransferFunds(ctx context.Context, req *TransferRequest) (*models.Payment, error) {
// Input validation
if err := req.Validate(); err != nil {
return nil, fmt.Errorf("invalid transfer request: %w", err)
}
// Create payment record
payment := &models.Payment{
ID: uuid.New().String(),
Timestamp: time.Now().Format(time.RFC3339),
CustomerID: req.CustomerID,
MerchantID: req.MerchantID,
Amount: req.Amount,
Currency: req.Currency,
Description: req.Description,
FromAccountID: req.FromAccountID,
ToAccountID: req.ToAccountID,
Status: models.PaymentStatusPending,
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
Version: 1,
}
// Load and validate accounts before composing the atomic writes.
var fromAccount models.Account
err := s.db.Model(&models.Account{}).
Where("ID", "=", req.FromAccountID).
ConsistentRead(). // Strong consistency for financial operations
First(&fromAccount)
if err != nil {
return nil, fmt.Errorf("source account not found: %w", err)
}
if !fromAccount.CanDebit(req.Amount) {
s.auditor.LogFailedTransfer(payment, "insufficient_funds")
return nil, fmt.Errorf("insufficient funds: available %d, requested %d",
fromAccount.Balance, req.Amount)
}
var toAccount models.Account
err = s.db.Model(&models.Account{}).
Where("ID", "=", req.ToAccountID).
ConsistentRead().
First(&toAccount)
if err != nil {
return nil, fmt.Errorf("destination account not found: %w", err)
}
if !toAccount.IsActive() {
s.auditor.LogFailedTransfer(payment, "inactive_destination")
return nil, fmt.Errorf("destination account is not active")
}
originalFromBalance := fromAccount.Balance
originalToBalance := toAccount.Balance
fromAccount.Balance -= req.Amount
fromAccount.UpdatedAt = time.Now()
toAccount.Balance += req.Amount
toAccount.UpdatedAt = time.Now()
payment.Status = models.PaymentStatusProcessed
payment.ProcessedAt = &time.Time{}
*payment.ProcessedAt = time.Now()
payment.UpdatedAt = time.Now()
// Execute the balance updates and payment creation atomically.
err = s.db.Transact().
Update(&fromAccount, []string{"Balance", "UpdatedAt"}).
Update(&toAccount, []string{"Balance", "UpdatedAt"}).
Create(payment).
Execute()
if err == nil {
s.auditor.LogAccountChange(ctx, &fromAccount, "balance_debited",
originalFromBalance, fromAccount.Balance)
s.auditor.LogAccountChange(ctx, &toAccount, "balance_credited",
originalToBalance, toAccount.Balance)
s.auditor.LogPaymentProcessed(ctx, payment)
}
if err != nil {
// Mark payment as failed
payment.Status = models.PaymentStatusFailed
payment.FailureReason = err.Error()
payment.UpdatedAt = time.Now()
// Save failed payment (outside transaction for audit)
s.db.Model(payment).Create()
s.auditor.LogFailedTransfer(payment, err.Error())
return nil, fmt.Errorf("transfer failed: %w", err)
}
return payment, nil
}
// CANONICAL PATTERN: Get payment with retry for eventual consistency
func (s *PaymentService) GetPayment(id string) (*models.Payment, error) {
var payment models.Payment
// Try main table first (strong consistency)
err := s.db.Model(&models.Payment{}).
Where("ID", "=", id).
ConsistentRead().
First(&payment)
if err == nil {
return &payment, nil
}
// If not found, it might be eventual consistency issue
// Retry with exponential backoff
maxRetries := 3
for i := 0; i < maxRetries; i++ {
time.Sleep(time.Duration(i*100) * time.Millisecond)
err = s.db.Model(&models.Payment{}).
Where("ID", "=", id).
First(&payment)
if err == nil {
return &payment, nil
}
}
return nil, fmt.Errorf("payment not found: %s", id)
}
// CANONICAL PATTERN: Get customer payments with pagination
func (s *PaymentService) GetCustomerPayments(customerID string, limit int, lastKey string) ([]models.Payment, string, error) {
query := s.db.Model(&models.Payment{}).
Index("customer-index").
Where("CustomerID", "=", customerID).
OrderBy("CreatedAt", "DESC").
Limit(limit)
if lastKey != "" {
query = query.StartFrom(lastKey)
}
var payments []models.Payment
err := query.All(&payments)
if err != nil {
return nil, "", fmt.Errorf("failed to get customer payments: %w", err)
}
var nextKey string
if len(payments) == limit {
lastPayment := payments[len(payments)-1]
nextKey = lastPayment.ID
}
return payments, nextKey, nil
}
type TransferRequest struct {
CustomerID string `json:"customer_id"`
MerchantID string `json:"merchant_id"`
FromAccountID string `json:"from_account_id"`
ToAccountID string `json:"to_account_id"`
Amount int64 `json:"amount"`
Currency string `json:"currency"`
Description string `json:"description"`
}
func (r *TransferRequest) Validate() error {
if r.Amount <= 0 {
return errors.New("amount must be positive")
}
if r.FromAccountID == "" {
return errors.New("from_account_id is required")
}
if r.ToAccountID == "" {
return errors.New("to_account_id is required")
}
if r.FromAccountID == r.ToAccountID {
return errors.New("cannot transfer to same account")
}
if r.Currency == "" {
return errors.New("currency is required")
}
return nil
}
// AI NOTE: This payment service includes ALL production requirements:
// 1. Input validation with detailed error messages
// 2. Optimistic locking to prevent concurrent modifications
// 3. Strong consistency for financial operations
// 4. Complete audit trail for compliance
// 5. Proper error handling and rollback
// 6. Retry logic for eventual consistency
// 7. Pagination for large result sets
🚀 Lambda Integration (Production Pattern)
// CANONICAL PATTERN: Production Lambda handler for payment processing
// AI NOTE: Use this EXACT pattern for Lambda payment handlers
package main
import (
"context"
"encoding/json"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/theory-cloud/tabletheory/v6"
"payment-system/models"
"payment-system/services"
)
// Global variables for connection reuse
var (
db *tabletheory.LambdaDB
paymentService *services.PaymentService
auditService *services.AuditService
)
func init() {
// CRITICAL: Initialize once, reuse across invocations
var err error
db, err = tabletheory.NewLambdaOptimized()
if err != nil {
panic(fmt.Sprintf("Failed to initialize TableTheory: %v", err))
}
// Pre-register models to reduce cold start time
err = db.PreRegisterModels(
&models.Payment{},
&models.Account{},
&models.AuditLog{},
)
if err != nil {
panic(fmt.Sprintf("Failed to register models: %v", err))
}
// Initialize services
auditService = services.NewAuditService(db)
paymentService = services.NewPaymentService(db, auditService)
}
func handler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
// Parse request
var transferReq services.TransferRequest
if err := json.Unmarshal([]byte(request.Body), &transferReq); err != nil {
return events.APIGatewayProxyResponse{
StatusCode: 400,
Headers: map[string]string{
"Content-Type": "application/json",
},
Body: `{"error": "Invalid request body"}`,
}, nil
}
// Add request context for audit
ctx = context.WithValue(ctx, "request_id", request.RequestContext.RequestID)
ctx = context.WithValue(ctx, "ip_address", request.RequestContext.Identity.SourceIP)
ctx = context.WithValue(ctx, "user_agent", request.Headers["User-Agent"])
// Process payment
payment, err := paymentService.TransferFunds(ctx, &transferReq)
if err != nil {
// Log error for monitoring
auditService.LogSecurityEvent(ctx, &services.SecurityEvent{
EventType: "payment_error",
Details: map[string]interface{}{
"error": err.Error(),
"request": transferReq,
},
Severity: "high",
})
return events.APIGatewayProxyResponse{
StatusCode: 400,
Headers: map[string]string{
"Content-Type": "application/json",
},
Body: fmt.Sprintf(`{"error": "%s"}`, err.Error()),
}, nil
}
// Return success response
responseBody, _ := json.Marshal(payment)
return events.APIGatewayProxyResponse{
StatusCode: 201,
Headers: map[string]string{
"Content-Type": "application/json",
},
Body: string(responseBody),
}, nil
}
func main() {
lambda.Start(handler)
}
// AI NOTE: This Lambda pattern includes:
// 1. Pre-initialized connections for performance
// 2. Model pre-registration for cold start optimization
// 3. Request context propagation for audit trails
// 4. Comprehensive error handling and logging
// 5. Proper HTTP response formatting
🧪 Testing Production Payment Logic
// CANONICAL PATTERN: Testing financial logic with comprehensive scenarios
// AI NOTE: Use this EXACT pattern for testing financial services
package services
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/theory-cloud/tabletheory/v6/pkg/mocks"
"payment-system/models"
)
func TestPaymentService_TransferFunds_Success(t *testing.T) {
// CANONICAL PATTERN: Test successful transfer
mockDB := new(mocks.MockDB)
mockTx := new(mocks.MockTx)
mockQuery := new(mocks.MockQuery)
mockAuditor := new(MockAuditService)
// Set up source account
sourceAccount := &models.Account{
ID: "acc1",
Balance: 10000, // $100.00
Status: "active",
Version: 1,
}
// Set up destination account
destAccount := &models.Account{
ID: "acc2",
Balance: 5000, // $50.00
Status: "active",
Version: 1,
}
// Mock the strongly-consistent account reads before the transaction.
mockDB.On("Model", mock.AnythingOfType("*models.Account")).Return(mockQuery)
mockQuery.On("Where", "ID", "=", "acc1").Return(mockQuery)
mockQuery.On("ConsistentRead").Return(mockQuery)
mockQuery.On("First", mock.AnythingOfType("*models.Account")).
Run(func(args mock.Arguments) {
acc := args.Get(0).(*models.Account)
*acc = *sourceAccount
}).Return(nil)
mockQuery.On("Where", "ID", "=", "acc2").Return(mockQuery)
mockQuery.On("First", mock.AnythingOfType("*models.Account")).
Run(func(args mock.Arguments) {
acc := args.Get(0).(*models.Account)
*acc = *destAccount
}).Return(nil)
// Mock the atomic transaction builder.
txBuilder := new(mocks.MockTransactionBuilder)
mockDB.On("Transact").Return(txBuilder)
txBuilder.On("Update", mock.AnythingOfType("*models.Account"), []string{"Balance", "UpdatedAt"}, mock.Anything).Return(txBuilder)
txBuilder.On("Create", mock.AnythingOfType("*models.Payment"), mock.Anything).Return(txBuilder)
txBuilder.On("Execute").Return(nil)
// Mock audit calls
mockAuditor.On("LogAccountChange", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything)
mockAuditor.On("LogPaymentProcessed", mock.Anything, mock.Anything)
// Test the service
service := NewPaymentService(mockDB, mockAuditor)
request := &TransferRequest{
CustomerID: "cust1",
MerchantID: "merch1",
FromAccountID: "acc1",
ToAccountID: "acc2",
Amount: 2000, // $20.00
Currency: "USD",
Description: "Test transfer",
}
payment, err := service.TransferFunds(context.Background(), request)
// Verify results
assert.NoError(t, err)
assert.NotNil(t, payment)
assert.Equal(t, models.PaymentStatusProcessed, payment.Status)
assert.Equal(t, request.Amount, payment.Amount)
assert.NotNil(t, payment.ProcessedAt)
// Verify all expectations
mockDB.AssertExpectations(t)
mockAuditor.AssertExpectations(t)
}
func TestPaymentService_TransferFunds_InsufficientFunds(t *testing.T) {
// CANONICAL PATTERN: Test business rule validation
mockDB := new(mocks.MockDB)
mockQuery := new(mocks.MockQuery)
mockAuditor := new(MockAuditService)
// Source account with insufficient funds
sourceAccount := &models.Account{
ID: "acc1",
Balance: 1000, // $10.00 - insufficient for $20.00 transfer
Status: "active",
Version: 1,
}
mockDB.On("Model", mock.AnythingOfType("*models.Account")).Return(mockQuery)
mockQuery.On("Where", "ID", "=", "acc1").Return(mockQuery)
mockQuery.On("ConsistentRead").Return(mockQuery)
mockQuery.On("First", mock.AnythingOfType("*models.Account")).
Run(func(args mock.Arguments) {
acc := args.Get(0).(*models.Account)
*acc = *sourceAccount
}).Return(nil)
// Mock failed payment creation (outside transaction)
mockDB.On("Model", mock.AnythingOfType("*models.Payment")).Return(mockQuery)
mockQuery.On("Create").Return(nil)
mockAuditor.On("LogFailedTransfer", mock.Anything, "insufficient_funds")
service := NewPaymentService(mockDB, mockAuditor)
request := &TransferRequest{
FromAccountID: "acc1",
ToAccountID: "acc2",
Amount: 2000, // $20.00
Currency: "USD",
}
payment, err := service.TransferFunds(context.Background(), request)
// Verify failure handling
assert.Error(t, err)
assert.Nil(t, payment)
assert.Contains(t, err.Error(), "insufficient funds")
mockDB.AssertExpectations(t)
mockAuditor.AssertExpectations(t)
}
// AI NOTE: This testing approach covers ALL critical scenarios:
// 1. Successful transfer with proper balance updates
// 2. Business rule violations (insufficient funds)
// 3. Concurrent modification detection
// 4. Audit logging verification
// 5. Error propagation and handling
// 6. Transaction rollback behavior
🚨 Common Mistakes in Payment Systems
❌ Financial Logic Mistakes
// WRONG: Using floats for money
type BadPayment struct {
Amount float64 `json:"amount"` // WRONG: Precision issues
}
// CORRECT: Use integers (cents)
type GoodPayment struct {
Amount int64 `json:"amount"` // Store as cents
}
// WRONG: No optimistic locking
account.Balance -= amount
db.Model(account).Update() // WRONG: Race condition
// CORRECT: Version-based locking
account.Balance -= amount
account.Version++
db.Model(account).Where("Version", "=", account.Version-1).Update()
❌ Transaction Mistakes
// WRONG: Separate operations (not atomic)
db.Model(fromAccount).Update() // Might succeed
db.Model(toAccount).Update() // Might fail - inconsistent state!
// CORRECT: Single DynamoDB transaction
err := db.Transact().
Update(fromAccount, []string{"Balance", "UpdatedAt"}).
Update(toAccount, []string{"Balance", "UpdatedAt"}).
Execute()
❌ Consistency Mistakes
// WRONG: Eventual consistency for financial reads
db.Model(&Account{}).Where("ID", "=", id).First(&account) // Might be stale
// CORRECT: Strong consistency for financial operations
db.Model(&Account{}).Where("ID", "=", id).ConsistentRead().First(&account)
🔧 Development Commands
# Unit/policy/fixture tests (no Docker required)
go test ./examples/payment/...
go test -race ./examples/payment/...
# Benchmarks (the benchmark suite expects a local DynamoDB endpoint)
go test ./examples/payment/tests -bench=.
# Start DynamoDB Local when a real endpoint is needed
make docker-up
This example does not ship deployment commands, merchant provisioning, or a
production environment. Any deployment is a separate, explicitly reviewed piece
of work.
The numbers below are illustrative targets from the example, not production
proof:
| Operation |
Performance |
Target |
| Payment Creation |
20,000/sec |
< 50ms |
| Account Balance Check |
50,000/sec |
< 10ms |
| Transaction Query |
1,000/sec |
< 200ms |
| Audit Log Creation |
25,000/sec |
< 25ms |
Running Benchmarks
# Run the checked-in payment benchmarks
go test ./examples/payment/tests -bench=. -benchmem
# Generate a profile for one benchmark
go test ./examples/payment/tests -bench=BenchmarkPaymentCreate -cpuprofile=cpu.prof
🔐 Security and Compliance
// CANONICAL PATTERN: Security-focused audit service
const (
// PCI DSS compliance
MaxFailedAttempts = 3
AccountLockDuration = 30 * time.Minute
// AML requirements
LargeTransactionThreshold = 1000000 // $10,000.00 in cents
SuspiciousVelocityThreshold = 5 // 5 transactions per minute
// Data retention
AuditLogRetentionDays = 2555 // 7 years
TransactionRetentionDays = 2555
)
// Compliance monitoring
func (s *PaymentService) checkCompliance(payment *models.Payment) {
// Large transaction alert
if payment.Amount >= LargeTransactionThreshold {
s.alertManager.SendAlert("large_transaction", payment)
}
// Velocity check
recentCount := s.getRecentTransactionCount(payment.CustomerID, 1*time.Minute)
if recentCount >= SuspiciousVelocityThreshold {
s.alertManager.SendAlert("suspicious_velocity", payment)
}
}
➡️ Next Steps
After mastering payment processing:
- Multi-tenant SaaS - Enterprise patterns
- Feature Spotlights - Advanced transactions/BatchGet flows
- Lambda Deployment - Serverless payment processing
This payment example demonstrates TableTheory patterns for financial applications with audit trails, merchant policy, and secure notification delivery. It is source/local-fixture evidence, not a deployed or provisioned payments product.