ViewsCart & Checkout

Cart & Checkout

CartSlideOver

File: Views/Cart/CartSlideOver.swift

A slide-up cart view accessible from the cart button overlay on any tab.

Cart

Features

  • Item list: Each item shows name, modifiers, quantity, price
  • Quantity controls: Increment/decrement per item, remove if quantity reaches 0
  • Order summary: Subtotal, tax (8.5%), total
  • Stars earned: Total stars for this order
  • “Checkout” button: Opens CheckoutSheet
  • Empty state: Message when cart is empty

Cart Persistence

Cart data is saved to UserDefaults via CartStorageService with key staccato-cart. The cart survives app restarts.

CheckoutSheet

File: Views/Checkout/CheckoutSheet.swift

The final checkout flow presented as a sheet.

Steps

  1. Order Review: Final item list with totals
  2. Payment Selection: Choose payment method
  3. Tip Selection: Optional tip amount
  4. Confirm: Place order button

Payment Methods

MethodViewDescription
Apple PayApplePayButtonNative Apple Pay sheet via PassKit
CardCardEntryViewManual card number entry
Pay at Counter—No payment processing needed

Checkout Flow

  1. Customer reviews order and selects payment
  2. CheckoutViewModel.processCheckout():
    • Processes payment via SquarePaymentService
    • Creates order via OrderService.createOrder()
    • Awards stars to loyalty account
    • Syncs to Square POS (non-blocking)
    • Clears cart on success
  3. Shows success confirmation
  4. Dismisses sheet

CardEntryView

File: Views/Checkout/CardEntryView.swift

Manual card entry form with fields for:

  • Card number
  • Expiration date
  • CVV
  • ZIP code

ApplePayButton

File: Views/Checkout/ApplePayButton.swift

SwiftUI wrapper for PKPaymentButton that triggers the Apple Pay payment flow.