Please, do not share your card details with anyone. Note that FIB never ask you for such information.
FIB payment SDK was created to allow you to integrate FIB as a convenient payment method within your application:
This section will show the probable flow of using the Mobiles-SDK for creating transaction, retrieving transaction state and canceling a transaction.
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 .
21+
ClientID
ClientSecret
GrantType
FIBBackend
Add this dependency in your app’sbuild.gradle file:
build.gradle
Code Example
dependencies { implementation 'iq.fib.payments:fib_payment_sdk:1.0.0' }
After you took required steps to get a developer account in FIB, you’ll be provided with your accounts credentials (ClientId ,ClientSecret ,GrantType ,FIBBackend ).
ClientId
In the root of your android project locatelocal.properties (create one if it doesn’t exist) file and add your credentials to it.
local.properties
FIBBackend = XXXX GrantType = XXXX ClientId = XXXX ClientSecret = XXXX
In your app’sbuild.gradle file addit.manifestPlaceholders["env_type"] = ".stage" to yourdefaultConfig block. block.
it.manifestPlaceholders["env_type"] = ".stage"
defaultConfig
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" } }
The SDK could be used in two ways:
You can use FIBButton View to do your payment operations. AddFIBButton to your layout class:
FIBButton
<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:
import com.lawrencespring.payment.widget.FIBButton val payButton = findViewById<FIBButton>(R.id.buttonBuy)
Payment operation with FIBButton
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) }
Payment operation with PayWithFIB
PayWithFIB
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.
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.
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.
redirect URI
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.
Thank you! We will get back to you shortly.
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.
Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.