PlatformPaymentException constructor

PlatformPaymentException({
  1. required PlatformPaymentType type,
  2. String? errorCode,
  3. String? transactionId,
  4. double? amount,
  5. String? currency,
  6. String? userMessage,
  7. String? devMessage,
  8. Object? cause,
  9. StackTrace? stack,
  10. Map<String, dynamic> metadata = const {},
  11. Severity severity = Severity.error,
  12. bool isReportable = true,
})

Creates a payment exception tied to the specific provider type.

Implementation

PlatformPaymentException({
  required this.type,
  this.errorCode,
  this.transactionId,
  this.amount,
  this.currency,
  String? userMessage,
  String? devMessage,
  super.cause,
  super.stack,
  Map<String, dynamic> metadata = const {},
  super.severity,
  super.isReportable,
}) : super(
        userMessage: userMessage ?? '${type.displayName} payment failed.',
        devMessage:
            devMessage ?? '${type.displayName} payment failed: $errorCode',
        metadata: {
          'paymentType': type.name,
          if (errorCode != null) 'errorCode': errorCode,
          if (transactionId != null) 'transactionId': transactionId,
          if (amount != null) 'amount': amount,
          if (currency != null) 'currency': currency,
          ...metadata,
        },
      );