Android SDK

The Foloosi Payments plugin allows you to accept credit card and debit card payments via Foloosi payment gateway.

Foloosi Android SDK Integration

Step - 1 - Add Dependency

We distribute our SDK from the Maven Central Repository. To begin with this SDK open your build.gradle file of Module:app and add the following dependency.

implementation 'com.foloosi:FoloosiSDK:1.0.8'

Step - 2 - Initialize SDK

To initialize the SDK add the below line of code with the merchant key you retrieved from foloosi merchant panel. If you don't have a merchant key create new one.

FoloosiPay.init(this, "Your Unique Merchant Key");

Step - 3 - Create Order Data Object with necessary inputs

You can create the order data or payment input with our OrderData Model class. Here you need to provide order id, title, description, currency code, order amount and customer details like name, email, mobile number.

OrderData orderData = new OrderData(); // Foloosi Order Data Model Class Instance
orderData.setOrderAmount(Double.parseDouble(amount)); // in double format ##,###.##
Random rand = new Random();
int orderId = rand.nextInt(100000);
orderData.setCustomColor("#ab34fd"); // make payment page loading color as app color.
orderData.setOrderId(String.valueOf(orderId)); // unique order id.
orderData.setOrderDescription("Mobile Phone"); // any description.
Customer customer = new Customer();
customer.setEmail("[email protected]");

Step - 4 - Implement Payment Listener

Set and Implement our payment listener to receive the payment result for the payment we going to make in Step - 5. Use the below code to obtain the payment result.

//Setting payment listener (paste this line after init() method)
public class ActDemoPay extends AppCompatActivity implements FPayListener {
public void onTransactionSuccess(String transactionId) {
// Success Callback
public void onTransactionFailure(String error) {
// Failure Callback.
public void onTransactionCancelled() {
// Transaction Cancelled by User

Step - 5 - Make Transaction with Foloosi

Use the below line of code to make the payment with the order data you created in Step - 3


Foloosi Log

You can enable / disable the SDK logs by using the below line of code. By default it will be disabled.

FoloosiLog.setLogVisible(true or false);

Progurad Rules

If you are using Proguard for your builds, modify the Proguard rule file:

-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
-keepattributes JavascriptInterface
-keepattributes *Annotation*
-dontwarn com.foloosi.**
-keep class com.foloosi.** {*;}
-optimizations !method/inlining/*

Sample Payment Reference.

Please check this link for sample payment with above steps.