userMessage property

String get userMessage

Short, non-technical text safe to show to the paying user.

Implementation

String get userMessage => switch (this) {
  SwichPayNotInitializedException() =>
    'Payments are not available right now. Please try again later.',
  SwichPayValidationException(:final message) => message,
  SwichPayNetworkException() =>
    'Unable to connect. Please check your internet connection and try again.',
  SwichPayApiException(:final statusCode, :final serverMessage) =>
    switch (statusCode) {
      404 =>
        'This payment method is currently unavailable. Please try another method or try again later.',
      401 || 403 =>
        'This payment could not be authorized. Please contact the merchant.',
      408 || 429 || >= 500 =>
        'The payment service is temporarily unavailable. Please try again in a few minutes.',
      _ =>
        serverMessage ??
            'Something went wrong while processing your payment. Please try again.',
    },
};