sabpaisa_flutter 0.0.29 copy "sabpaisa_flutter: ^0.0.29" to clipboard
sabpaisa_flutter: ^0.0.29 copied to clipboard

Flutter plugin for SabPaisa SDK. To know more about SabPaisa, visit http://sabpaisa.in.

SabPaisa Flutter #

Flutter plugin for SabPaisa SDK.

pub package

Getting Started #

This flutter plugin is a wrapper around our Android and iOS SDKs.

To know more about SabPaisa payment flow and steps involved, read up here: https://SabPaisa.com/docs/

Installation #

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

Add this to dependencies in your app's pubspec.yaml

sabpaisa_flutter: ^0.0.3

Note for Android: Make sure that the minimum API level for your app is 19 or higher.

Proguard rules #

If you are using proguard for your builds, you need to add following lines to proguard files

-keepattributes *Annotation*
-dontwarn com.SabPaisa.**
-keep class com.SabPaisa.** {*;}
-optimizations !method/inlining/
-keepclasseswithmembers class * {
  public void onPayment*(...);
}

Note for iOS: Make sure that the minimum deployment target for your app is iOS 10.0 or higher. Also, don't forget to enable bitcode for your project.

Run flutter packages get in the root directory of your app.

Usage #

Sample code to integrate can be found in https://gitlab.com/eywa-public/sabpaisaplugins2025examples/react-native-example.

Import package

import 'package:sabpaisa_flutter/sabpaisa_flutter.dart';

Create SabPaisa instance

_SabPaisa = SabPaisa();

Attach event listeners

The plugin uses event-based communication, and emits events when payment fails or succeeds.

The event names are exposed via the constants EVENT_PAYMENT_SUCCESS and EVENT_PAYMENT_ERROR from the SabPaisa class.

Use the on(String event, Function handler) method on the SabPaisa instance to attach event listeners.


_SabPaisa.on(SabPaisa.EVENT_PAYMENT_SUCCESS, _handlePaymentSuccess);
_SabPaisa.on(SabPaisa.EVENT_PAYMENT_ERROR, _handlePaymentError);

The handlers would be defined somewhere as


void _handlePaymentSuccess(TransactionResponsesModel response) {
  // Do something when payment succeeds
}

void _handlePaymentError(TransactionResponsesModel response) {
  // Do something when payment fails
}

To clear event listeners, use the clear method on the SabPaisa instance.

_SabPaisa.clear(); // Removes all listeners

Setup options

Map<String, Object> getPaymentOptions() {
    return {
    'first_name': 'firstnamereact',
            'last_name': 'lastnamereact',
            'currency': 'INR',
            'mobile_number': '9999999999',
            'email_id': 'lokesh.d@eywa.com',
            'client_code': 'DJ020',
            'aes_iv': 'M+aUFgRMPq7ci+Cmoytp3KJ2GPBOwO72Z2Cjbr55zY7++pT9mLES2M5cIblnBtaX',
            'aes_key': 'ISTrmmDC2bTvkxzlDRrVguVwetGS8xC/UFPsp6w+Itg=',
            'user_name': 'DJL754@sp',
            'password': '4q3qhgmJNM4m',
            'env': 'staging', // staging/prod
            'txn_id': '<Unique Transaction Id>',
            'amount': '1',
            'callback_url': 'http://localhost:8082',
            'udf1': '1',
            'udf2': '2',
            'udf3': '3',
            'udf4': '4',
            'udf5': '5',
            'udf6': '6',
            'udf7': '7',
            'udf8': '8',
            'udf9': '9',
            'udf10': '10',
            'udf11': '11',
            'udf12': '12',
            'udf13': '13',
            'udf14': '14',
            'udf15': '15',
            'udf16': '16',
            'udf17': '17',
            'udf18': '18',
            'udf19': '19',
            'udf20': '20'


    };
  }

Open Checkout

_SabPaisa.open(options);

Troubleshooting #

Enabling Bitcode #

Open ios/Podfile and find this section:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

Set config.build_settings['ENABLE_BITCODE'] = 'YES'.

Setting Swift version #

Add the following line below config.build_settings['ENABLE_BITCODE'] = 'YES':

config.build_settings['SWIFT_VERSION'] = '5.0'

CocoaPods could not find compatible versions for pod "sabpaisa_flutter" when running pod install #

Specs satisfying the `sabpaisa_flutter (from
    `.symlinks/plugins/sabpaisa_flutter/ios`)` dependency were found, but they
    required a higher minimum deployment target.

This is due to your minimum deployment target being less than iOS 10.0. To change this, open ios/Podfile in your project and add/uncomment this line at the top:

# platform :ios, '9.0'

and change it to

platform :ios, '10.0'

and run pod install again in the ios directory.

iOS build fails with 'sabpaisa_flutter/sabpaisa_flutter-Swift.h' file not found #

Add use_frameworks! in ios/Podfile and run pod install again in the ios directory.

Gradle build fails with Error: uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:sabpaisa_flutter] #

This is due to your Android minimum SDK version being less than 19. To change this, open android/app/build.gradle, find minSdkVersion in defaultConfig and set it to at least 19.

A lot of errors saying xxxx is not defined for the class 'SabPaisa' #

We export a class SabPaisa from package:sabpaisa_flutter/sabpaisa_flutter.dart. Check if your code is redeclaring the SabPaisa class.

API #

SabPaisa #

open(map<String, dynamic> options)

Open SabPaisa Checkout.

The options map has key as a required property. All other properties are optional.

on(String eventName, Function listener)

Register event listeners for payment events.

  • eventName: The name of the event.
  • listener: The function to be called. The listener should accept a single argument of the following type:

clear()

Clear all event listeners.

Error Codes

The status codes have been exposed as integers by the SabPaisa class.

The error status is available as the status field of the TransactionResponsesModel instance passed to the callback.

Error Code Description
NETWORK_ERROR There was a network error, for example loss of internet connectivity
INVALID_OPTIONS An issue with options passed in SabPaisa.open
PAYMENT_CANCELLED User cancelled the payment
TLS_ERROR Device does not support TLS v1.1 or TLS v1.2
UNKNOWN_ERROR An unknown error occurred.

Event names

The event names have also been exposed as Strings by the SabPaisa class.

Event Name Description
EVENT_PAYMENT_SUCCESS The payment was successful.
EVENT_PAYMENT_ERROR The payment was not successful.

PaymentSuccessResponse #

Field Name Type Description
data String Full payment details object

PaymentFailureResponse #

Field Name Type Description
data String Full payment details object
1
likes
0
points
33
downloads

Publisher

verified publishereywa.com

Weekly Downloads

Flutter plugin for SabPaisa SDK. To know more about SabPaisa, visit http://sabpaisa.in.

Homepage
Repository (GitLab)
View/report issues

License

unknown (license)

Dependencies

eventify, flutter, fluttertoast, package_info_plus

More

Packages that depend on sabpaisa_flutter

Packages that implement sabpaisa_flutter