mypay_flutter 0.0.2 copy "mypay_flutter: ^0.0.2" to clipboard
mypay_flutter: ^0.0.2 copied to clipboard

outdated

An unofficial Flutter plugin that enables the integration of the MyPay Payment Gateway into applications, allowing users to make payments using their MyPay Wallet.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:mypay_flutter/model/my_pay_config.dart';
import 'package:mypay_flutter/mypay_flutter.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'MyPay Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.green,
      ),
      home: const EsewaApp(title: 'MyPay Payment'),
    );
  }
}

class EsewaApp extends StatefulWidget {
  const EsewaApp({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<EsewaApp> createState() => _EsewaAppState();
}

class _EsewaAppState extends State<EsewaApp> {
  String message = '';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            /// Example Use case - 1
            MyPayButton(
              apiKey: "API-KEY",
              paymentConfig: MyPayConfig(
                  amount: 2000,
                  environment: MyPayEnvironment.dev,
                  orderId: "QWE-SEW-SFES-QXZS",
                  merchantId: "CAFEQ",
                  userName: "username1",
                  password: "decryptedPassword",
                  returnUrl: "https://mypay.com.np/successCallBackUrl"),
              width: 100,
              onFailure: (result) async {
                message = result.message;
                if (kDebugMode) {
                  print("Transaction Failed");
                }
              },
              onSuccess: (result) async {
                message = result.message;
                if (kDebugMode) {
                  print("Transaction Successful");
                }
              },
              onCancel: () {
                message = "Transaction Cancelled";
                if (kDebugMode) {
                  print("Transaction Cancelled");
                }
              },
            ),

            if (message.isNotEmpty)
              Text('Console: Payment Info, Message: $message'),
          ],
        ),
      ),
    );
  }
}
23
likes
0
points
46
downloads

Publisher

unverified uploader

Weekly Downloads

An unofficial Flutter plugin that enables the integration of the MyPay Payment Gateway into applications, allowing users to make payments using their MyPay Wallet.

Repository (GitLab)
View/report issues

License

unknown (license)

Dependencies

dio, flutter, flutter_inappwebview

More

Packages that depend on mypay_flutter