Round-A fresh review (6 agents) + fix + secondary cross-cutting + verification rounds: - F1: campaign discounts reduce the charged amount (deposit credit + admin PaymentModal discounted total); capDiscountToRemainingObligation prevents over-credit at completion in all four campaign blocks - F2: sweep replay rescue distinguishes legitimate same-key retries (21h window) from expired-key new charges; ccof blind-fails leave pending + CRITICAL instead of clawing back - F3: post-start online overflow carved as a tip record (mirrors terminal split builder) - A1: single-source Square decline-code classification (till delegates to square.IsDefinitivePaymentError) - A2/A5: refund attempt-cap literals consolidated; refund-failure counter capped + reset on terminal resolutions + admin notifications - A3/A9: idempotency helpers adopted across derivations; IsExplicitDevOrMockEnv relocated + all gates unified (incl. health-check) - A7: 2FA user+IP limiter + TRUST_PROXY_HEADERS startup warning; SNAPSHOT_ENC_KEY startup validation; TWO_FACTOR_PEPPER docs corrected - A8: snapshot encryption on all 6 write sites + marker-aware reuse paths; MPV->SPV effective voucher type (single VAT point) - A10/A11/A12/A16: gift-card slot scan advances past failed; amount-aware refund reconciliation; completed-booking refund re-check; PaymentWasRefunded on SquareClient interface - Dedup refund revalidation on tip/terminal/gift-card paths; sweep acknowledged_at IS NULL parity; refund-notification single source (exported payments.InsertRefundFailedNotifications) - Duplication/modularisation round: shared frontend helpers (sanitizeDecimalInput, campaignDiscountCents, twoFactorBlocksSavedCards getter, generateUUID), single-source MaxIdempotencyKeyLength, notification-helper consolidation, snapshot-guard comments - Cross-cutting GBP rename: Cents->Pence across backend + frontend + tests (26 identifiers, 16 files) - Tests: 11 behavior-change tests updated to new invariants; coverage for fixed functions; frontend vitest 55 tests; docs corrected (test counts, 2FA delivery, pre-launch checklist, resolution status) - gitleaks: allowlist backend/internal/square test fixtures (mock idempotency keys) All 25 backend packages pass; frontend 55/55 + build clean; env-docs 41/41.
31 lines
1020 B
Go
31 lines
1020 B
Go
package payments
|
|
|
|
import "time"
|
|
|
|
const (
|
|
FullRefundThreshold = 72 * time.Hour
|
|
PartialRefundThreshold = 24 * time.Hour
|
|
NoShowThreshold = 24 * time.Hour
|
|
DepositDeadlineWindow = 24 * time.Hour
|
|
DepositAdvanceWindow = 36 * time.Hour
|
|
|
|
FullRefundTier = "full_refund_72h"
|
|
PartialRefundTier = "partial_refund_24h_72h"
|
|
NoRefundTier = "no_refund_under_24h"
|
|
|
|
ProtectedDepositMaxPct = 0.50
|
|
RequiredDepositPct = 0.20
|
|
|
|
// depositPromotionMinPct is the share of the booking total a payment must
|
|
// cover before a pending_release booking is promoted back to 'confirmed'
|
|
// (A10) — the deposit-promotion threshold in the CreateBookingPayment
|
|
// deposit-promotion query. Named separately from RequiredDepositPct (the
|
|
// deposit REQUIRED at booking time, used by bookings.go): the promotion
|
|
// threshold is about already-paid money, not the amount to demand up front,
|
|
// even though both are 20% today.
|
|
depositPromotionMinPct = 0.2
|
|
|
|
LoyaltyStampCost = 10
|
|
LoyaltyDiscountPercent = 10.0
|
|
)
|