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

A Flutter plugin for Zoho Payments Checkout.

Zoho Payments Flutter SDK #

A Flutter plugin for integrating Zoho Payments checkout into your Android and iOS apps. Accept payments via cards, net banking, and UPI with a pre-built, secure checkout UI.

Features #

  • Pre-built checkout UI — no need to build payment forms
  • Supports Card, Net Banking, and UPI payment methods
  • Sandbox and Live environments for testing and production
  • US and India domain support
  • Type-safe result handling with Dart sealed classes

Requirements #

Platform Minimum Version
Dart SDK 3.4.0+
Flutter 3.22.0+
Android API 26 (Android 8.0)+
iOS 15.6+

Installation #

Add the dependency to your pubspec.yaml:

dependencies:
  zoho_payments_flutter_sdk: ^1.0.0

Then run:

flutter pub get

Android Setup #

Add the Zoho Payments SDK maven repository to your project-level settings.gradle (or build.gradle):

allprojects {
    repositories {
        maven { url 'https://maven.zohodl.com' }
    }
}

Quick Start #

import 'package:zoho_payments_flutter_sdk/zoho_payments_flutter_sdk.dart';

// 1. Create an SDK instance
final sdk = ZohoPaymentsFlutterSdk();

// 2. Initialize with your credentials
await sdk.initialize(
  apiKey: 'your_api_key',
  accountId: 'your_account_id',
);

// 3. Configure checkout options
final options = ZohoPaymentsCheckoutOptions(
  paymentSessionId: 'your_payment_session_id',
);

// 4. Show checkout and handle the result
final result = await sdk.showCheckout(
  options,
  domain: ZohoPaymentsDomain.india,
  environment: ZohoPaymentsEnvironment.live,
);

switch (result) {
  case ZohoPaymentsSuccess():
    print('Payment ID: ${result.paymentId}');
    print('Signature: ${result.signature}');
  case ZohoPaymentsFailure():
    print('Error: ${result.code} - ${result.message}');
}

Usage #

Step 1: Obtain Credentials #

Get your API Key and Account ID from the Zoho Payments Dashboard.

Step 2: Create a Payment Session #

Create a payment session on your backend using the Payments Session API. The API returns a payment_session_id that you pass to the Flutter SDK.

Step 3: Initialize the SDK #

Call initialize() before showing the checkout. This sets up the SDK with your merchant credentials.

final sdk = ZohoPaymentsFlutterSdk();

await sdk.initialize(
  apiKey: 'your_api_key',
  accountId: 'your_account_id',
);

Step 4: Configure Checkout Options #

Create a ZohoPaymentsCheckoutOptions object with the payment session ID and optional customer details:

final options = ZohoPaymentsCheckoutOptions(
  paymentSessionId: 'ps_xxxxxxxxxxxxxxx',
  // Optional fields:
  description: 'Order #1234',
  invoiceNumber: 'INV-1234',
  referenceNumber: 'REF-5678',
  name: 'John Doe',
  email: 'john@example.com',
  phone: '+919876543210',
  paymentMethod: ZohoPaymentsPaymentMethod.upi, // Pre-select a payment method
);

Step 5: Show Checkout #

Launch the payment checkout UI. The method returns a ZohoPaymentsResult — either ZohoPaymentsSuccess or ZohoPaymentsFailure.

final result = await sdk.showCheckout(
  options,
  domain: ZohoPaymentsDomain.india,       // or ZohoPaymentsDomain.us
  environment: ZohoPaymentsEnvironment.live, // or .sandbox for testing
);

Step 6: Handle the Result #

Use Dart's pattern matching on the sealed ZohoPaymentsResult class:

switch (result) {
  case ZohoPaymentsSuccess():
    // Payment succeeded
    print('Payment ID: ${result.paymentId}');
    print('Signature: ${result.signature}');
    if (result.mandateId != null) {
      print('Mandate ID: ${result.mandateId}');
    }
    // Verify the signature on your backend before fulfilling the order

  case ZohoPaymentsFailure():
    // Payment failed or was cancelled
    print('Error Code: ${result.code}');
    print('Error Message: ${result.message}');
}

Or use is checks:

if (result is ZohoPaymentsSuccess) {
  // Handle success
} else if (result is ZohoPaymentsFailure) {
  // Handle failure
}

Documentation #

📖 Complete Integration Guide

License #

MIT License. See LICENSE for details.