Skip to content
Get started
Menu
Get started

Method choice and quote changes

Choose a payment method, see the fee and total the host quotes for it, then review and pay. Unavailable methods say why. When the host re-prices at submit, the payer sees the old and new totals and must accept the new total before Pay becomes available.

Method list with fees per method, an unavailable card with its reason, and a Continue action showing the total Rp254.000.Method list with fees per method, an unavailable card with its reason, and a Continue action showing the total Rp254.000.
Choose a method
Changed total banner from Rp254.000 to Rp255.000, new fee lines, an unchecked acceptance box and a disabled Pay action.
Quote changed at submit
The fee could not be calculated; a banner offers Try again and Continue stays disabled.
Quote failed

From example/:

Terminal window
flutter run -d <device-id> -t lib/method_quote_demo.dart

Pick a method. Continue stays disabled until the host quote for that method arrives, then shows the total. Continue to the review and tap Bayar. The developer menu offers two more scenarios:

  • Biaya VA berubah saat bayar: the host answers the first Pay with a new bank fee. The review shows the change, and Pay waits for the payer to check the acceptance box.
  • Biaya gagal dihitung: the first quote fails and Coba lagi asks again.

If the payer switches method while a quote is running, the older answer is ignored. Changing a scenario starts a fresh synthetic session.

MethodQuoteBlock takes the host’s methods, the selected id, the latest PaymentQuote, the previous approved quote and callbacks. The static MethodQuoteBlock.quoteMatches check enables Continue only for a settled quote that names the current selection. The host passes previousQuote when it re-prices; the kit resets acceptance on every new quote revision.

UI Existing library surface
Methods, fees and availability reasons PaymentMethodPicker, PaymentMethod
Fee lines and total PaymentSummary, PaymentQuote
Review, changed total and acceptance PaymentConfirmation with previousQuote
Pinned Continue and quote retry PaymentFullPageView, PaymentButton, PaymentBanner

The host owns pricing, quote ids and revisions, the request that asks for a quote, and authorization (PIN, OTP, biometrics) after approval. This block collects no credentials. All prices are fictional. See the checkout pattern.

