stripeReceiptLines function

List<String> stripeReceiptLines(
  1. Map<String, dynamic> data,
  2. String? cardPaymentId
)

Stripe-cardPaymentData (Online-Zahlung via Payment-Link) als Anzeige-Zeilen. Gemeinsam fuer Druck (PrintPaper._stripe) und Beleg-Widget (_KeckReceiptWidgetState._stripePart), damit beide Pfade zwingend denselben Betrag/dieselben Kernwerte zeigen (siehe stripe_render_consistency_test.dart). Jedes Feld kann fehlen/null sein — die jeweilige Zeile wird dann einfach ausgelassen. receiptUrl wird nie gerendert.

Implementation

List<String> stripeReceiptLines(Map<String, dynamic> data, String? cardPaymentId) {
  final List<String> lines = [];
  final String? type = data['paymentMethodType']?.toString();

  if (type == 'card') {
    final String brandLine = _stripeCardBrandLine(data);
    if (brandLine.isNotEmpty) {
      lines.add(brandLine);
    }
    if (data['cardLastDigits'] != null) {
      lines.add('**** **** **** ${data['cardLastDigits']}');
    }
    if (data['threeDSecure'] == 'authenticated') {
      lines.add('3-D Secure: ja');
    }
  } else if (type == 'eps') {
    if (data['epsBank'] != null) {
      lines.add('EPS - ${_stripeEpsBankLabel(data['epsBank'].toString())}');
    }
  } else if (type != null) {
    lines.add(type.toUpperCase());
  }

  final dynamic amount = data['amount'];
  if (amount is int) {
    final String currency = data['currency']?.toString().toUpperCase() ?? 'EUR';
    lines.add('Gesamtbetrag ${formatCents(amount)} $currency');
  }

  final dynamic paidAt = data['paidAt'];
  if (paidAt is int) {
    lines.add('Bezahlt: ${_formatStripePaidAt(paidAt)}');
  }

  if (data['statementDescriptor'] != null) {
    lines.add('Abrechnung: ${data['statementDescriptor']}');
  }

  if (cardPaymentId != null) {
    lines.add('Referenz: $cardPaymentId');
  }

  return lines;
}