Documentation
¶
Overview ¶
Package store is the single-source payment record repository: one implementation against *sql.DB plus a kernel Dialect, following the orders store pattern. Placeholder rendering comes from the dialect; everything else (columns, scans, messages) is shared.
Index ¶
- type Store
- func (s *Store) EncryptPending(ctx context.Context, limit int) (int, error)
- func (s *Store) FindByID(ctx context.Context, id int64) (*paymentsdomain.Payment, error)
- func (s *Store) FindByReference(ctx context.Context, reference string) (*paymentsdomain.Payment, error)
- func (s *Store) Insert(ctx context.Context, payment *paymentsdomain.Payment) (int64, error)
- func (s *Store) List(ctx context.Context, status *paymentsdomain.Status, beforeID int64, limit int) ([]paymentsdomain.Payment, error)
- func (s *Store) ListByOrder(ctx context.Context, orderID int64) ([]paymentsdomain.Payment, error)
- func (s *Store) SetStatus(ctx context.Context, id int64, status paymentsdomain.Status, verifiedBy string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the payment record single-source store. The reference and verifier identity are encrypted at this boundary: writes seal them through the cipher and reads open them, while webhook dedup resolves through the blind-index column over the reference. A nil cipher stores and reads plaintext (legacy mode); the startup sweep encrypts those rows once a key is provisioned.
func New ¶
New builds the store over an open database, its dialect, and the PII cipher. A nil cipher stores and reads plaintext (legacy mode); a set cipher seals the reference and verifier identity on write and resolves webhook dedup through the blind-index column.
func (*Store) EncryptPending ¶
EncryptPending encrypts up to limit legacy plaintext rows in place and fills their blind-index columns, returning how many rows changed. The startup backfill sweep calls it in batches until it reports zero: a second boot is a no-op because enveloped rows no longer match the sweep predicate. A nil cipher encrypts nothing and reports zero. Fields already carrying the envelope are left untouched, so concurrent sweeps converge instead of double-encrypting.
func (*Store) FindByReference ¶
func (s *Store) FindByReference(ctx context.Context, reference string) (*paymentsdomain.Payment, error)
FindByReference returns the record carrying the gateway transaction reference, or paymentsdomain.ErrPaymentNotFound. An empty reference never matches: empty plaintext leaves the blind-index column empty, so querying it could hit an unrelated empty-index row.
func (*Store) Insert ¶
Insert persists one submitted payment record: the storage identity and timestamps fill the struct before return.
func (*Store) List ¶
func (s *Store) List(ctx context.Context, status *paymentsdomain.Status, beforeID int64, limit int) ([]paymentsdomain.Payment, error)
List returns the newest payment records carrying the given status (nil is any), strictly below the keyset boundary (0 means from the newest), at most limit rows.
func (*Store) ListByOrder ¶
ListByOrder returns every record paying one order, newest first. Order histories are short — a handful of proofs and at most one gateway row — so the read carries no pagination.