mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
package processor
|
|
|
|
import "testing"
|
|
|
|
// Settled is the one definition of "money was actually taken", shared by the
|
|
// charge path and the inbound webhook path. This pins the contract directly, so
|
|
// a change to it is a deliberate act rather than a side effect.
|
|
func TestSettled(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
status string
|
|
want bool
|
|
}{
|
|
{"COMPLETED", true},
|
|
{"CAPTURED", true},
|
|
{"completed", true}, // processors disagree on casing
|
|
{" COMPLETED ", true},
|
|
|
|
// APPROVED is an authorization hold: reserved, not taken. It can still be
|
|
// voided or expire, and a card-verification pre-auth is exactly that shape
|
|
// — authorized, then deliberately voided. Crediting it mints balance
|
|
// against money that may never arrive.
|
|
{"APPROVED", false},
|
|
{"approved", false},
|
|
|
|
{"PENDING", false},
|
|
{"CANCELED", false},
|
|
{"FAILED", false},
|
|
{"", false},
|
|
{"nonsense", false},
|
|
} {
|
|
if got := Settled(tc.status); got != tc.want {
|
|
t.Errorf("Settled(%q) = %v, want %v", tc.status, got, tc.want)
|
|
}
|
|
}
|
|
}
|