payme_sdk_flutter 1.1.6
payme_sdk_flutter: ^1.1.6 copied to clipboard

PayME SDK Flutter is plugin for application integrate with PayME Platform.

example/lib/main.dart

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

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

const APP_TOKEN_DEFAULT_SANDBOX =
    "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MTQsImlhdCI6MTYxNDE2NDI3MH0.MmzNL81YTx8XyTu6SczAqZtnCA_ALsn9GHsJGBKJSIk";
const PUBLIC_KEY_DEFAULT_SANDBOX = "-----BEGIN PUBLIC KEY-----\n" +
    "      MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMyTFdiYBiaSIBgqFdxSgzk5LYXKocgT\n" +
    "      MCx/g1gz9k2jadJ1PDohCs7N65+dh/0dTbT8CIvXrrlAgQT1zitpMPECAwEAAQ==\n" +
    "      -----END PUBLIC KEY-----";
const SECRET_KEY_DEFAULT_SANDBOX = "de7bbe6566b0f1c38898b7751b057a94";
const PRIVATE_KEY_DEFAULT_SANDBOX = "-----BEGIN RSA PRIVATE KEY-----\n" +
    "      MIIBOQIBAAJAZCKupmrF4laDA7mzlQoxSYlQApMzY7EtyAvSZhJs1NeW5dyoc0XL\n" +
    "      yM+/Uxuh1bAWgcMLh3/0Tl1J7udJGTWdkQIDAQABAkAjzvM9t7kD84PudR3vEjIF\n" +
    "      5gCiqxkZcWa5vuCCd9xLUEkdxyvcaLWZEqAjCmF0V3tygvg8EVgZvdD0apgngmAB\n" +
    "      AiEAvTF57hIp2hkf7WJnueuZNY4zhxn7QNi3CQlGwrjOqRECIQCHfqO53A5rvxCA\n" +
    "      ILzx7yXHzk6wnMcGnkNu4b5GH8usgQIhAKwv4WbZRRnoD/S+wOSnFfN2DlOBQ/jK\n" +
    "      xBsHRE1oYT3hAiBSfLx8OAXnfogzGLsupqLfgy/QwYFA/DSdWn0V/+FlAQIgEUXd\n" +
    "      A8pNN3/HewlpwTGfoNE8zCupzYQrYZ3ld8XPGeQ=\n" +
    "      -----END RSA PRIVATE KEY-----";

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _accountStatus = 'Not Connected. Please LOGIN first';
  bool _connected = false;

  @override
  Widget build(BuildContext context) {
    final sdkArgs = PaymeSdkFlutterConfig(
      appToken: APP_TOKEN_DEFAULT_SANDBOX,
      publicKey: PUBLIC_KEY_DEFAULT_SANDBOX,
      privateKey: PRIVATE_KEY_DEFAULT_SANDBOX,
      secretKey: SECRET_KEY_DEFAULT_SANDBOX,
    );
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('PayME SDK Example'),
        ),
        body: Center(
          child: Column(
            children: [
              Text(_accountStatus),
              ElevatedButton(
                onPressed: () async {
                  try {
                    final status = await PaymeSdkFlutter.login(
                        '1001', '0929000200', sdkArgs);
                    setState(() {
                      _accountStatus = status;
                      _connected = true;
                    });
                    print(status);
                  } catch (e) {
                    print(e);
                    setState(() {
                      _connected = false;
                    });
                  }
                },
                child: Text("1. Login"),
              ),
              ElevatedButton(
                onPressed: _connected
                    ? () async {
                        try {
                          final info = await PaymeSdkFlutter.getAccountInfo();
                          print(info);
                        } catch (e) {
                          print(e);
                        }
                      }
                    : null,
                child: Text("2. getAccountInfo"),
              ),
              ElevatedButton(
                onPressed: _connected
                    ? () async {
                        try {
                          final info =
                              await PaymeSdkFlutter.getSupportedServices();
                          print(info);
                        } catch (e) {
                          print(e);
                        }
                      }
                    : null,
                child: Text("3. getSupportedServices"),
              ),
              ElevatedButton(
                onPressed: _connected
                    ? () {
                        PaymeSdkFlutter.openWallet();
                      }
                    : null,
                child: Text("4. openWallet"),
              ),
              ElevatedButton(
                onPressed: _connected
                    ? () {
                        try {
                          PaymeSdkFlutter.deposit();
                        } catch (e) {
                          print(e);
                        }
                      }
                    : null,
                child: Text("5. deposit"),
              ),
              ElevatedButton(
                onPressed: _connected
                    ? () {
                        try {
                          PaymeSdkFlutter.openKYC();
                        } catch (e) {
                          print(e);
                        }
                      }
                    : null,
                child: Text("6. openKYC"),
              ),
              ElevatedButton(
                onPressed: _connected
                    ? () {
                        try {
                          PaymeSdkFlutter.openService('POWE', 'Điện');
                        } catch (e) {
                          print(e);
                        }
                      }
                    : null,
                child: Text("7. openService"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
2
likes
110
pub points
54%
popularity

PayME SDK Flutter is plugin for application integrate with PayME Platform.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, flutter_web_plugins

More

Packages that depend on payme_sdk_flutter