toyyibpay 2.1.0 copy "toyyibpay: ^2.1.0" to clipboard
toyyibpay: ^2.1.0 copied to clipboard

Flutter helper to create ToyyibPay bills, open a WebView checkout, parse the return URL, and optionally verify the transaction via ToyyibPay APIs for simple in-app payments.

example/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'ToyyibPay Example',
      home: CheckoutDemo(),
    );
  }
}

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

  Future<void> _startPayment(BuildContext context) async {
    final result = await ToyyibpayCheckout.startPayment(
      context: context,
      apiKey: '<YOUR_SECRET_KEY>',
      categoryCode: '<YOUR_CATEGORY_CODE>',
      billName: 'Demo Bill',
      billDescription: 'Testing ToyyibPay checkout',
      amountCents: '1000', // RM10.00
      returnDeepLink: 'https://yourapp.example/return',
      payerName: 'Test User',
      payerEmail: 'test@example.com',
      payerPhone: '0123456789',
    );

    if (context.mounted) {
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(
            content: Text(
                'Payment status: ${result.status} (bill: ${result.billCode})')),
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('ToyyibPay Example')),
      body: Center(
        child: ElevatedButton(
          onPressed: () => _startPayment(context),
          child: const Text('Pay RM10.00'),
        ),
      ),
    );
  }
}
3
likes
160
points
18
downloads

Publisher

verified publishergoutam.info

Weekly Downloads

Flutter helper to create ToyyibPay bills, open a WebView checkout, parse the return URL, and optionally verify the transaction via ToyyibPay APIs for simple in-app payments.

Repository (GitHub)
View/report issues

Topics

#payments #checkout #toyyibpay #malaysia

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http, webview_flutter

More

Packages that depend on toyyibpay