패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.1

easebuzz_flutter_sdk

Easebuzz Flutter SDK는 Android, iOS 및 웹 플랫폼에서 안전한 결제 통합을 간편하게 만듭니다.

30일 다운로드
95
좋아요
10
Pub 점수
70

패키지 설치

flutter pub add easebuzz_flutter_sdk

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Easebuzz Flutter SDK는 안드로이드, iOS 및 웹 플랫폼에서 Flutter 애플리케이션에 원활하고 안전한 결제 통합을 가능하게 합니다. 최소한의 설정으로 결제 기능 추가 프로세스를 단순화하며, 보안 표준을 준수합니다. 개발자는 일관된 API를 활용하여 거래 처리, 결제 흐름 관리, 단일 크로스플랫폼 솔루션 내에서 다양한 결제 수단을 지원할 수 있습니다. 이 SDK는 생산 환경에서 신뢰성, 성능, 사용 편의성을 고려해 설계되었습니다.

사용 사례

  • 앱 내 구매
  • 전자상거래 체크아웃
  • 구독 결제
  • 디지털 서비스 결제
  • 온라인 티켓 예약
  • 기부금 모집

주요 기능

  • 크로스 플랫폼 호환성
  • 안전한 결제 처리
  • Flutter Pub를 통한 간단한 통합
  • 다양한 결제 수단 지원
  • 실시간 거래 상태 업데이트
  • 내장된 오류 처리

적합한 대상

  • 모바일 전자상거래 앱
  • 웹 기반 결제 포털
  • 구독 기반 서비스
  • 이벤트 티켓팅 플랫폼
  • 비영리 기부 시스템

고려 사항

  • 유효한 Easebuzz 계정 자격 증명이 필요합니다
  • 지원되는 지역에 한정
  • 네트워크 연결에 의존
  • 생산 환경에 적절한 구성이 필요합니다
  • 추가적인 백엔드 검증이 필요할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Easebuzz Flutter SDK

The Easebuzz Flutter SDK provides seamless integration with the Easebuzz payment gateway, enabling merchants to securely collect online payments through various payment modes such as credit cards, debit cards, UPI, and more. This SDK ensures robust encryption and security measures to safeguard customer data. Easebuzz is a fully API-integrated platform, simplifying payment processing for websites and mobile apps.


Features

  • Multiple payment modes: Credit/Debit Cards, UPI, Net Banking, and more.
  • Secure and encrypted transactions.
  • Easy integration with Flutter apps.
  • Fully API-integrated payment gateway.
  • Sandbox environment for testing.

Prerequisites

Before integrating the Easebuzz Flutter SDK, ensure the following:

  1. Merchant Onboarding

  2. Sandbox/Test Integration Credentials

    • Test credentials will be sent to your registered email address. Use these credentials to test payment functionality in a secure sandbox environment.
    • Once testing is complete, replace the test keys with live keys to enable real transactions in the production environment.
  3. Platform-Specific Configuration

    • Web:

      • Add the following two <script> tags in the <head> section of your web/index.html:

        <script src="https://ebz-static.s3.ap-south-1.amazonaws.com/easecheckout/v2.0.0/easebuzz-checkout-v2.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
        

Installation

To integrate the SDK, follow these steps:

  1. Add the Dependency

    Add the following to your pubspec.yaml file:

    dependencies:
      easebuzz_flutter_sdk: ^0.0.1
    

    Fetch the package by running:

    flutter pub get
    
  2. Import the Package

    Import the SDK in your Dart file:

    import 'package:easebuzz_flutter_sdk/easebuzz_flutter_sdk.dart';
    

How to Use

Step 1: Initialize the SDK

Before using any functionality from the SDK, initialize the EasebuzzFlutterSdk instance:

final EasebuzzFlutterSdk _easebuzzFlutterPlugin = EasebuzzFlutterSdk();

Step 2: Create the Payment Model

Start by creating an instance of EasebuzzPaymentModel:

final paymentModel = EasebuzzPaymentModel(
  txnid: "TEST${DateTime.now().millisecondsSinceEpoch}", // Unique transaction ID
  amount: amount, // Payment amount
  productinfo: productName, // Product/service name
  firstname: "John", // Customer's first name
  email: "john@example.com", // Customer's email
  phone: "9999999999", // Customer's phone number
  surl: "https://your-success-url.com", // Success URL
  furl: "https://your-failure-url.com", // Failure URL
  splitPayments: jsonEncode({"your_label": amount}), // Split payments if applicable
  key: key, // Merchant key
);

