flutter_wing_checkout 1.0.0 copy "flutter_wing_checkout: ^1.0.0" to clipboard
flutter_wing_checkout: ^1.0.0 copied to clipboard

Flutter checkout for Wing Bank online payment, built on dart_wing: opens Wing's payment page in a web view and reports success or cancellation.

example/lib/main.dart

// Complete Wing checkout with flutter_wing_checkout. Configure it with a .env (copy
// .env.example) and run:
//
//   flutter run --dart-define-from-file=.env
//
// Demo only: DemoPaymentBackend calls Wing from the app with the .env
// secrets. In a real app, your server keeps them and authorizes payments;
// replace DemoPaymentBackend with calls to your server.
import 'package:flutter/material.dart';

import 'src/checkout_page.dart';
import 'src/payment_backend.dart';
import 'src/wing_config.dart';

void main() => runApp(
  ExampleApp(
    backend: WingConfig.missing.isEmpty
        ? DemoPaymentBackend(WingConfig.merchant())
        : null,
  ),
);

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key, this.backend, this.openCheckout});

  /// `null` when the .env is missing
  final PaymentBackend? backend;

  /// replaces Wing's web view in tests
  final OpenCheckout? openCheckout;

  @override
  Widget build(BuildContext context) => MaterialApp(
    title: 'flutter_wing_checkout',
    theme: ThemeData(colorSchemeSeed: Colors.lightGreen),
    home: switch ((backend, openCheckout)) {
      (null, _) => const SetupPage(),
      (final backend?, null) => CheckoutPage(backend: backend),
      (final backend?, final open?) => CheckoutPage(
        backend: backend,
        openCheckout: open,
      ),
    },
  );
}

/// Shown until the .env is configured.
class SetupPage extends StatelessWidget {
  const SetupPage({super.key});

  @override
  Widget build(BuildContext context) => Scaffold(
    appBar: AppBar(title: const Text('Wing credentials needed')),
    body: ListView(
      padding: const EdgeInsets.all(24),
      children: [
        const Text(
          'Copy .env.example to .env, fill in your Wing UAT '
          'credentials, and run:',
        ),
        const SizedBox(height: 12),
        const SelectableText(
          'flutter run --dart-define-from-file=.env',
          style: TextStyle(fontFamily: 'monospace'),
        ),
        const SizedBox(height: 12),
        Text('Missing: ${WingConfig.missing.join(', ')}'),
      ],
    ),
  );
}
0
likes
150
points
45
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter checkout for Wing Bank online payment, built on dart_wing: opens Wing's payment page in a web view and reports success or cancellation.

Repository (GitHub)
View/report issues

Topics

#wing #payment #checkout #cambodia

License

MIT (license)

Dependencies

dart_wing, flutter, flutter_inappwebview

More

Packages that depend on flutter_wing_checkout