Please, do not share your card details with anyone. Note that FIB never ask you for such information.

Android Payments SDK

FIB payment SDK was created to allow you to integrate FIB as a convenient payment method within your application

Developer Guide — FIB SDK for Android

FIB payment SDK was created to allow you to integrate FIB as a convenient payment method within your application:

  1. Initiate a transaction and let users pay through FIB apps (personal, business, corporate);
  2. Get payment status;
  3. Cancel payments.

Mobile — SDK Status Diagram

This section will show the probable flow of using the Mobiles-SDK for creating transaction, retrieving transaction state and canceling a transaction.

1. Initiate Transaction

2. Retrieving Payment State from Mobile-SDK

3. Canceling Payment from Mobile-SDK

Get Started with FIB SDK for Android

To use this SDK on Android, the following must be addressed.

1. API level21+ .
2. Have a developer account, and provide the SDK with your account credentials such asClientID ,ClientSecret ,GrantType andFIBBackend .

Download-Addressing API

Gradle

Add this dependency in your app’sbuild.gradle file:

Code Example

Copy Copied
dependencies {
    implementation 'iq.fib.payments:fib_payment_sdk:1.0.0'
}

SDK Initialization

Step 1: Get Your Account Credentials.

After you took required steps to get a developer account in FIB, you’ll be provided with your accounts credentials (ClientId ,ClientSecret ,GrantType ,FIBBackend ).

Step 2: Provide Your Credentials to the SDK.

In the root of your android project locatelocal.properties (create one if it doesn’t exist) file and add your credentials to it.

Code Example

Copy Copied
FIBBackend = XXXX
GrantType = XXXX
ClientId = XXXX
ClientSecret = XXXX

Step 3: Provide Your Environment to the SDK.

In your app’sbuild.gradle file addit.manifestPlaceholders["env_type"] = ".stage" to yourdefaultConfig block. block.

Code Example

Copy Copied
android {
    compileSdk 30
    defaultConfig {
        // replace ".stage" with "" for production environment
        // .stage: means that all transactions are fake and the operations will happen in a development environment 
        // "": means that the transactions are real and the operations will happen in a production environment
      it.manifestPlaceholders["env_type"] = ".stage"
    }
}

SDK Usage

The SDK could be used in two ways:

  1. By reusing provided UI components
  2. By using custom UI and reusing the underlying logic

Using Provided UI

You can use FIBButton View to do your payment operations.
AddFIBButton to your layout class:

Code Example

Copy Copied
<com.lawrencespring.payment.widget.FIBButton
        android:id="@+id/buttonBuy"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>

Reference the button in your activity/fragment code:

Code Example

Copy Copied
import com.lawrencespring.payment.widget.FIBButton

val payButton = findViewById<FIBButton>(R.id.buttonBuy)

Payment operation with FIBButton

Code Example

Copy Copied
payButton.setOnClickListener {
    // starting payment with FIBButton
    payButton.startPayment(
        listOf(
            "https://personal.stage.first-iraqi-bank.co/?link=https://personal.stage.first-iraqi-bank.co/onlinePayment/?identifier%3DSIBAFZSPVZB2&apn=com.firstiraqibank.personal.stage&ibi=se.core.Lawrencespring.development",
            "https://business.stage.first-iraqi-bank.co/?link=https://business.stage.first-iraqi-bank.co/onlinePayment/?identifier%3DSIBAFZSPVZB2&apn=com.firstiraqibank.business.stage&ibi=se.core.Lawrencespring.business.development",
            "https://corporate.stage.first-iraqi-bank.co/?link=https://corporate.stage.first-iraqi-bank.co/onlinePayment/?identifier%3DSIBAFZSPVZB2&apn=com.firstiraqibank.corporate.stage&ibi=se.core.Lawrencespring.corporate.development"
        )
    )
}
                  
// retrieving payment status
lifecycleScope.launch {
    val state: PaymentStatus? = payButton.checkPaymentState(paymentID)
}
  
// canceling payment 
lifecycleScope.launch {
    payButton.cancelPayment(paymentID)
}

Using Provided Logic with Custom UI Components

Payment operation with PayWithFIB

Code Example

Copy Copied
import com.lawrencespring.payment.adapter.exposer.payWithFIB.PayWithFIB
import com.lawrencespring.payment.framework.exposer.payWithFIB.PaymentListener
import com.lawrencespring.payment.framework.exposer.payWithFIB.model.FIBApp
import com.lawrencespring.payment.framework.exposer.payWithFIB.PaymentStatus
val payWithFIB = PayWithFIB()
// moreThanOneApp is triggered only when multiple FIB apps are installed on the end device
// once the app is selected it could be started by using appStarter(FIBApp)
payWithFIB.addPaymentListener(object : PaymentListener {
    // availableApps: are the list of fib apps available on the end device
    // appStarted: is a callback function that's called with the app that needs to be open     
    override fun moreThanOneApp(availableApps: List<FIBApp>, appStarter: (FIBApp) -> Unit) {
        // creating a dialog that will show the available apps
        val dialog = AlertDialog.Builder(context)
        val arrayAdapter =
            ArrayAdapter<String>(context, android.R.layout.select_dialog_item)
        availableApps.forEach { arrayAdapter.add(it.name.lowercase()) }
        dialog.setAdapter(arrayAdapter) { _, which ->
            // passing the selected app to the callback          
            appStarter(availableApps[which])
        }
        dialog.create().show()
    }
})
// starting payment with PayWithFIB
payWithFIB.startPayment(
    listOf(
        "https://personal.stage.first-iraqi-bank.co/?link=https://personal.stage.first-iraqi-bank.co/onlinePayment/?identifier%3DSIBAFZSPVZB2&apn=com.firstiraqibank.personal.stage&ibi=se.core.Lawrencespring.development",
        "https://business.stage.first-iraqi-bank.co/?link=https://business.stage.first-iraqi-bank.co/onlinePayment/?identifier%3DSIBAFZSPVZB2&apn=com.firstiraqibank.business.stage&ibi=se.core.Lawrencespring.business.development",
        "https://corporate.stage.first-iraqi-bank.co/?link=https://corporate.stage.first-iraqi-bank.co/onlinePayment/?identifier%3DSIBAFZSPVZB2&apn=com.firstiraqibank.corporate.stage&ibi=se.core.Lawrencespring.corporate.development"
    )
)
// retrieving payment status
lifecycleScope.launch {
    val state: PaymentStatus? = payWithFIB.getPaymentState(paymentID)
}
// canceling payment 
lifecycleScope.launch {
    payWithFIB.cancelPayment(paymentID)
}

The library will check if any version of FIB app is installed on the mobile device of the user and will try to proceed with the transaction. If more than one app are installed the user is asked to choose one of them. If no FIB is installed the user will be redirected to the Google Play Store.

License

Copyright 2021 First Iraqi Bank, Inc.

Licensed under the Apache License, Version 2.0 (the “License”); You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 .

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Redirection

This SDK also includes an option to redirect the user from the FIB applications to your application, you can provide the applicationsredirect URI and everything will be handled for you.

It is optional to have this feature, so if you provide yoursredirect URI , the redirection happens otherwise the FIB applications behave as they normally would.

First Iraqi Bank - FIB
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.