feat: Square payment integration, booking flow redesign, and timezone/weekday fixes
- Add Square payment integration (mock + handlers + UI): terminal/online payments, refunds, tips, saved cards, webhooks. Build-tagged dev/prod clients. - Redesign booking flow: Step 4 conditional (deposit only), Step 5 confirmation screen with booking ID, auto-submit on transition. - Redesign schedule modal: 2x3 button grid with Pay Deposit/Pay Early logic. - Add deposit warning banner at Step 1 for users with outstanding deposits. - Fix weekday conversion bug: Go 0=Sunday vs DB 0=Monday mismatch in 6 locations. - Fix timezone bug: UTC vs London time in closing hours validation. - Fix frontend error parsing: plain text backend errors now displayed correctly. - Fix crypto.randomUUID fallback for environments without Web Crypto. - Add 7 new regression tests: closing hours, advance check, active booking limit, weekday conversion, UTC/London, deposit snapshot, exceptional hours. - Fix 3 flaky tests: dynamic dates instead of fixed, no-show timing.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package payments
|
||||
|
||||
import "errors"
|
||||
|
||||
// Valid payment types
|
||||
var validPaymentTypes = map[string]bool{
|
||||
"deposit": true,
|
||||
"full": true,
|
||||
"tip": true,
|
||||
"balance": true,
|
||||
"partial": true,
|
||||
}
|
||||
|
||||
// ValidateAmount checks that amount is greater than 0
|
||||
func ValidateAmount(amount int64) error {
|
||||
if amount <= 0 {
|
||||
return errors.New("amount must be greater than 0")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidatePaymentType checks that payment type is valid
|
||||
func ValidatePaymentType(pt string) error {
|
||||
if !validPaymentTypes[pt] {
|
||||
return errors.New("invalid payment type")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateRefundReason checks that refund reason is not empty
|
||||
func ValidateRefundReason(reason string) error {
|
||||
if reason == "" {
|
||||
return errors.New("refund reason is required")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateCardInfo checks that at least one of cardID or newCardToken is provided
|
||||
func ValidateCardInfo(cardID, newCardToken *string) error {
|
||||
if cardID == nil && (newCardToken == nil || *newCardToken == "") {
|
||||
return errors.New("either card_id or new_card_token is required")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user