flutter_gbprimepay_qrcode 0.0.5 copy "flutter_gbprimepay_qrcode: ^0.0.5" to clipboard
flutter_gbprimepay_qrcode: ^0.0.5 copied to clipboard

The GBPrimePay QRCode package allows you to request a QRCode image from the QRCash service provided by GBPrimePay.

example/lib/main.dart

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:example/firebase_options.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_gbprimepay_qrcode/flutter_gbprimepay_qrcode.dart';
import 'package:get/get.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await dotenv.load(fileName: ".env");

  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  // use firestore emulator
  FirebaseFirestore.instance.useFirestoreEmulator('10.0.2.2', 8088);

  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 GetMaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'GBPrimePay QRCode Demo'),
    );
  }
}

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: Padding(
        padding: const EdgeInsets.all(8.0),
        child: LayoutBuilder(builder: (context, constraints) {
          return ElevatedButton(
            style: ElevatedButton.styleFrom(
              minimumSize: Size(constraints.maxWidth, 48),
            ),
            onPressed: () {
              // pay with gbprimapay qrcode

              // create timestamp as referenceId
              final referenceNo =
                  DateTime.now().millisecondsSinceEpoch.toString();
              const amount = 1.0;

              // show dialog
              Get.dialog(
                GBPrimePayQRCode(
                  collectionRef:
                      FirebaseFirestore.instance.collection("payment"),
                  referenceNo: referenceNo,
                  detail: "Sample T-Shirt",
                  amount: amount,
                  backgroundUrl: dotenv.env['BACKGROUND_URL'] ?? "",
                  token: dotenv.env['GB_TOKEN'] ?? "",
                  completeMessage1: "Payment recieved!",
                  completeMessage2: "Thank You",
                  completeButtonTitle: "Close",
                  completeButtonOnTap: () => Get.back(),
                  failMessage1: "Payment not complete!",
                  failMessage2: "Try other payment method",
                  failButtonTitle: "Close",
                  failButtonOnTap: () => Get.back(),
                ),
                useSafeArea: true,
              );
            },
            child: const Text("Pay via QRCode"),
          );
        }),
      ),
    );
  }
}
3
likes
0
points
57
downloads

Publisher

verified publisherredlinesoft.net

Weekly Downloads

The GBPrimePay QRCode package allows you to request a QRCode image from the QRCash service provided by GBPrimePay.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cloud_firestore, flutter, http

More

Packages that depend on flutter_gbprimepay_qrcode