LittleFish Payments Cloud POS

Cloud POS payment gateway package for push-to-terminal card payments via the Cloud POS backend API.

Overview

This package provides a self-contained payment gateway (CloudPOSPaymentGateway) that extends PaymentGateway<CloudPosProvider> from littlefish_payments. It enables card-present transactions by staging payments on the backend API and polling for terminal completion, without requiring a direct connection between the mobile device and the POS terminal.

Architecture

Mobile App
  -> CloudPOSPaymentGateway (this package)
    -> CloudPosApiClient (HTTP)
      -> Cloud POS Backend API (littlefish.CloudPos service)
        -> Terminal Manager
          -> Physical POS Terminal

The gateway:

  1. Stages a transaction via the backend API
  2. Polls for status updates (configurable interval and timeout)
  3. Returns a PaymentResult when the terminal reports approval, decline, or error
  4. Automatically abandons transactions that exceed the local timeout

Components

Gateway

  • CloudPOSPaymentGateway -- Extends PaymentGateway<CloudPosProvider>. Supports processPurchase, getTransactionInfo, and reversal. Exposes additional Cloud POS operations: retryTransaction, reassignTransaction.

Models

  • CloudPosProvider -- Extends PaymentProvider with cloudPosApiBaseUrl for API routing.
  • CloudPosTransaction -- Transaction model with status tracking and JSON serialization.
  • CloudPosTerminal -- Terminal DTO with terminalId, displayName, isOnline.
  • CloudPosTransactionStatus -- Enum with 8 states: staged, pendingOnTerminal, cardPresented, approved, declined, timedOut, error, abandoned. Includes isTerminal and isSuccessful helpers.

Services

  • CloudPosApiClient -- HTTP client with 6 API methods: stageTransaction, pollTransactionStatus, reassignTransaction, retryTransaction, abandonTransaction, listTerminals.

Presentation

  • CloudPosTerminalSelector -- Terminal picker widget with auto-selection for single-terminal merchants.
  • CloudPosProgressView -- Transaction progress display showing current status during polling.

Usage

import 'package:littlefish_payments_cloud_pos/littlefish_payments_cloud_pos.dart';

// 1. Create provider settings
final provider = CloudPosProvider(
  cloudPosApiBaseUrl: 'https://api.example.com',
);

// 2. Create and initialise gateway
final gateway = CloudPOSPaymentGateway();
await gateway.initialise(settings: provider);

// 3. Process a payment
final result = await gateway.processPurchase(
  amount: Decimal.parse('100.00'),
  reference: 'INV-001',
);

Dependencies

  • littlefish_payments ^8.1.3 -- Base gateway abstractions
  • littlefish_core ^6.1.2 -- Core service interfaces
  • littlefish_core_utils ^4.7.5 -- HTTP client utilities
  • decimal ^3.2.4 -- Monetary arithmetic
  • Phase 1 (Backend): littlefish.CloudPos service in littlefish_core_api (PR #192)
  • Implementation Plan: CPOS-PLAN_001 in littlefish_ai_planning

Libraries

gateway/cloud_pos_payment_gateway
littlefish_payments_cloud_pos
Cloud POS payment gateway package.
models/cloud_pos_provider
models/cloud_pos_status
models/cloud_pos_terminal
models/cloud_pos_transaction
presentation/bloc/terminal_list/cloud_pos_terminal_list_bloc
presentation/bloc/terminal_list/cloud_pos_terminal_list_event
presentation/bloc/terminal_list/cloud_pos_terminal_list_state
presentation/bloc/transaction/cloud_pos_transaction_bloc
presentation/bloc/transaction/cloud_pos_transaction_event
presentation/bloc/transaction/cloud_pos_transaction_state
presentation/cloud_pos_payment_page
presentation/cloud_pos_progress_view
presentation/cloud_pos_terminal_selector
presentation/components/app_bar/cloud_pos_custom_app_bar
presentation/components/bottom_controls
presentation/components/buttons/button_primary
presentation/components/buttons/button_secondary
presentation/components/cloud_pos_terminal_card
presentation/components/cloud_pos_terminal_tile
presentation/components/dialogs/exit_confirmation_dialog
presentation/components/layouts/cloud_pos_split_layout
presentation/components/scaffolds/cloud_pos_app_scaffold
presentation/components/search/cloud_pos_search_text_field
presentation/components/state_views/cloud_pos_error_view
presentation/components/state_views/cloud_pos_loading_view
presentation/components/state_views/cloud_pos_no_terminals_view
presentation/components/state_views/cloud_pos_pushing_sale_view
presentation/components/state_views/cloud_pos_single_terminal_confirmation_view
presentation/components/state_views/cloud_pos_transaction_failed_view
presentation/components/utilities/cloud_pos_form_factor
presentation/components/utilities/keyboard_dismissal_utility
presentation/models/cloud_pos_transaction_config
presentation/pages/cloud_pos_terminal_selection_page
presentation/theme/cloud_pos_typography
services/cloud_pos_api_client
services/cloud_pos_realtime_notifier
services/cloud_pos_terminal_status_notifier