showWalletReceipt method
Future<void>
showWalletReceipt({
- required BuildContext context,
- required TransactionDetailsSettings settings,
Shows the wallet payment receipt dialog.
Displays a modal dialog containing transaction details for wallet payments. The dialog is non-dismissible and includes proper navigation handling.
Parameters:
context: The build context for showing the dialogsettings: Configuration for the transaction details display
Example:
await ReceiptHandler.instance.showWalletReceipt(
context: context,
settings: TransactionDetailsSettings(
transactionId: 'TXN123',
amount: 100.0,
),
);
Implementation
Future<void> showWalletReceipt({
required BuildContext context,
required TransactionDetailsSettings settings,
}) async {
Logar.debug('showWalletReceipt starting', tag: 'RECEIPT_HANDLER');
// Check if receipt should be ignored
final shouldIgnore = AmwalPaySdk.settings?.additionValues?['ignoreReceipt'] == 'true';
if (shouldIgnore) {
Logar.info('Receipt ignored by configuration', tag: 'RECEIPT_HANDLER');
// Show success or failed animation based on transaction status
if (settings.transactionStatus == TransactionStatus.success) {
await showSuccessAnimation(
context: context,
onComplete: () {
// Perform cleanup logic - pop SDK screens
if (AmwalSdkNavigator.amwalNavigatorObserver.navigator != null) {
final nav = AmwalSdkNavigator.amwalNavigatorObserver.navigator!;
if (nav.canPop()) nav.pop();
if (nav.canPop()) nav.pop();
}
},
);
} else {
await showFailedAnimation(
context: context,
onComplete: () {
// Perform cleanup logic - pop SDK screens
if (AmwalSdkNavigator.amwalNavigatorObserver.navigator != null) {
final nav = AmwalSdkNavigator.amwalNavigatorObserver.navigator!;
if (nav.canPop()) nav.pop();
if (nav.canPop()) nav.pop();
}
},
);
}
return;
}
try {
Logar.debug('Pushing dialog route', tag: 'RECEIPT_HANDLER');
await Navigator.of(context).push(
DialogRoute(
context: context,
builder: (_) {
Logar.debug(
'Building TransactionStatusDialog',
tag: 'RECEIPT_HANDLER',
);
return TransactionStatusDialog(
settings: settings.copyWith(
onClose: () {
Logar.debug(
'Dialog closed, popping navigators',
tag: 'RECEIPT_HANDLER',
);
Navigator.of(context).pop();
Logar.info(
'Navigator popped from receipt handler context',
tag: 'NAVIGATION',
);
Navigator.of(context).pop();
Logar.info(
'Navigator popped from receipt handler context',
tag: 'NAVIGATION',
);
if (AmwalSdkNavigator.amwalNavigatorObserver.navigator !=
null) {
AmwalSdkNavigator.amwalNavigatorObserver.navigator!.pop();
Logar.info(
'Navigator popped from receipt handler',
tag: 'NAVIGATION',
);
}
},
),
);
},
barrierDismissible: false,
),
);
Logar.debug('Dialog route pushed successfully', tag: 'RECEIPT_HANDLER');
} catch (e, stackTrace) {
Logar.error(
'showWalletReceipt error',
tag: 'RECEIPT_HANDLER',
error: e,
stackTrace: stackTrace,
);
}
}