littlefish_payments_cloud_pos 2.4.5
littlefish_payments_cloud_pos: ^2.4.5 copied to clipboard
Cloud POS payment gateway — enables push-to-terminal card payments via the Cloud POS API. Self-contained package with API client, polling, and UI.
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