grootpay_sdk 0.0.4 copy "grootpay_sdk: ^0.0.4" to clipboard
grootpay_sdk: ^0.0.4 copied to clipboard

Flutter SDK for integrating GrootPay payments.

example/lib/main.dart

import 'package:flutter_screenutil/flutter_screenutil.dart';

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

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

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

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

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(360, 690), // adjust if needed
      minTextAdapt: true,
      splitScreenMode: true,
      builder: (context, child) {
        return MaterialApp(
          home: Scaffold(
            appBar: AppBar(
              title: const Text('Sdk example app'),
            ),
            body: Center(
              child: Builder(builder: (context) {
                return TextButton(
                  child: const Text("Pay With GrootPay"),
                  onPressed: () {
                    GrootpaySdk().initPayment(
                      context: context,
                      paymentConfig: PaymentConfig(
                        environment: Environment.development,
                        clientId: "first-epg1",
                        clientSecret: "test-secret",
                      ),
                      paymentCheckout: PaymentCheckout(
                        totalAmount: 100,
                        serviceType: "Online Payment",
                      ),
                      onPayment: (PaymentResponse success) {},
                    );
                  },
                );
              }),
            ),
          ),
        );
      },
    );
  }
}