Skip to main content

sela_pay 1.0.0 copy "sela_pay: ^1.0.0" to clipboard
sela_pay: ^1.0.0 copied to clipboard

In-app checkout for Sela Pay. Accept Libyan payment methods inside your Flutter app with a ready-made themed sheet or your own UI.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:sela_pay/sela_pay.dart';

void main() => runApp(const ExampleApp());

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Sela Pay example',
      theme: ThemeData(colorSchemeSeed: Colors.teal, useMaterial3: true),
      home: const CheckoutPage(),
    );
  }
}

/// Paste a session your server created, then open the checkout.
///
/// In a real app the session id and token come from your own backend, which
/// creates the session with its secret access token.
class CheckoutPage extends StatefulWidget {
  const CheckoutPage({super.key});

  @override
  State<CheckoutPage> createState() => _CheckoutPageState();
}

class _CheckoutPageState extends State<CheckoutPage> {
  final _sessionId = TextEditingController();
  final _sessionToken = TextEditingController();
  String _outcome = '';

  @override
  void dispose() {
    _sessionId.dispose();
    _sessionToken.dispose();
    super.dispose();
  }

  Future<void> _pay() async {
    final result = await SelaCheckout.present(
      context,
      sessionId: _sessionId.text.trim(),
      sessionToken: _sessionToken.text.trim(),
      locale: 'ar',
    );
    if (!mounted) return;
    setState(() => _outcome = '${result.status.name} ${result.transactionId ?? ''}'.trim());
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Sela Pay example')),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            TextField(controller: _sessionId, decoration: const InputDecoration(labelText: 'session_id')),
            const SizedBox(height: 12),
            TextField(controller: _sessionToken, decoration: const InputDecoration(labelText: 'session_token')),
            const SizedBox(height: 20),
            FilledButton(onPressed: _pay, child: const Text('Pay')),
            const SizedBox(height: 20),
            Text(_outcome, textAlign: TextAlign.center),
          ],
        ),
      ),
    );
  }
}
0
likes
150
points
--
downloads

Documentation

API reference

Publisher

verified publisherselapay.ly

Weekly Downloads

In-app checkout for Sela Pay. Accept Libyan payment methods inside your Flutter app with a ready-made themed sheet or your own UI.

Homepage

Topics

#payments #checkout #libya

License

MIT (license)

Dependencies

flutter, http, webview_flutter

More

Packages that depend on sela_pay