Payment and refund detail
Show a confirmed payment and its refund. The original payment keeps its success and amount in every refund state. The refund is a separate section with its own status, amount and masked reference, all from the host. The person can ask for a newer refund status and open a read-only receipt.




Run and try
Section titled “Run and try”From example/:
flutter run -d <device-id> -t lib/refund_detail_demo.dartTap Perbarui status refund: the synthetic host moves the refund from pending to partial. Tap Lihat struk for the receipt. The developer menu offers Refund penuh (the refund completes for the whole amount) and Cek refund gagal (the first refresh fails, the last known refund status stays and the next refresh succeeds). Changing a scenario starts a fresh synthetic session.
Composition and boundaries
Section titled “Composition and boundaries”PaymentRefundDetail takes the host’s TransactionRecord with its RefundInfo
and callbacks for refreshing and copying. PaymentRefundReceiptSheet shows the
host’s PaymentReceiptData. The refresh action disappears once the refund is
final.
| UI | Existing library surface |
|---|---|
| Original payment, refund section and copy | TransactionDetail, TransactionRecord, RefundInfo |
| Receipt sheet | PaymentReceipt, PaymentReceiptData, PaymentSheet (opened by the host with showPaymentSheet) |
| Pinned actions and refresh failure | PaymentFullPageView, PaymentBanner |
This block never starts, edits or cancels a refund. The host owns refund requests, their status, masking and the clipboard. All records are fictional. See the transaction history pattern and the status and receipt pattern.
Source
Section titled “Source”Source: compositions/payment_refund_detail.dart
Open this file on GitHub. Copy and adapt it in your host app.
import 'package:flutter/material.dart';import 'package:rakit_ui/rakit_ui.dart';
/// Copyable host composition: a confirmed payment with its refund lifecycle.////// The original payment keeps its success and amount in every refund state;/// the refund is a separate section whose status, amount and reference come/// from the host. The person can ask the host for a newer refund status and/// open a read-only receipt. This block never starts, edits or cancels a/// refund.class PaymentRefundDetail extends StatelessWidget { const PaymentRefundDetail({ super.key, required this.record, required this.refundReference, required this.onViewReceipt, required this.onCopyReference, this.onRefreshRefund, this.refreshing = false, this.refreshError, });
/// The original payment as the host confirmed it, with its refund. final TransactionRecord record;
/// Already masked by the host, e.g. "RF-•••-4821". final String refundReference; final VoidCallback onViewReceipt;
/// Host clipboard for the payment reference: false when copying failed. final Future<bool> Function(String reference) onCopyReference;
/// Asks the host for a newer refund status; null once the refund is final. final Future<void> Function()? onRefreshRefund; final bool refreshing;
/// Shown above the detail; the last known refund status stays in place. final String? refreshError;
@override Widget build(BuildContext context) { final theme = PaymentTheme.of(context); final receipt = PaymentButton( label: 'Lihat struk', variant: onRefreshRefund == null ? PaymentButtonVariant.primary : PaymentButtonVariant.quiet, // The sheet stays open while its Future runs; keep the button idle. onPressed: () { onViewReceipt(); }, ); return PaymentFullPageView( title: 'Detail pembayaran', primaryAction: onRefreshRefund == null ? receipt : PaymentButton( label: 'Perbarui status refund', busy: refreshing, busyLabel: 'Memeriksa refund…', onPressed: onRefreshRefund, ), secondaryAction: onRefreshRefund == null ? null : receipt, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ if (refreshError != null) ...[ PaymentBanner( tone: StatusTone.neutral, icon: Icons.cloud_off_outlined, title: 'Status refund belum diperbarui', message: refreshError, ), SizedBox(height: theme.space(PaymentSpace.group)), ], TransactionDetail(record: record, onCopyReference: onCopyReference), SizedBox(height: theme.space(PaymentSpace.related)), PaymentPropertyList( items: [ PaymentPropertyListItem( label: 'Referensi refund', valueText: refundReference, reference: true, ), ], ), ], ), ); }}
/// Read-only receipt for the original payment, opened in a sheet.class PaymentRefundReceiptSheet extends StatelessWidget { const PaymentRefundReceiptSheet({ super.key, required this.data, required this.onClose, }); final PaymentReceiptData data; final VoidCallback onClose;
@override Widget build(BuildContext context) => PaymentSheet( header: PaymentSheetHeader(title: 'Struk pembayaran', onClose: onClose), // No share or copy here: the host offers only effects it implements. body: PaymentReceipt(data: data), footer: PaymentButton( label: 'Tutup', variant: PaymentButtonVariant.secondary, onPressed: onClose, ), );}Source: refund_detail_demo.dart
Open this file on GitHub. Copy and adapt it in your host app.
import 'package:flutter/material.dart';import 'package:rakit_ui/rakit_ui.dart';
import 'block_demo_shell.dart';import 'compositions/payment_refund_detail.dart';
void main() => runBlockDemo(const RefundDetailDemo());
enum RefundDemoScenario { partial, full, refreshFails }
final refundPaidAt = DateTime(2026, 11, 3, 15, 10);const refundOriginalAmount = Money.idr(240000);
/// Synthetic refund host. Refund states are declared fixture answers; the/// demo never initiates a refund and calls no network.class RefundDetailDemo extends StatefulWidget { const RefundDetailDemo({ super.key, this.initialScenario = RefundDemoScenario.partial, this.initialDark = false, this.delay = const Duration(milliseconds: 500), }); final RefundDemoScenario initialScenario; final bool initialDark; final Duration delay;
@override State<RefundDetailDemo> createState() => _RefundDetailDemoState();}
class _RefundDetailDemoState extends State<RefundDetailDemo> { late bool dark = widget.initialDark; late RefundDemoScenario scenario = widget.initialScenario; late RefundInfo refund = requested; bool refreshing = false; String? refreshError; int refreshes = 0; int generation = 0;
Money get requestedAmount => scenario == RefundDemoScenario.full ? refundOriginalAmount : const Money.idr(50000);
RefundInfo get requested => RefundInfo( status: RefundStatus.pending, amount: requestedAmount, updatedAt: DateTime(2026, 11, 4, 9, 15), safeReason: 'Merchant menyetujui refund. Bank biasanya memproses dalam ' '3–7 hari kerja.', );
bool get settled => refund.status == RefundStatus.partial || refund.status == RefundStatus.refunded;
void reset(RefundDemoScenario value) => setState(() { generation++; scenario = value; refund = requested; refreshing = false; refreshError = null; refreshes = 0; });
Future<void> refresh() async { if (refreshing) return; final current = generation; final count = ++refreshes; setState(() { refreshing = true; refreshError = null; }); await Future<void>.delayed(widget.delay); if (!mounted || current != generation) return; setState(() { refreshing = false; if (scenario == RefundDemoScenario.refreshFails && count == 1) { refreshError = 'Menampilkan status terakhir yang diketahui. Coba lagi nanti.'; return; } refund = RefundInfo( status: scenario == RefundDemoScenario.full ? RefundStatus.refunded : RefundStatus.partial, amount: requestedAmount, updatedAt: DateTime(2026, 11, 4, 10, 42), safeReason: 'Dana dikembalikan ke rekening asal pembayaran.', ); }); }
TransactionRecord get record => TransactionRecord( id: 'INV-2044', title: 'Paket Belajar Pro', merchant: 'Ruang Bayar Akademi', reference: 'TX-DEMO-55302044', amount: refundOriginalAmount, createdAt: refundPaidAt, methodLabel: 'Transfer •••• 2190', // The original payment stays succeeded in every refund state. status: PaymentStatus.succeeded, refund: refund, );
@override Widget build(BuildContext context) => BlockDemoShell( title: 'Refund · Demo', dark: dark, onToggleDark: () => setState(() => dark = !dark), scenarios: [ for (final (value, label) in [ (RefundDemoScenario.partial, 'Refund sebagian'), (RefundDemoScenario.full, 'Refund penuh'), (RefundDemoScenario.refreshFails, 'Cek refund gagal'), ]) (label: label, onSelected: () => reset(value)), ], body: (context) => PaymentRefundDetail( key: ValueKey(generation), record: record, refundReference: 'RF-•••-4821', refreshing: refreshing, refreshError: refreshError, onRefreshRefund: settled ? null : refresh, onCopyReference: copyToClipboard, onViewReceipt: () => showPaymentSheet<void>( context: context, builder: (sheet) => PaymentRefundReceiptSheet( data: PaymentReceiptData( transactionId: record.reference!, merchantName: record.merchant!, paidAt: refundPaidAt, lines: const [ QuoteLine(label: 'Paket Belajar Pro', amount: Money.idr(236000)), QuoteLine( label: 'Biaya bank', amount: Money.idr(4000), kind: QuoteLineKind.fee, ), ], total: refundOriginalAmount, methodLabel: record.methodLabel!, refund: refund, ), onClose: () => Navigator.pop(sheet), ), ), ), );}Source: block_demo_shell.dart
Open this file on GitHub. Copy and adapt it in your host app.
import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:flutter_localizations/flutter_localizations.dart';import 'package:rakit_ui/rakit_ui.dart';
import 'themes.dart';
/// Starts a block demo edge-to-edge, as the shipped checkout demo does.void runBlockDemo(Widget app) { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); runApp(app);}
/// The example host's clipboard effect. It reports the real outcome and never/// claims a copy that did not happen. The kit itself never touches the/// clipboard (B11).Future<bool> copyToClipboard(String value) async { try { await Clipboard.setData(ClipboardData(text: value)); return true; } on PlatformException { return false; }}
/// One developer scenario in the demo menu. Choosing it restarts the/// synthetic session; it is never an end-user action.typedef DemoScenario = ({String label, VoidCallback onSelected});
/// Ordinary phone host chrome shared by the block demos: app themes, Indonesian/// localization, D85 system-bar styling, a light/dark switch and a developer/// scenario menu. It is example scaffolding, not a block runtime: copy the/// composition under `compositions/` and keep your own app shell.class BlockDemoShell extends StatelessWidget { const BlockDemoShell({ super.key, required this.title, required this.dark, required this.onToggleDark, required this.body, this.scenarios = const [], this.lightTheme, this.darkTheme, this.locale = const Locale('id'), this.textScale, });
final String title; final bool dark; final VoidCallback onToggleDark; final List<DemoScenario> scenarios;
/// Optional illustrative host themes; the payment demos use Ruang Bayar. final ThemeData? lightTheme; final ThemeData? darkTheme;
/// Host locale for this synthetic demo. final Locale locale;
/// Optional fixed text scale for accessibility captures; null follows the /// device setting. final double? textScale;
/// Built below the Scaffold, so sheets and toasts find their ancestors. final WidgetBuilder body;
@override Widget build(BuildContext context) => MaterialApp( debugShowCheckedModeBanner: false, theme: lightTheme ?? buildTheme(DemoBrand.ruangBayar, Brightness.light), darkTheme: darkTheme ?? buildTheme(DemoBrand.ruangBayar, Brightness.dark), themeMode: dark ? ThemeMode.dark : ThemeMode.light, locale: locale, supportedLocales: const [Locale('id'), Locale('en')], localizationsDelegates: const [ PaymentLocalizations.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], builder: (context, child) { final scale = textScale; if (scale == null) return child!; return MediaQuery( data: MediaQuery.of( context, ).copyWith(textScaler: TextScaler.linear(scale)), child: child!, ); }, home: AnnotatedRegion<SystemUiOverlayStyle>( // D85: the host styles the system bars from its resolved theme. value: (dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark) .copyWith( systemNavigationBarColor: Colors.transparent, systemNavigationBarDividerColor: Colors.transparent, systemNavigationBarContrastEnforced: false, ), child: Scaffold( appBar: AppBar( title: Text(title), actions: [ PaymentIconButton( icon: dark ? Icons.light_mode_outlined : Icons.dark_mode_outlined, tooltip: dark ? 'Mode terang' : 'Mode gelap', onPressed: onToggleDark, ), if (scenarios.isNotEmpty) PopupMenuButton<int>( tooltip: 'Skenario demo', onSelected: (i) => scenarios[i].onSelected(), itemBuilder: (_) => [ for (final (i, s) in scenarios.indexed) PopupMenuItem(value: i, child: Text(s.label)), ], ), ], ), body: SafeArea(top: false, child: Builder(builder: body)), ), ), );}Proof and limits
Section titled “Proof and limits”Widget tests cover the original payment remaining unchanged, failed refund-check recovery and a reachable refresh action at 320 dp with 200% text. Connect your own refund-status service; this block does not initiate refunds. See Compatibility for device coverage.