b24_payment_sdk 1.2.1-beta.9 copy "b24_payment_sdk: ^1.2.1-beta.9" to clipboard
b24_payment_sdk: ^1.2.1-beta.9 copied to clipboard

Package payment SDK for merchant.

example/lib/main.dart

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

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

class Item {
  final double amount;
  final String currency;
  final String imagePath;

  Item({
    required this.amount,
    required this.currency,
    required this.imagePath,
  });
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'កម្មវិធី'),
    );
  }
}

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

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  bool isToggled = false;

  String? tranId =
      //"8F79D121E49E"
      "5AC437B99EEF";
  String? refererKey = "qMVkpHAer87FQvwFMwLwAav736DUkV";
  String? language = '';
  bool? darkMode = false;
  bool? isProduction = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Column(
        children: <Widget>[
          Expanded(
            child: Center(
              child: SingleChildScrollView(
                child: Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      TextField(
                        onChanged: (value) {
                          setState(() {
                            tranId = value;
                          });
                        },
                        decoration: const InputDecoration(labelText: 'tranId'),
                      ),
                      TextField(
                        onChanged: (value) {
                          setState(() {
                            refererKey = value;
                          });
                        },
                        decoration:
                            const InputDecoration(labelText: 'X-Referrer-Key'),
                      ),
                      TextField(
                        onChanged: (value) {
                          setState(() {
                            language = value;
                          });
                        },
                        decoration:
                            const InputDecoration(labelText: 'language'),
                      ),
                      CheckboxListTile(
                        title: const Text('Is productionS'),
                        value: isProduction,
                        onChanged: (value) {
                          setState(() {
                            isProduction = value;
                          });
                        },
                      ),
                      CheckboxListTile(
                        title: const Text('dark Mode'),
                        value: darkMode,
                        onChanged: (value) {
                          setState(() {
                            darkMode = value;
                          });
                        },
                      ),
                      const SizedBox(height: 10.0),
                      ElevatedButton(
                        onPressed: () {
                          // B24PaymentSdk.initSdk(
                          //     controller: context,
                          //     tranId: '$tranId',
                          //     refererKey: "$refererKey",
                          //     language: "$language",
                          //     //darkMode: null,
                          //     darkMode: darkMode,
                          //     isProduction: true,
                          //     testingEnv: "PILOT",
                          //     isPopup: true);

                          // B24PaymentSdk.initInstantPaymentSdk(
                          //     context: context,
                          //     customerSyncCode: "8223004",
                          //     refererKey: "8223",
                          //     isDarkmode: true,
                          //     isProduction: false,
                          //     language: "km",
                          //     testingEnv: "STAG",
                          //     isDisplayCurrencySymbol: false);

                          // B24PaymentSdk.instantPaymentSdkTopUp(
                          //     context: context,
                          //     paymentMethodId:
                          //         "eb905507-35e8-476d-a970-8ea0aa5e75cc",
                          //     refererKey: "8223",
                          //     isDarkmode: true,
                          //     isProduction: false,
                          //     language: "km",
                          //     testingEnv: "STAG",
                          //     isDisplayCurrencySymbol: false);

                               B24PaymentSdk.instantPaymentSdkDetail(
                              context: context,
                              customerSyncCode: "68ba4564173330741729fe5f",
                              paymentMethodId:
                                  "20c06d85-b57e-466a-ad8b-decb2f577f01",
                              refererKey: "7062",
                              isDarkmode: true,
                              isProduction: true,
                              language: "km",
                              testingEnv: "STAG",
                              isDisplayCurrencySymbol: false);
                        },
                        child: const Text('Checkout'),
                      ),
                      const SizedBox(height: 80),
                    ],
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}