store

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

func New(db *sql.DB, dialect kerneldatabase.Dialect, piiCipher *pii.Cipher) *Store

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

func (s *Store) EncryptPending(ctx context.Context, limit int) (int, error)

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) FindByID

func (s *Store) FindByID(ctx context.Context, id int64) (*paymentsdomain.Payment, error)

FindByID returns the payment record, or paymentsdomain.ErrPaymentNotFound.

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

func (s *Store) Insert(ctx context.Context, payment *paymentsdomain.Payment) (int64, error)

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

func (s *Store) ListByOrder(ctx context.Context, orderID int64) ([]paymentsdomain.Payment, error)

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.

func (*Store) SetStatus

func (s *Store) SetStatus(ctx context.Context, id int64, status paymentsdomain.Status, verifiedBy string) error

SetStatus flips the record to the given status, recording who decided it. An unknown record reads as paymentsdomain.ErrPaymentNotFound.

Jump to

Keyboard shortcuts

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