Skip to main content

paywit 0.1.0 copy "paywit: ^0.1.0" to clipboard
paywit: ^0.1.0 copied to clipboard

Accept USDC payments in your Flutter app. Creates a Paywit payment, opens the hosted checkout, and returns the settled result — no native setup required.

example/lib/main.dart

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

// Both values come from your Paywit dashboard.
const publishableKey = String.fromEnvironment('PAYWIT_PUBLISHABLE_KEY');
const apiBaseUrl = String.fromEnvironment('PAYWIT_API_BASE_URL');

void main() => runApp(const ExampleApp());

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

  @override
  State<ExampleApp> createState() => _ExampleAppState();
}

class _ExampleAppState extends State<ExampleApp> {
  late final Paywit _paywit = Paywit(
    publishableKey: publishableKey,
    apiBaseUrl: apiBaseUrl,
  );

  String _message = 'Tap to pay 1 USDC.';

  @override
  void dispose() {
    _paywit.dispose();
    super.dispose();
  }

  void _show(String message) => setState(() => _message = message);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Paywit example',
      theme: ThemeData(colorSchemeSeed: Colors.indigo, useMaterial3: true),
      home: Scaffold(
        appBar: AppBar(title: const Text('Paywit example')),
        body: Center(
          child: Padding(
            padding: const EdgeInsets.all(24),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(_message, textAlign: TextAlign.center),
                const SizedBox(height: 24),
                PaywitButton(
                  paywit: _paywit,
                  amount: 1,
                  description: 'Example order',
                  onResult: (result) => _show(
                    switch (result.status) {
                      PaymentStatus.paid => 'Paid. Thank you!',
                      PaymentStatus.expired => 'The payment window closed.',
                      PaymentStatus.canceled => 'Checkout dismissed.',
                      _ => 'Payment ${result.status.name}.',
                    },
                  ),
                  onError: (error) => _show(error.message),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
0
likes
160
points
53
downloads

Documentation

API reference

Publisher

verified publisherpaywit.xyz

Weekly Downloads

Accept USDC payments in your Flutter app. Creates a Paywit payment, opens the hosted checkout, and returns the settled result — no native setup required.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_custom_tabs, http

More

Packages that depend on paywit