LightSpeedPay Flutter SDK

Overview

LightSpeedPay Flutter SDK allows you to easily integrate payment functionalities into your Flutter applications. With this SDK, you can initiate transactions seamlessly using the LightSpeedPay class.

Installation

To use the LightSpeedPay SDK in your Flutter project, follow these steps:

  1. Add the following dependency to your pubspec.yaml file:
dependencies:
  lightspeedpay_flutter_sdk: ^1.0.0
  1. Run the following command to install the dependency:
flutter pub get

Usage

Initiating a Transaction

To initiate a transaction, use the initiateTransaction function of the LightSpeedPay class. Below is the function signature:

Future<void> initiateTransaction(
  String amount,
  String method,
  String description,
  String billId,
  String customerName,
  String vpaId,
  String apiKey,
  String apiSecret,
)
  • amount: The amount of the transaction.
  • method: The payment method (only "unknown" is accepted).
  • description: Description of the transaction.
  • billId: Unique identifier for the bill.
  • customerName: Name of the customer.
  • vpaId: VPA ID (only compulsory when method is "collect").
  • apiKey: Your API key.
  • apiSecret: Your API secret.

Example

import 'package:flutter/material.dart';
import 'package:lightspeedpay_flutter_sdk/lightspeedpay_flutter_sdk.dart';

class MyTransactionScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Initiate Transaction'),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () async {
            try {
              await LightSpeedPay().initiateTransaction(
                "100.00",
                "unknown",
                "Sample transaction",
                "123456",
                "John Doe",
                "john.doe@upi", // Example VPA ID, replace with actual one if needed
                "YOUR_API_KEY",
                "YOUR_API_SECRET",
              );
              print('Transaction initiated successfully');
            } catch (e) {
              print('Error initiating transaction: $e');
            }
          },
          child: Text('Initiate Transaction'),
        ),
      ),
    );
  }
}

Replace "YOUR_API_KEY" and "YOUR_API_SECRET" with your actual API credentials from LightSpeedPay Dashboard.