Source: compositions/method_quote_block.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';
enum MethodQuoteStep { choose, review }
/// Copyable host composition: choose a method, see its host-priced fees and
/// total, then review and approve before paying.
///
/// A selection is not a price. Continue is enabled only when the host quote
/// names the selected method and no newer quote request is running, so a late
/// answer for an earlier choice can never enable paying. When the host
/// re-prices at submit, pass the approved quote as [previousQuote]: the kit
/// shows the change and keeps Pay disabled until the payer accepts the new
/// total. Authorization (PIN, OTP, biometrics) stays in the host; this block
/// collects no credentials.
class MethodQuoteBlock extends StatelessWidget {
const MethodQuoteBlock({
super.key,
required this.title,
required this.step,
required this.methods,
required this.selectedId,
required this.quote,
required this.onSelect,
required this.onContinue,
required this.onChangeMethod,
required this.onConfirm,
required this.onRetryQuote,
this.quoting = false,
this.quoteError,
this.previousQuote,
this.submitting = false,
});
/// What is being paid for; the method list carries its own heading.
final String title;
final MethodQuoteStep step;
final List<PaymentMethod> methods;
final String? selectedId;
/// Latest host quote, or null before the first answer.
final PaymentQuote? quote;
final ValueChanged<PaymentMethod> onSelect;
final VoidCallback onContinue;
final VoidCallback onChangeMethod;
final Future<void> Function() onConfirm;
final VoidCallback onRetryQuote;
final bool quoting;
final String? quoteError;
final PaymentQuote? previousQuote;
final bool submitting;
/// True only for a settled quote that prices the current selection.
static bool quoteMatches({
required List<PaymentMethod> methods,
required String? selectedId,
required PaymentQuote? quote,
required bool quoting,
}) =>
!quoting &&
quote != null &&
PaymentMethodPicker.validSelection(methods, selectedId) != null &&
quote.methodId == selectedId;
@override
Widget build(BuildContext context) {
final theme = PaymentTheme.of(context);
final type = PaymentType.of(context);
final ready = quoteMatches(
methods: methods,
selectedId: selectedId,
quote: quote,
quoting: quoting,
);
if (step == MethodQuoteStep.review && ready) {
final method = methods.firstWhere((m) => m.id == selectedId);
return PaymentConfirmation(
// A new quote revision resets the kit's acceptance checkbox.
quote: quote!,
previousQuote: previousQuote,
method: method,
busy: submitting,
onConfirm: onConfirm,
footnote:
'Setelah Anda menyetujui, aplikasi meminta otorisasi di '
'langkah berikutnya.',
header: Row(
crossAxisAlignment: CrossAxisAlignment.center,
spacing: theme.space(PaymentSpace.related),
children: [
Expanded(child: Text(title, style: type.heading)),
PaymentLink(
label: 'Ganti metode',
semanticLabel: 'Ganti metode pembayaran',
onPressed: submitting ? null : onChangeMethod,
),
],
),
);
}
final l10n = PaymentLocalizations.of(context);
return PaymentFullPageView(
title: title,
// The priced total rides on the pinned action, so the payer sees it
// without scrolling past the method list.
primaryAction: PaymentButton(
label: ready
? 'Lanjutkan · ${l10n.moneyFormat.format(quote!.total)}'
: 'Lanjutkan',
onPressed: ready ? onContinue : null,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: theme.space(PaymentSpace.group),
children: [
PaymentMethodPicker(
methods: methods,
selectedId: selectedId,
onChanged: onSelect,
),
if (selectedId == null)
Text(
'Pilih metode untuk melihat biaya dan total dari merchant.',
style: type.caption,
)
else if (quoting)
Row(
spacing: theme.space(PaymentSpace.related),
children: [
const PaymentIcon(
PaymentIcons.busy,
color: PaymentTextColor.secondary,
),
Expanded(
child: Text(
'Menghitung biaya untuk metode ini…',
style: type.label,
),
),
],
)
else if (quoteError != null)
PaymentBanner(
tone: StatusTone.danger,
icon: Icons.cloud_off_outlined,
title: 'Biaya belum dapat dihitung',
message: quoteError,
actions: [
PaymentButton(
label: 'Coba lagi',
variant: PaymentButtonVariant.secondary,
width: PaymentWidth.hug,
onPressed: onRetryQuote,
),
],
)
else if (ready)
PaymentSummary(quote: quote!),
],
),
);
}
}
Source: method_quote_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/method_quote_block.dart';
void main() => runBlockDemo(const MethodQuoteDemo());
enum MethodQuoteScenario { normal, repriced, quoteError }
final methodQuoteNow = DateTime(2026, 11, 4, 10, 42);
const methodQuoteMethods = [
PaymentMethod(
id: 'balance',
label: 'Saldo Ruang Bayar',
kind: PaymentMethodKind.balance,
detail: 'Saldo Rp400.000',
feeNote: 'Tanpa biaya',
),
PaymentMethod(
id: 'va',
label: 'Virtual account',
kind: PaymentMethodKind.virtualAccount,
detail: 'Bank Demo',
feeNote: 'Biaya bank Rp4.000',
),
PaymentMethod(
id: 'qris',
label: 'QRIS',
kind: PaymentMethodKind.eWallet,
feeNote: 'Biaya layanan 0,7%',
),
PaymentMethod(
id: 'card',
label: 'Kartu kredit',
kind: PaymentMethodKind.card,
unavailableReason: 'Belum didukung merchant ini',
),
];
/// Synthetic pricing table. A real host asks its server for every quote.
PaymentQuote methodQuoteFixture(String methodId, {int revision = 1}) {
final fee = switch (methodId) {
'va' => revision > 1 ? 5000 : 4000,
'qris' => 1750,
_ => 0,
};
return PaymentQuote(
id: 'QUOTE-DEMO-218-$methodId',
revision: revision,
methodId: methodId,
lines: [
const QuoteLine(label: 'Paket Belajar Pro', amount: Money.idr(250000)),
if (fee > 0)
QuoteLine(
label: methodId == 'va' ? 'Biaya bank' : 'Biaya layanan',
amount: Money.idr(fee),
kind: QuoteLineKind.fee,
),
],
total: Money.idr(250000 + fee),
expiresAt: methodQuoteNow.add(const Duration(minutes: 10)),
);
}
/// Host answer to a submit: accepted, or the server re-priced the order.
typedef MethodSubmitAnswer = ({bool accepted, PaymentQuote? newQuote});
/// Synthetic checkout host. No payment, authorization or network happens;
/// delays only make the busy states visible.
class MethodQuoteDemo extends StatefulWidget {
const MethodQuoteDemo({
super.key,
this.initialScenario = MethodQuoteScenario.normal,
this.initialDark = false,
this.quoteFor,
this.delay = const Duration(milliseconds: 500),
});
final MethodQuoteScenario initialScenario;
final bool initialDark;
/// Replaces the fixture pricing, e.g. to control answer order in tests.
final Future<PaymentQuote> Function(String methodId)? quoteFor;
final Duration delay;
@override
State<MethodQuoteDemo> createState() => _MethodQuoteDemoState();
}
class _MethodQuoteDemoState extends State<MethodQuoteDemo> {
late bool dark = widget.initialDark;
late MethodQuoteScenario scenario = widget.initialScenario;
MethodQuoteStep step = MethodQuoteStep.choose;
String? selectedId;
PaymentQuote? quote;
PaymentQuote? previousQuote;
bool quoting = false;
String? quoteError;
bool submitting = false;
bool submitted = false;
int quoteRequest = 0;
int quoteCalls = 0;
int submits = 0;
int generation = 0;
void reset(MethodQuoteScenario value) => setState(() {
generation++;
scenario = value;
step = MethodQuoteStep.choose;
selectedId = null;
quote = previousQuote = quoteError = null;
quoting = submitting = submitted = false;
quoteCalls = submits = 0;
});
Future<PaymentQuote> fixtureQuote(String methodId) async {
await Future<void>.delayed(widget.delay);
if (scenario == MethodQuoteScenario.quoteError && quoteCalls == 1) {
throw StateError('Synthetic pricing failure');
}
return methodQuoteFixture(methodId);
}
Future<void> select(PaymentMethod method) async {
if (submitting) return;
// Every request gets a number; only the newest may update the screen.
final request = ++quoteRequest;
final current = generation;
quoteCalls++;
setState(() {
selectedId = method.id;
quoting = true;
quoteError = null;
previousQuote = null;
});
try {
final answer = await (widget.quoteFor ?? fixtureQuote)(method.id);
if (!mounted || current != generation || request != quoteRequest) {
return;
}
setState(() {
quoting = false;
quote = answer;
});
} catch (_) {
if (!mounted || current != generation || request != quoteRequest) {
return;
}
setState(() {
quoting = false;
quote = null;
quoteError = 'Periksa koneksi, lalu coba lagi.';
});
}
}
Future<void> confirm() async {
final approved = quote;
if (submitting || approved == null) return;
final current = generation;
setState(() => submitting = true);
await Future<void>.delayed(widget.delay);
if (!mounted || current != generation) return;
// The host re-validates the approved quote; the fixture re-prices the
// first VA submit in the "changed" scenario.
final answer =
scenario == MethodQuoteScenario.repriced &&
approved.methodId == 'va' &&
submits++ == 0
? (
accepted: false,
newQuote: methodQuoteFixture('va', revision: approved.revision + 1),
)
: (accepted: true, newQuote: null);
setState(() {
submitting = false;
if (answer.newQuote case final next?) {
previousQuote = approved;
quote = next;
} else {
submitted = true;
}
});
}
@override
Widget build(BuildContext context) => BlockDemoShell(
title: 'Pembayaran · Demo',
dark: dark,
onToggleDark: () => setState(() => dark = !dark),
scenarios: [
for (final (value, label) in [
(MethodQuoteScenario.normal, 'Harga tetap'),
(MethodQuoteScenario.repriced, 'Biaya VA berubah saat bayar'),
(MethodQuoteScenario.quoteError, 'Biaya gagal dihitung'),
])
(label: label, onSelected: () => reset(value)),
],
body: (context) => submitted
? PaymentStatusView(
key: ValueKey('done-$generation'),
attempt: PaymentAttempt(
attemptId: 'PAY-DEMO-218',
quoteId: quote!.id,
quoteRevision: quote!.revision,
methodId: quote!.methodId!,
submission: SubmissionState.accepted,
snapshot: PaymentStatusSnapshot(
attemptId: 'PAY-DEMO-218',
serverReference: 'TX-DEMO-218',
status: PaymentStatus.processing,
revision: 1,
updatedAt: methodQuoteNow,
safeReason:
'Total yang Anda setujui diteruskan ke host untuk '
'otorisasi. Demo berhenti di sini.',
),
),
amount: quote!.total,
onAction: (_) {},
secondaryAction: PaymentButton(
label: 'Mulai ulang demo',
variant: PaymentButtonVariant.quiet,
onPressed: () => reset(scenario),
),
)
: MethodQuoteBlock(
key: ValueKey(generation),
title: 'Paket Belajar Pro',
step: step,
methods: methodQuoteMethods,
selectedId: selectedId,
quote: quote,
previousQuote: previousQuote,
quoting: quoting,
quoteError: quoteError,
submitting: submitting,
onSelect: select,
onRetryQuote: () => select(
methodQuoteMethods.firstWhere((m) => m.id == selectedId),
),
onContinue: () => setState(() => step = MethodQuoteStep.review),
onChangeMethod: () => setState(() {
step = MethodQuoteStep.choose;
previousQuote = null;
}),
onConfirm: confirm,
),
);
}
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)),
),
),
);
}

Widget tests cover late quotes, changed-total acceptance, unavailable methods, pricing retry and a reachable Continue action at 320 dp with 200% text. Connect your own pricing and authorization services. See Compatibility for device coverage.