toWalletOptionsScreen method

Future<void> toWalletOptionsScreen(
  1. BuildContext context,
  2. RouteSettings settings,
  3. OnPayCallback onPay,
  4. OnPayCallback onCountComplete,
  5. GetTransactionFunction getTransactionFunction,
  6. int countDownInSeconds,
  7. EventCallback? log,
)

Navigates to the wallet payment options screen.

This method presents the user with available digital wallet payment options, including Apple Pay, Google Pay, and other supported wallets.

Parameters:

  • context - The current build context for navigation
  • settings - Route settings containing navigation arguments
  • onPay - Callback function executed when payment is completed
  • onCountComplete - Callback function executed when countdown timer expires
  • getTransactionFunction - Function to retrieve transaction details
  • countDownInSeconds - Duration of the payment countdown timer
  • log - Optional callback for logging events and analytics
  1. Extracts payment arguments from route settings
  2. Creates a new route to the wallet options screen
  3. Passes all necessary parameters to the screen
  4. Handles navigation and screen presentation

Example

await AmwalSdkNavigator.instance.toWalletOptionsScreen(
  context,
  settings,
  (result) =&gt; print('Payment completed: $result'),
  () =&gt; print('Countdown expired'),
  () async =&gt; await getTransactionDetails(),
  90, // 90 seconds countdown
  (event, params) =&gt; logEvent(event, params),
);

Navigates to the wallet payment options screen.

Implementation

Future<void> toWalletOptionsScreen(
  BuildContext context,
  RouteSettings settings,
  OnPayCallback onPay,
  OnPayCallback onCountComplete,
  GetTransactionFunction getTransactionFunction,
  int countDownInSeconds,
  EventCallback? log,
) async {
  final args = settings.arguments as PaymentArguments;
  await Navigator.of(context).push(
    MaterialPageRoute(
      builder: (_) => SaleByWalletPayingOptions(
        getTransactionFunction: getTransactionFunction,
        onCountComplete: onCountComplete,
        onPay: onPay,
        amount: args.amount,
        terminalId: args.terminalId,
        merchantId: args.merchantId,
        currencyId: args.currencyData!.idN,
        currency: args.currencyData!.name,
        transactionId: args.transactionId,
        countDownInSeconds: countDownInSeconds,
        log: log,
      ),
    ),
  );
}