إقرأ مجلة البنك العراقي الأول باللغات الكردية، العربية و الانجليزية لشهر تموز ٢٠٢٤ !

back to developers

IOS Payments SDK

FIBPaymentSDK 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 state and canceling a transaction.

  1. Initiate Transaction

    initiate transaction diagram
  2. Retrieving Payment State from Mobile-SDK

    Retrieving Payment State from Mobile-SDK diagram
  3. Canceling Payment from Mobile-SDK

    Canceling Payment from Mobile-SDK diagram

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 the 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

pod 'FIBPaymentSDK', '~> 1.1.1'

Swift Package Manager

if you want to integrate the SDK using SwiftPackageManager 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:

FIBConfiguration.plist

<?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>

FIBConfiguration.plistOverview:

  1. accountId: this isaccountIdof 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 is fibPayGate.

The fibPayGate can be either:

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

    Code Example

    https://fib.stage.fib.iq
  2. production: which you will use when you release your app.

    Code Example

    https://fib.prod.fib.iq

To use the FIBPaymentSDK you need to import:

Code Example

import FIBPaymentSDK

Then you will need to create an instance of PayWithFIBView:

Code Example

let fibView = PayWithFIBView()

PayWithFIBView has three methods:

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

    Code Example

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

    Configure has two parameters.

    • fibApplicationURLs: this is an Array of TypeFIBApplicationURLType, so we expect all the links of the FIB apps to be sent to this method.
    • delegate:it is an instance of typeFIBPaymentManagerDelegate?which you need conform in order to be notified about some extra information on the transaction.
    FIBPaymentManagerDelegatehas two methods which you can implement:
    • paymentCanceled:this one is called when you cancel a specific payment.

      Code Example

      func paymentCanceled(paymentID: String):
    • 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 occur.

      Code Example

      func didReceive(error: APIError):
      The error is of typeAPIError which is anenum so that you can check what is exactly 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

    public func checkPaymentStatus(paymentID: String, completion: @escaping (PaymentStatusType?) -> Void)
    checkPaymentStatus has two parameters:
    • paymentID: an ID which is used to indicate which transaction you need to check.
    • completion: which gives you feedback about the status.
  3. cancelPayment: It is another method of PayWithFIBView will be used to cancel a specific payment.

    Code Example

    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 UIButton which you can customize for example like that:

    Code Example

    fibView.button.setTitle( "any custom title", for: .normal)
    Using Your Own UI: you can assign the logic for handling payment with FIB your self, Incase 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

    let fibPaymentManager: FIBPaymentManagerType
                                            init(fibPaymentManager: FIBPaymentManagerType = FIBPaymentManager()) {
                                            self.fibPaymentManager = fibPaymentManager
                                            fibPaymentManager.delegate = self
                                            }
    As you seeFIBPaymentManagerType is a protocol and FIBPaymentManageris the class that conforms to it, we have provided this protocol in order to make your life easier in terms of testability.

    It has three methods which you will need to use:

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

      Code Example

      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

      func checkPaymentStatus(paymentID: String, completion: @escaping ((PaymentStatusType?) -> Void))
      It has two Parameters:
      • paymentID: an ID which is used to indicate which transaction you need to check.
      • completion:which gives you feedback about the status.

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

      Code Example

      func cancelPayment(paymentID: String)
      As you can see in the body of theinitializer,fibPaymentManagerhas 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 applications redirect URI and everything will be handled for you.


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

اتصل بنا

مركز الاتصال: متوفر من ٨:٠٠ ص إلى ١١:٥٩ م

مركز الاتصال: متوفر من ٨:٠٠ ص إلى ١١:٥٩ م

٦٩٧٧ ٢٢٠ ٠٦٦
دردش معنا على واتساب!

دردش معنا على واتساب!

٦٩٩٩ ٦٦٦ ٠٦٦
اتصل بنا عبر البريد الإلكتروني

اتصل بنا عبر البريد الإلكتروني

customer-service@fib.iq