SplitPaymentService class

Business logic service for managing split payment sessions.

Handles session creation, payment leg recording, cumulative total calculations, and building the final cumulative PaymentResult.

Constructors

SplitPaymentService({LoggerService? logger, SplitPaymentApiClient? apiClient})
SplitPaymentService.withCoreLogger({SplitPaymentApiClient? apiClient})
Factory that resolves the logger from the DI container. Use this in production code (e.g. from the gateway).
factory

Properties

apiClient SplitPaymentApiClient?
Optional API client for backend communication. When provided, the service can fetch and synchronise state from the backend. In unit tests this can be omitted.
final
currentSession SplitSession?
The currently active split session, if any.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

buildCumulativeResult({required String businessId, required String userId, required String merchantId, String isoCurrencyCode = '', String shortCurrencyCode = ''}) → PaymentResult
Builds a cumulative PaymentResult summarising the entire split session.
discardSession({bool force = false}) → void
Clears the current session.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recordPaymentLeg({required PaymentResult result, required String paymentMethod, String? description, int? transactionNumber, String? customerId, String? customerName}) SplitSession
Records a payment leg result and returns the updated session.
resumeFromApiState(SplitPaymentStateResponse apiState) SplitSession
Resumes a session from a SplitPaymentStateResponse returned by the GetSplitPaymentState API.
resumeSession(SplitSession session) SplitSession
Resumes a previously saved split session.
startSession({required Decimal orderTotal, String? splitPaymentId, Decimal? explicitTipAmount}) SplitSession
Creates a new split payment session for the given order total.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited