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

iOS Payments SDK

FIB payment SDK is a payment library using First Iraqi Bank applications written in Swift, using this in your IOS application enables your users to purchase items using First Iraqi Bank applications

Developer Guide — FIB SDK for iOS

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 Initiating a transaction, retrieving transaction status and canceling a transaction.

1. Initiate Transaction

2. Retrieving Payment State from Mobile-SDK

3. Canceling Payment from Mobile-SDK

Features

Following are features of the iOS Payments SDK:

  1. Make payment transaction using FIB App.
  2. Check the status of the payments which you make.
  3. Provising a UI that you can use for handling the transactions.
  4. Provising your custome UI but the logic that we provide in this SDK.
  5. Supports 3 FIB apps (Personal & Business & Corporate).

Get started with FIB SDK for iOS

FIB Payment SDK is a payment library using First Iraqi Bank App written in Swift.

Requirements

  1. iOS 12.1+
  2. Xcode 11+
  3. Swift 5.0+

Installation

CocoaPods

It is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrateFIBPaymentSDK into your Xcode project using CocoaPods, specify it in your Podfile

Code Example

Copy Copied
pod 'FIBPaymentSDK', '~> 1.1.1'

Swift Package Manager

If you want to integrate the SDK using Swift Package Manager you just need to go toFile -> Swift Packages -> Add Package Dependency... then in the search writehttps://github.com/First-Iraqi-Bank/fib-ios-sdk.git , the url for this github repository, then choose the version or the branch of interest.

SDK Usage

The first thing you will need to do if you want to use this SDK is having a property list file in your app with exactly this name:FIBConfiguration.plist This file contains the required data for the SDK to be able to work. Replace the content of the SDK with:

Code Example

Copy Copied
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>accountId</key>
    <string>you will be given this ID</string>
    <key>clientSecret</key>
    <string>you will be given this secret</string>
    <key>clientId</key>
    <string>you will be given this ID</string>
    <key>grantType</key>
    <string>client_credentials</string>
    <key>baseURLs</key>
    <dict>
        <key>fibPayGate</key>
        <string>this URL with change based on your need</string>
    </dict>
</dict>
</plist>

Overview:FIBConfiguration.plist

1.accountId : this isaccountId of the FIB business account which receives the payments.

2. clientSecret: an secret that you will be given to authenticate you.

3.clientId : an Id that you will be given to identify you as a client.

4.grantType : This is used for authentication as well.

5.baseURLs : thebaseURLs that we use for making the API requests for creating the payment, currently it only has one property which isfibPayGate .

The FIB PayGate Can Be Either:

1.Develop : which can be used for testing purposes.

Code Example

Copy Copied
 https://fib.stage.fib.iq

2.production : which you will use when you release your app.

Code Example

Copy Copied
 https://fib.prod.fib.iq


To use theFIBPaymentSDK you need to import:

Code Example

Copy Copied
import FIBPaymentSDK


Then you will need to create an instance ofPayWithFIBView :

Code Example

Copy Copied
let fibView = PayWithFIBView()


PayWithFIBView has three methods:

1.Configure : which you can call to make the view intractable.

Code Example

Copy Copied
configure(fibApplicationURLs: [FIBApplicationURLType], delegate: FIBPaymentManagerDelegate?)

Configure has two parameters:

a.fibApplicationURLs : this is an Array of TypeFIBApplicationURLType ,so we expect all the links of the FIB apps to be sent to this method;

b.delegate : it is an instance of typeFIBPaymentManagerDelegate? which you need conform in order to be notified about some additional information on the transaction.

FIBPaymentManagerDelegate has two methods which you can implement:

I.paymentCanceled : this one is called when you cancel a specific payment.

Code Example

Copy Copied
func paymentCanceled(paymentID: String):

II.didReceive : This one will be called every time you want to start a FIB payment or check the status of a specific payment but an error occurs in the APIRequest for handling these cases you will need to implement this to deal with anyerror that might happen.

Code Example

Copy Copied
func didReceive(error: APIError):

The error is of typeAPIError which is anenum So that you can check what exactly is the error and update you UI accordingly. Doing so you enable thefibView to make all the required functionalities and present and alert to indicate to the user that he/she can open the available FIB applications.


2.checkPaymentStatus : It is another method ofPayWithFIBView will be used to check the status of a specific payment.

Code Example

Copy Copied
public func checkPaymentStatus(paymentID: String, completion: @escaping (PaymentStatusType?) -> Void)

checkPaymentStatus has two parameters:

a.paymentID : an ID which is used to indicate which transaction you need to check;

b.completion : which gives you feedback about the status.


3.cancelPayment : It is another method ofPayWithFIBView will be used to cancel a specific payment.

Code Example

Copy Copied
func cancelPayment(paymentID: String)

Note: Please note that Cancel Payment feature should not be used for refunding an item, this feature should be used only to cancel a pending and currently active payment.

PayWithFIBView has an instance of UI Button which you can customize for example like that:

Code Example

Copy Copied
fibView.button.setTitle( "any custom title", for: .normal)

Using Your Own UI:

You can assign the logic for handling payment with FIB your self, If you want to use the SDK but you want to use your won UI, we got your back.
We have created a class which you can use to handle all the logic but provide your own UI:

Code Example

Copy Copied
let fibPaymentManager: FIBPaymentManagerType
                                        init(fibPaymentManager: FIBPaymentManagerType = FIBPaymentManager()) {
                                        self.fibPaymentManager = fibPaymentManager
                                        fibPaymentManager.delegate = self
                                        }

As you seeFIBPaymentManagerType is a protocol andFIBPaymentManager is the class that conforms to it, we have provided this protocol in order to make your life easier in terms of testability.


1.openFIB : This is responsible for opening the fib apps based on you input:

Code Example

Copy Copied
func openFIB(_ applicationType: FIBApplicationURLType)

It has one parameter which isapplicationType : you can pass.personalURL("personal app link") or.businessURL("business app link") or.corporateURL("corporate app link") , based on user’s input to you.


2.checkPaymentStatus : This one is used to check the status of a specific payment.

Code Example

Copy Copied
func checkPaymentStatus(paymentID: String, completion: @escaping ((PaymentStatusType?) -> Void))

It has two parameters:

a.paymentID : an ID which is used to indicate which transaction you need to check;
b.completion : which gives you feedback about the status.


3.cancelPayment : you call this one when you want to cancel a specific payment.

Code Example

Copy Copied
func cancelPayment(paymentID: String)

As you can see in the body of theinitializer ,fibPaymentManager has a property calleddelegate and it is of typeFIBPaymentManagerDelegate? Which you need to conform to and implement its methods.

License

FIB-Payment-SDK is released under the MIT license. See License for details.

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.