korapay_flutter 0.4.1 copy "korapay_flutter: ^0.4.1" to clipboard
korapay_flutter: ^0.4.1 copied to clipboard

Korapay payment gateway integration for Flutter. This SDK allows easy integration of Korapay's payment services into your Flutter applications with a customizable UI component.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:developer' as developer;
import 'package:korapay_flutter/korapay_flutter.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter/services.dart';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'dart:async';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setSystemUIOverlayStyle(
    const SystemUiOverlayStyle(
      statusBarColor: Colors.transparent,
      statusBarIconBrightness: Brightness.dark,
    ),
  );
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Korapay Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        fontFamily: 'Averta',
        primaryColor: const Color(0xFF2376F3),
        colorScheme: ColorScheme.light(
          primary: const Color(0xFF2376F3),
          secondary: const Color(0xFF989898),
        ),
        scaffoldBackgroundColor: Colors.white,
        textTheme: const TextTheme(
          titleLarge: TextStyle(fontWeight: FontWeight.w600),
          titleMedium: TextStyle(fontWeight: FontWeight.w500),
          labelLarge: TextStyle(fontWeight: FontWeight.w500),
        ),
        inputDecorationTheme: InputDecorationTheme(
          filled: true,
          fillColor: Colors.grey.shade50,
          contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
          border: OutlineInputBorder(
            borderRadius: BorderRadius.circular(8),
            borderSide: BorderSide.none,
          ),
          enabledBorder: OutlineInputBorder(
            borderRadius: BorderRadius.circular(8),
            borderSide: BorderSide.none,
          ),
          focusedBorder: OutlineInputBorder(
            borderRadius: BorderRadius.circular(8),
            borderSide: const BorderSide(color: Color(0xFF2376F3), width: 1.5),
          ),
          labelStyle: TextStyle(
            fontFamily: 'Averta',
            color: Colors.grey.shade700,
            fontSize: 16,
          ),
          hintStyle: TextStyle(
            fontFamily: 'Averta',
            color: Colors.grey.shade500,
            fontSize: 14,
          ),
          floatingLabelStyle: const TextStyle(
            fontFamily: 'Averta',
            color: Color(0xFF2376F3),
            fontSize: 16,
            fontWeight: FontWeight.w500,
          ),
        ),
        elevatedButtonTheme: ElevatedButtonThemeData(
          style: ElevatedButton.styleFrom(
            backgroundColor: const Color(0xFF2376F3),
            foregroundColor: Colors.white,
            elevation: 0,
            padding: const EdgeInsets.symmetric(vertical: 16),
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(8),
            ),
            textStyle: const TextStyle(
              fontSize: 16,
              fontWeight: FontWeight.w500,
            ),
          ),
        ),
        cardTheme: CardTheme(
          elevation: 0,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(12),
            side: BorderSide(color: Colors.grey.shade200),
          ),
          color: Colors.white,
        ),
        appBarTheme: const AppBarTheme(
          backgroundColor: Colors.white,
          foregroundColor: Color(0xFF989898),
          elevation: 0,
          systemOverlayStyle: SystemUiOverlayStyle.dark,
        ),
        snackBarTheme: SnackBarThemeData(
          behavior: SnackBarBehavior.floating,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(8),
          ),
        ),
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(
          'Korapay Flutter Demo',
          style: TextStyle(
            fontFamily: 'Averta',
            fontSize: 22,
            fontWeight: FontWeight.w600,
            color: Color(0xFF2376F3),
          ),
        ),
        centerTitle: true,
        backgroundColor: Colors.white,
        elevation: 0,
      ),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(24.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              // Add your logo here if available
              // SvgPicture.asset(
              //   'assets/korapay_icon.svg',
              //   height: 100,
              //   width: 80,
              // ),
              const SizedBox(height: 24),
              const Text(
                'Welcome to Korapay Flutter SDK',
                style: TextStyle(
                  fontFamily: 'Averta',
                  fontSize: 28,
                  fontWeight: FontWeight.w600,
                  color: Color(0xFF2376F3),
                ),
                textAlign: TextAlign.center,
              ),
              const SizedBox(height: 20),
              const Text(
                'This example demonstrates how to integrate the Korapay Flutter SDK in your app using the pre-built payment UI component.',
                style: TextStyle(
                  fontSize: 16,
                  color: Colors.black87,
                ),
                textAlign: TextAlign.center,
              ),
              const SizedBox(height: 40),
              ElevatedButton(
                onPressed: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(
                      builder: (context) => const KorapayPaymentPage(
                        // Replace with your public key from Korapay dashboard
                        publicKey: 'pk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
                        title: 'Payment for Product',
                        description: 'Test payment from Flutter SDK',
                        initialAmount: '1000', // Optional: Set an initial amount in NGN
                        showLiveToggle: true, // Optional: Show test/live environment toggle
                        // Optional: Custom styles, callback functions, etc. are also available
                      ),
                    ),
                  );
                },
                style: ElevatedButton.styleFrom(
                  minimumSize: const Size(double.infinity, 56),
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(8),
                  ),
                ),
                child: const Text(
                  'Proceed to Payment',
                  style: TextStyle(
                    fontFamily: 'Averta',
                    fontSize: 18,
                    fontWeight: FontWeight.w600,
                  ),
                ),
              ),
              const SizedBox(height: 20),
              const Text(
                'Note: Replace the publicKey placeholder with your actual public key from the Korapay dashboard.',
                style: TextStyle(
                  fontSize: 14,
                  color: Colors.grey,
                  fontStyle: FontStyle.italic,
                ),
                textAlign: TextAlign.center,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
120
points
56
downloads

Publisher

unverified uploader

Weekly Downloads

Korapay payment gateway integration for Flutter. This SDK allows easy integration of Korapay's payment services into your Flutter applications with a customizable UI component.

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_svg, http

More

Packages that depend on korapay_flutter