easy_pay 0.0.3 copy "easy_pay: ^0.0.3" to clipboard
easy_pay: ^0.0.3 copied to clipboard

EasyPay SDK.

example/lib/main.dart

import 'dart:convert';

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

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  final EasyPay _easyPay = EasyPay();
  String? _sessionKey;

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

  Future<void> initPlatformState() async {
    try {
      final version = await _easyPay.getPlatformVersion() ?? 'Unknown platform version';
      setState(() {
        _platformVersion = version;
      });
    } catch (e) {
      print('Failed to get platform version: $e');
    }
  }

  Future<void> startTransaction() async {
    try {
      final response = await _easyPay.registerDevice('128922769414', '139453877702');
      print("Transaction successful::::::::::::::::::::::::: $response");
      // get sessionkey

      //
    } catch (e) {
      print('Failed to start transaction::::::::::::::::::: $e');
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Running on: $_platformVersion\n'),
              ElevatedButton(
                onPressed: startTransaction,
                child: const Text('Start Transaction'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}