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:
- Stages a transaction via the backend API
- Polls for status updates (configurable interval and timeout)
- Returns a
PaymentResultwhen the terminal reports approval, decline, or error - Automatically abandons transactions that exceed the local timeout
Components
Gateway
CloudPOSPaymentGateway-- ExtendsPaymentGateway<CloudPosProvider>. SupportsprocessPurchase,getTransactionInfo, andreversal. Exposes additional Cloud POS operations:retryTransaction,reassignTransaction.
Models
CloudPosProvider-- ExtendsPaymentProviderwithcloudPosApiBaseUrlfor API routing.CloudPosTransaction-- Transaction model with status tracking and JSON serialization.CloudPosTerminal-- Terminal DTO withterminalId,displayName,isOnline.CloudPosTransactionStatus-- Enum with 8 states:staged,pendingOnTerminal,cardPresented,approved,declined,timedOut,error,abandoned. IncludesisTerminalandisSuccessfulhelpers.
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 abstractionslittlefish_core^6.1.2 -- Core service interfaceslittlefish_core_utils^4.7.5 -- HTTP client utilitiesdecimal^3.2.4 -- Monetary arithmetic
Related
- Phase 1 (Backend):
littlefish.CloudPosservice inlittlefish_core_api(PR #192) - Implementation Plan:
CPOS-PLAN_001inlittlefish_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/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