dart_payway_partner 1.0.0 copy "dart_payway_partner: ^1.0.0" to clipboard
dart_payway_partner: ^1.0.0 copied to clipboard

A self registration for aba payway

example/lib/main.dart

import 'dart:convert';
import 'package:dart_payway_partner/dart_payway_partner.dart' hide debugPrint;
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';

void main() async {
  await dotenv.load(fileName: ".env");
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  late String referer_id = "Merchant001";

  late PaywayPartnerService service;

  @override
  void initState() {
    service = PaywayPartnerService(
        partner: PaywayPartner(
      partnerName: dotenv.env['ABA_PARTNER_NAME'] ?? '',
      partnerID: dotenv.env['ABA_PARTNER_ID'] ?? '',
      partnerKey: dotenv.env['ABA_PARTNER_KEY'] ?? '',
      partnerPrivateKey: utf8
          .decode(base64.decode(dotenv.env['ABA_PARTNER_PRIVATE_KEY'] ?? "")),
      partnerPublicKey: utf8
          .decode(base64.decode(dotenv.env['ABA_PARTNER_PUBLIC_KEY'] ?? "")),
      baseApiUrl: dotenv.env['ABA_PARTNER_API_URL'] ?? '',
    ));

    super.initState();
  }

  Future<void> registerMerchant() async {
    final merchant = PaywayPartnerRegisterMerchant(
      pushback_url: 'https://www.mylekha.org/',
      redirect_url: 'https://www.mylekha.org/',
      type: 0,
      register_ref: referer_id,
    );
    try {
      var registerResponse = await service.registerMerchant(merchant: merchant);
      debugPrint(registerResponse.toJson());
    } catch (e) {}
  }

  Future<void> checkMerchant() async {
    final merchant = PaywayPartnerCheckMerchant(
      register_ref: referer_id,
    );
    try {
      var checkResponse = await service.checkMerchant(merchant: merchant);
      debugPrint(checkResponse.toJson());
    } catch (e) {}
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextButton(
                onPressed: registerMerchant, child: Text("register merchant")),
            TextButton(onPressed: checkMerchant, child: Text("check merchant"))
          ],
        ),
      ),
    );
  }
}
1
likes
0
points
54
downloads

Publisher

verified publishermylekha.app

Weekly Downloads

A self registration for aba payway

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

crypto, dio, encrypt, intl, logger, pointycastle

More

Packages that depend on dart_payway_partner