resumeSession method

SplitSession resumeSession(
  1. SplitSession session
)

Resumes a previously saved split session.

Use this to load a session that was saved via the "Save" action on the ReconciliationScreen so the user can continue payment later.

Implementation

SplitSession resumeSession(SplitSession session) {
  if (_currentSession != null && _currentSession!.hasSuccessfulPayments) {
    _logger?.error(
      this,
      'resumeSession: blocked — active session has '
      '${_currentSession!.successfulLegCount} successful leg(s)',
    );
    throw StateError(
      'Cannot resume session: there is already an active session with '
      '${_currentSession!.successfulLegCount} successful payment leg(s). '
      'Call discardSession() first.',
    );
  }
  _currentSession = session;
  _logger?.info(
    this,
    'resumeSession: restored — '
    'splitId=${session.splitId}, '
    'orderTotal=${session.orderTotal}, '
    'existingLegs=${session.paymentLegs.length}',
  );
  return _currentSession!;
}