smart_pay 0.0.1 copy "smart_pay: ^0.0.1" to clipboard
smart_pay: ^0.0.1 copied to clipboard

A unified Flutter payments toolkit. Configure gateways (Stripe now; more soon), render a single methods widget, and checkout via one API.

example/lib/main.dart

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

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  SmartPay.configure(
    SmartPayConfig(
      providers: [
        StripeProvider(publishableKey: 'pk_test_123', secretKey: 'sk_test_123'),
      ],
    ),
  );

  runApp(const SmartPayExampleApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'SmartPay Example',
      theme: ThemeData(colorSchemeSeed: Colors.blue, useMaterial3: true),
      home: const ExampleHomePage(),
    );
  }
}

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

  @override
  State<ExampleHomePage> createState() => _ExampleHomePageState();
}

class _ExampleHomePageState extends State<ExampleHomePage> {
  String? _lastResult;

  Future<void> _pay() async {
    final result = await SmartPay.checkout(
      const PayRequest(
        amountMinorUnits: 1999,
        currency: 'USD',
        description: 'SmartPay Demo Order #1001',
        flowMode: PaymentFlowMode.testing,
      ),
    );
    setState(() => _lastResult = result.toString());
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('SmartPay Example')),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          SmartPayMethods(
            store: SmartPay.store,
            onMethodSelected: (provider) {
              debugPrint('Selected provider: ${provider.id}');
            },
          ),
          const SizedBox(height: 24),
          Padding(
            padding: const EdgeInsets.all(16.0),
            child: FilledButton(
              onPressed: _pay,
              child: const Text('Pay \$19.99'),
            ),
          ),
          if (_lastResult != null)
            Padding(
              padding: const EdgeInsets.all(16.0),
              child: Text('Last result: $_lastResult'),
            ),
        ],
      ),
    );
  }
}
2
likes
0
points
17
downloads

Publisher

verified publishermwaqas.mobvers.com

Weekly Downloads

A unified Flutter payments toolkit. Configure gateways (Stripe now; more soon), render a single methods widget, and checkout via one API.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_stripe, http

More

Packages that depend on smart_pay