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

The Easebuzz Flutter plugin simplifies secure payment integration in Flutter apps.

Flutter plugin for Easebuzz SDK.

Getting Started #

This flutter plugin is a wrapper around our Android and iOS SDKs. providing a streamlined way to integrate the Easebuzz payment gateway in your Flutter application. To understand the Easebuzz payment flow and its implementation, refer to the official documentation:: https://docs.easebuzz.in/

Prerequisites #

Before proceeding with the integration, ensure the following:
  • Merchant onboarding:

  • Test Integration Kit/Sandbox credentials:

    • Test credentials will be sent to your registered email ID. These credentials enable you to test the payment functionality in a secure sandbox environment, ensuring no real financial transactions are made.
    • After thorough testing, replace the test keys with live keys to process real payments in the production environment.

Installation #

This plugin is available on : https://pub.dev/packages/easebuzz_flutter

To integrate the easebuzz_flutter in your Flutter project, add the following dependency to your pubspec.yaml file:

 easebuzz_flutter: ^0.0.2

Alternatively, run the following command:

flutter pub add easebuzz_flutter

After adding the dependency, fetch the package by running:

flutter pub get

Usage #

To integrate the Easebuzz payment functionality, follow the steps below:

Import package

import 'package:easebuzz_flutter/easebuzz_flutter.dart';

Initialize the Plugin

Create an instance of the plugin and define a variable for the payment response:

final _easebuzzFlutterPlugin = EasebuzzFlutter();
String _paymentResponse = 'No payment response yet';

Implement Payment Functionality

Use the following method to initiate a payment:

// Method to initiate payment using the Easebuzz plugin
Future<void> initiatePayment() async {
  String accessKey = "Access key generated by the Initiate Payment API";
  String payMode = "This will either be 'test' or 'production'";
  try {
    // Invoke the method on the platform to initiate payment
    final paymentResponse = await _easebuzzFlutterPlugin.payWithEasebuzz(accessKey,payMode);

    setState(() {
      _paymentResponse = paymentResponse.toString(); // Store and display response
    });
  } on PlatformException catch (e) {
    setState(() {
      _paymentResponse = "Payment failed: ${e.message}";
    });
  }
}

Example Usage

Below is an example widget demonstrating how to integrate the initiatePayment method:

import 'package:flutter/material.dart';
import 'package:easebuzz_flutter/easebuzz_flutter.dart';
class CheckoutPaymentPage extends StatefulWidget {
  @override
  _PaymentScreenState createState() => _PaymentScreenState();
}
class _PaymentScreenState extends State<PaymentScreen> {
  final _easebuzzFlutterPlugin = EasebuzzFlutter();
  String _paymentResponse = 'No payment response yet';

  Future<void> initiatePayment() async {
    String accessKey = "Access key generated by the Initiate Payment API";
    String payMode = "test"; // Use "production" for live mode
    try {
      final paymentResponse = await _easebuzzFlutterPlugin.payWithEasebuzz(accessKey,payMode);
      setState(() {
        _paymentResponse = "Payment successful: $paymentResponse";
      });
    } on PlatformException catch (e) {
      setState(() {
        _paymentResponse = "Payment failed: ${e.message}";
      });
    }
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Easebuzz Payment'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(_paymentResponse),
            SizedBox(height: 20),
            ElevatedButton(
              onPressed: initiatePayment,
              child: Text('Initiate Payment'),
            ),
          ],
        ),
      ),
    );
  }
}

Troubleshooting #

If you encounter issues during integration or testing, refer to the https://docs.easebuzz.in/ or contact the support team.

4
likes
140
points
7.92k
downloads

Publisher

unverified uploader

Weekly Downloads

The Easebuzz Flutter plugin simplifies secure payment integration in Flutter apps.

Homepage

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on easebuzz_flutter