Foloosi
Search…
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.
1
implementation 'com.foloosi:FoloosiSDK:1.0.8'
Copied!

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.
1
FoloosiPay.init(this, "Your Unique Merchant Key");
Copied!

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.
1
OrderData orderData = new OrderData(); // Foloosi Order Data Model Class Instance
2
orderData.setOrderAmount(Double.parseDouble(amount)); // in double format ##,###.##
3
Random rand = new Random();
4
int orderId = rand.nextInt(100000);
5
orderData.setCustomColor("#ab34fd"); // make payment page loading color as app color.
6
orderData.setOrderId(String.valueOf(orderId)); // unique order id.
7
orderData.setOrderDescription("Mobile Phone"); // any description.
8
orderData.setCurrencyCode(currencyCode);
9
Customer customer = new Customer();
10
customer.setName("name");
11
customer.setEmail("[email protected]");
12
customer.setMobile("1234567890");
13
orderData.setCustomer(customer);
Copied!

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.
1
//Setting payment listener (paste this line after init() method)
2
FoloosiPay.setPaymentListener(this);
3
4
//Implementing
5
public class ActDemoPay extends AppCompatActivity implements FPayListener {
6
7
@Override
8
public void onTransactionSuccess(String transactionId) {
9
// Success Callback
10
}
11
12
@Override
13
public void onTransactionFailure(String error) {
14
// Failure Callback.
15
}
16
17
@Override
18
public void onTransactionCancelled() {
19
// Transaction Cancelled by User
20
}
21
22
}
Copied!

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
1
FoloosiPay.makePayment(orderData);
Copied!

Foloosi Log

You can enable / disable the SDK logs by using the below line of code. By default it will be disabled.
1
FoloosiLog.setLogVisible(true or false);
Copied!

Progurad Rules

If you are using Proguard for your builds, modify the Proguard rule file:
1
-keepclassmembers class * {
2
@android.webkit.JavascriptInterface <methods>;
3
}
4
5
-keepattributes JavascriptInterface
6
-keepattributes *Annotation*
7
8
-dontwarn com.foloosi.**
9
-keep class com.foloosi.** {*;}
10
11
-optimizations !method/inlining/*
Copied!

Sample Payment Reference.

Please check this link for sample payment with above steps.
Last modified 9mo ago