processPayment method

  1. @override
Future<PaymentResponse> processPayment(
  1. String checkoutUrl
)
override

Processes a payment by opening the provided checkout URL in a webview.

The implementation should:

  • Open the checkout URL in a platform-appropriate webview
  • Handle Paystack's callback mechanisms (redirects, postMessage, etc.)
  • Return a PaymentResponse based on the payment outcome

checkoutUrl The Paystack checkout URL to load in the webview

Returns a PaymentResponse containing the payment result

Implementation

@override
Future<PaymentResponse> processPayment(String checkoutUrl) async {
  // For web, redirect to the checkout URL
  web.window.location.href = checkoutUrl;

  // Since we're redirecting, we can't return a response here
  // In practice, the app would handle the return via callback URL
  // For this implementation, we'll simulate a successful response
  // In a real implementation, you'd need to handle the return from Paystack

  // This is a placeholder - real implementation would need proper callback handling
  return PaymentResponse(
    reference: 'web_redirect_ref_${DateTime.now().millisecondsSinceEpoch}',
    status: PaymentStatus.pending, // Since we redirect, status is pending
    amount: 0,
    currency: Currency.ngn,
    paymentMethod: PaymentMethod.card,
  );
}