Note: Replace surl and furl with your actual success and failure handling URLs.

Step 3: Generate Hash

Generate a hash to ensure secure communication:

final hash = await _easebuzzFlutterPlugin.generateHash(
  paymentModel: paymentModel,
  key: key, // Merchant key
  salt: salt, // Merchant salt
);
Step 4: Initiate Payment Link
For Mobile Platforms (Android/iOS):

Use the initiateLink method:

final response = await _easebuzzFlutterPlugin.initiateLink(
  isTestMode: true, // Set to `false` for production
  hash: hash,
  paymentModel: paymentModel,
);
For Web:

The initiateLink method is not supported on web due to CORS issues. Instead, generate the access key on your backend or cloud function by calling the Easebuzz API:

Example for generating access key:

final response = await createAccessTokenForWeb(
  hash: hash,
  requestBody: paymentModel.toJson(),
);

Step 4: Proceed to Payment

After obtaining the access key from initiateLink or your backend, proceed with the payment:

final paymentResponse = await _easebuzzFlutterPlugin.payWithEasebuzz(
  response, // Access key from initiateLink response
  "test", // Payment mode: "test" for sandbox or "production" for live
);

Full Example for Payment Integration

Here’s an example of how to use the Easebuzz SDK in a Flutter app:

Future<void> initiatePayment({
  required String productName,
  required double amount,
  required Function(String) onSuccess,
  required Function(String) onError,
}) async {
  final paymentModel = EasebuzzPaymentModel(
    txnid: "TEST${DateTime.now().millisecondsSinceEpoch}",
    amount: amount,
    productinfo: productName,
    firstname: "John",
    email: "john@example.com",
    phone: "9999999999",
    surl: "https://your-success-url.com",
    furl: "https://your-failure-url.com",
    splitPayments: jsonEncode({"your_label": amount}),
    key: key,
  );

  try {
    // Generate hash
    final hash = await _easebuzzFlutterPlugin.generateHash(
      paymentModel: paymentModel,
      key: EaseBuzzPaymentRepository.key,
      salt: EaseBuzzPaymentRepository.salt,
    );

    if (hash == null) {
      onError("Failed to generate hash.");
      return;
    }

    // Initiate payment link
    final response = kIsWeb
        ? await createAccessTokenForWeb(
            hash: hash, requestBody: paymentModel.toJson()) // 
        : await _easebuzzFlutterPlugin.initiateLink(
            isTestMode: true, // Set to false for production
            hash: hash,
            paymentModel: paymentModel,
          );

    if (response == null) {
      onError("Failed to initiate payment link.");
      return;
    }

    // Proceed to payment
    final paymentResponse =
        await _easebuzzFlutterPlugin.payWithEasebuzz(response, "test");

    if (paymentResponse != null) {
      // Handle successful payment
      onSuccess("Payment successful: $paymentResponse");
    } else {
      // Handle failed payment
      onError("Payment failed: Payment response is null.");
    }
  } on PlatformException catch (e) {
    // Handle platform-specific errors
    onError("Payment failed: ${e.message}");
  } catch (e) {
    // Handle general errors
    onError("Payment failed: ${e.toString()}");
  }
}

/// Call this above method on paybutton

Future<void> _processPayment(BuildContext context, Product product) async {
    await paymentService.initiatePayment(
      productName: product.title,
      amount: product.price,
      onSuccess: (response) {
        _showFeedbackSnackBar(
          context,
          'Payment Successful: $response',
          Colors.green,
        );
      },
      onError: (error) {
        _showFeedbackSnackBar(
          context,
          'Payment Failed: $error',
          Colors.red,
        );
      },
    );
  }


Why Use Backend for Web Integration?

  • Due to CORS restrictions, the Initiate Payment API must be called from your backend or cloud function.
  • Backend integration ensures secure handling of the access key.

Example Screen Recording

Watch the example screen recordings for different platforms to see how to integrate the Easebuzz Flutter SDK:


Resources


카테고리

의존성

의존성 목록 4 개

  • crypto^3.0.6
  • dio^5.7.0
  • plugin_platform_interface^2.1.8
  • web^1.1.0

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.