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

A Flutter sdk for Amorio Payment Gateway integration with InAppWebView support.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:payment_gateway_amorio/amorio_PG_webview.dart';
import 'dart:math';


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

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

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

class _MyAppState extends State<MyApp> {
  String _paymentStatus = 'No payment initiated';

  void _updatePaymentStatus(String status) {
    setState(() {
      _paymentStatus = status;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: MyHomePage(
        paymentStatus: _paymentStatus,
        onUpdatePaymentStatus: _updatePaymentStatus,
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final String paymentStatus;
  final Function(String) onUpdatePaymentStatus;

  const MyHomePage({
    super.key,
    required this.paymentStatus,
    required this.onUpdatePaymentStatus,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Amorio Payment Gateway'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Image.asset(
              'assets/images/logo.png',
              width: 350,
              height: 180,
              fit: BoxFit.contain,
            ),
            const SizedBox(height: 30),
            Text('Payment Status: $paymentStatus'),
            
            const SizedBox(height: 40),
            const Text(
              'Tap to start payment',
              style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
            ),
            const SizedBox(height: 20),
            SizedBox(
              width: double.infinity,
              height: 60,
              child: ElevatedButton(
                onPressed: () async {
                  final amorioPayment = AmorioPayment(
                    // backendUrl: 'https://www.amoriotech.in/amoriogate/Api/HandleApi/',
                    businessKey: '_LUM7wiwshgQGOtASvNCam5ny6MWgMy1kdY4KDnpEfE',
                    returnUrl: 'myapp://payment',
                  );


                  final response = await amorioPayment.startPayment(
                    context: context,
                    name: 'cathy',
                    email: '[email protected]',
                    phone: '9876543012',
                    amount: 100.0,
                    orderId: (Random().nextInt(900000) + 100000).toString(),
                  );

                  // Extract fields
                  int code = response["code"];
                  String message = response["message"];
                  String txnId = response["data"]["txn_id"] ?? "";
                  String orderIdResp = response["data"]["order_id"] ?? "";
                  String dateTime = response["data"]["datetime"] ?? "";

                  // Print to debug
                  print("STATUS: $message");
                  print("TRANSACTION ID: $txnId");
                  print("ORDER ID: $orderIdResp");
                  print("DATETIME: $dateTime");

                  // Update UI
                  if (code == 200) {
                    onUpdatePaymentStatus(
                      "Success\nTxn: $txnId\nOrder: $orderIdResp\nTime: $dateTime"
                    );
                  } else {
                    onUpdatePaymentStatus(
                      "Failed\nTxn: $txnId\nOrder: $orderIdResp"
                    );
                  }

                },
                style: ElevatedButton.styleFrom(
                  backgroundColor: Colors.blue,
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(12),
                  ),
                ),
                child: const Text(
                  'Pay ₹100.00',
                  style: TextStyle(
                    fontSize: 20,
                    fontWeight: FontWeight.bold,
                    color: Colors.white
                  ),
                ),
              ),
            ),
            const SizedBox(height: 20),
            // SizedBox(
            //   width: double.infinity,
            //   height: 60,
            //   child: ElevatedButton(
            //     onPressed: () async {
            //       await Navigator.push(
            //         context,
            //         MaterialPageRoute(
            //           builder: (_) => PaymentWebView(url: 'https://www.w3schools.com/'),
            //         ),
            //       );
            //     },
            //     style: ElevatedButton.styleFrom(
            //       backgroundColor: Colors.green,
            //       shape: RoundedRectangleBorder(
            //         borderRadius: BorderRadius.circular(12),
            //       ),
            //     ),
            //     child: const Text(
            //       'Open W3Schools',
            //       style: TextStyle(
            //         fontSize: 20,
            //         fontWeight: FontWeight.bold,
            //         color: Colors.white
            //       ),
            //     ),
            //   ),
            // ),
          ],
        ),
      ),
    );
  }
}
0
likes
140
points
50
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter sdk for Amorio Payment Gateway integration with InAppWebView support.

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_inappwebview, html, http, plugin_platform_interface, url_launcher, webview_flutter

More

Packages that depend on payment_gateway_amorio

Packages that implement payment_gateway_amorio