kyrmannpay_flutter 1.3.1 copy "kyrmannpay_flutter: ^1.3.1" to clipboard
kyrmannpay_flutter: ^1.3.1 copied to clipboard

KyrmannPay plugin.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:kyrmannpay_flutter/kyrmannpay.dart';

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Kyrmannpay Demo'),
      routes: {
        '/payment': (context) => KyrmannPay(
          paymentData: const {
            "login": "login",
            "password": "password",
            "amount": 0000,
            "afid": 00,
            "offerId": 0000,
            "cartId": "cartId",
            "key": "iv",
            "iv": "iv"
          },
          callbackUrl: 'https://flutter.dev',
          onPaymentError: (error){
            showDialog(
              context: context, 
              builder: (_) => AlertDialog(
                title: const Text(
                  'Erreur',
                  textAlign: TextAlign.center,
                  ),
                content: Text('$error'),
              )
              );
          },
          onPaymentSuccess: (data){
            Navigator.of(context).pop();
          },
          )
      },
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: (){
            Navigator.pushNamed(context, '/payment');
          },
          child: const Text('payer'),
        ),
      ),
    );
    
  }
}