API Reference

PayWidget

Drop-in Flutter widget for the full FedaPay payment flow.

Overview

PayWidget is a Flutter widget that embeds the FedaPay payment page in a WebView. It handles token generation, URL construction, and payment callbacks automatically.

Usage

import 'package:feda_flutter/feda_flutter.dart';

PayWidget(
  apiKey: 'your_api_key',
  transactionId: 42,
  environment: FedaEnvironment.sandbox,
  onPaymentSuccess: () {
    print('Payment successful!');
  },
  onPaymentFailed: () {
    print('Payment failed.');
  },
  onPaymentCanceled: () {
    print('Payment canceled.');
  },
)

Parameters

ParameterTypeRequiredDescription
apiKeyStringYour FedaPay API key
transactionIdintID of the transaction to pay
environmentFedaEnvironment.sandbox or .live
onPaymentSuccessVoidCallback?Called on successful payment
onPaymentFailedVoidCallback?Called on failed payment
onPaymentCanceledVoidCallback?Called when user cancels

Environments

// Sandbox (testing)
environment: FedaEnvironment.sandbox

// Production
environment: FedaEnvironment.live
Always test with FedaEnvironment.sandbox before going live. Sandbox transactions are not real payments.

How it works

  1. PayWidget calls the /transactions/{id}/token endpoint to get a payment token
  2. It constructs the checkout URL: https://checkout.fedapay.com/pay/{token}
  3. The URL is loaded in a WebViewController
  4. Payment result callbacks are triggered based on the redirect URL