initializePayment method

  1. @override
Future<PaymentResponse> initializePayment(
  1. PaymentRequest request
)
override

Initialize a payment transaction

Implementation

@override
Future<PaymentResponse> initializePayment(PaymentRequest request) async {
  // For unified webview approach, get checkout URL first
  final checkoutUrl = await getCheckoutUrl(request);

  // For web, redirect to checkout URL (since web is already in browser)
  web.window.location.href = checkoutUrl;

  // Since we're redirecting, return a pending response
  // In practice, the app would handle the return via callback URL
  return PaymentResponse(
    reference: request.reference ?? _generateReference(),
    status: PaymentStatus.pending,
    amount: request.amount,
    currency: request.currency,
    paymentMethod: PaymentMethod.card, // Default
  );
}