digetpay_plugin 0.5.0 copy "digetpay_plugin: ^0.5.0" to clipboard
digetpay_plugin: ^0.5.0 copied to clipboard

Pure-Dart DigetPay payment plugin: hosted (PCI-safe) checkout via WebView plus transaction management over the DigetPay REST API.

example/lib/main.dart

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

import 'app_config_store.dart';
import 'log_console.dart';
import 'pages/home_page.dart';
import 'pages/onboarding_page.dart';
import 'theme/app_theme.dart';
import 'widgets/brand_header.dart';

void main() {
  runApp(const DigetPayExampleApp());
}

/// The DigetPay integration-guide example app.
///
/// Startup shows [_StartupGate], which decides whether to initialize the SDK
/// from a previously-saved API key/environment (see [AppConfigStore]) and go
/// straight to [HomePage], or ask for one via [OnboardingPage] first.
class DigetPayExampleApp extends StatelessWidget {
  /// Creates the example app.
  const DigetPayExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'DigetPay Example',
      debugShowCheckedModeBanner: false,
      theme: AppTheme.light,
      home: const _StartupGate(),
    );
  }
}

class _StartupGate extends StatefulWidget {
  const _StartupGate();

  @override
  State<_StartupGate> createState() => _StartupGateState();
}

class _StartupGateState extends State<_StartupGate> {
  bool _loading = true;
  bool _configured = false;

  @override
  void initState() {
    super.initState();
    _load();
  }

  Future<void> _load() async {
    final saved = await AppConfigStore.load();
    if (saved != null) {
      DigetPaySdk.initialize(
        apiKey: saved.apiKey,
        baseUrl: saved.environment.baseUrl,
        // Remove in production, or gate behind kDebugMode.
        logger: digetPayLog,
      );
    }
    if (!mounted) return;
    setState(() {
      _configured = saved != null;
      _loading = false;
    });
  }

  @override
  Widget build(BuildContext context) {
    if (_loading) {
      return const Scaffold(
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              BrandHeader(logoHeight: 56),
              SizedBox(height: 28),
              SizedBox(
                height: 22,
                width: 22,
                child: CircularProgressIndicator(strokeWidth: 2.4),
              ),
            ],
          ),
        ),
      );
    }
    return _configured ? const HomePage() : const OnboardingPage();
  }
}
1
likes
160
points
287
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Pure-Dart DigetPay payment plugin: hosted (PCI-safe) checkout via WebView plus transaction management over the DigetPay REST API.

Homepage
Repository (GitHub)
View/report issues

Topics

#payments #payment-gateway #checkout #webview

License

MIT (license)

Dependencies

crypto, flutter, http, uuid, webview_flutter

More

Packages that depend on digetpay_plugin