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
| Parameter | Type | Required | Description |
|---|---|---|---|
apiKey | String | ✅ | Your FedaPay API key |
transactionId | int | ✅ | ID of the transaction to pay |
environment | FedaEnvironment | ✅ | .sandbox or .live |
onPaymentSuccess | VoidCallback? | ❌ | Called on successful payment |
onPaymentFailed | VoidCallback? | ❌ | Called on failed payment |
onPaymentCanceled | VoidCallback? | ❌ | 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
PayWidgetcalls the/transactions/{id}/tokenendpoint to get a payment token- It constructs the checkout URL:
https://checkout.fedapay.com/pay/{token} - The URL is loaded in a
WebViewController - Payment result callbacks are triggered based on the redirect URL