How to use PayTabs payment gateway in iOS application?

Hi everyone, here we will discuss how to use the PayTabs payment gateway in the iOS application.

You can study their integration guide from the below-mentioned link:

Before entering into code first we want to know what a payment gateway is,

Get build your most engaging mobile experiences with best-in-class iOS application development!!!

payment gateway is an ecommerce service that practices credit card payments for the online and traditional piece and mortar stores. It completes an essential role in the ecommerce transaction process; permits the payment between merchant and client.

How to use the PayTabs payment gateway in the iOS application?

Now start with the following instruction mentioned below:

  1. Download the PayTabs iOS SDK
  2. Copy or drag-drop each of the content inside the Demo Merchants folder into your project.
  3. Build bridging header or XCode will automatically build it for you when you drag-drop content inside Demo Merchants/headerfiles.
  4. Inside the bridging header.h file paste #import“PayTabCardReaderViewController.h”.
  5. Now, In Payment ViewController build an object of PayTabCardReaderViewController similar to this.
var paytab = PayTabCardReaderViewController()
  1. Then paste this code inside your payment class
func callPaytabPaymentGateway(){

        paytab.tag_amount = "Order's total amount"

        paytab.tag_title = "Order payment title like customer's Firstname , Lastname etc"

        paytab.tag_currency = "Order amount currency"

        paytab.sdklanguage = "Your SDK language code like 'en' "

        paytab.tag_tax = "Total applicable tax";


        paytab.shipping_address = "Customer's shipping address";

        paytab.shipping_city = "Customer's shipping city";

        paytab.shiping_country = "Customer's shipping country";

        paytab.shipping_state = "Customer's shipping state"

        paytab.shipping_zip_code = "Customer's shipping zipcode"


        paytab.billing_address = "Customer's billing address"

        paytab.billing_city = "Customer's billing city"

        paytab.billing_country = "Customer's billing country"

        paytab.billing_state = "Customer's billing state"

        paytab.billing_zip_code = "Customer's billing zipcode"

        paytab.order_id = "Customer's order id that uniquely identifies order"

        paytab.phonenum = "Customer phone number"

        paytab.customer_email = "Customer's mail Id"


        paytab.tag_merchant_email = "Your merchant Id"

        paytab.timerFlag = 20100;//seconds


        paytab.secretKey = "Your merchant secret key"

        paytab.tag_original_assignee_code = "SDK"; // booking id - n

        self.present(paytab, animated: true, completion: nil)



    func checkPaymentStatus(){

        if UserDefaults.standard.value(forKey: "pt_response_code") as? String ?? "0" == "0"{

             // Payment Failed

            showAlert(message:"Payment Failed")



            // Payment Success

            self.responseCode = UserDefaults.standard.value(forKey: "pt_response_code") as! String

            self.transactionId = UserDefaults.standard.value(forKey: "pt_transaction_id") as! String

           // Update your server for the successful payment




    func showAlert(message:String){

        let errorAlert = UIAlertController(title: "", message:message, preferredStyle: .alert)

        let noBtn = UIAlertAction(title: "ok", style: .default, handler: {(_ action: UIAlertAction) -> Void in

             CheckoutShippingMethod.orderData = ""




        self.parent!.present(errorAlert, animated: true, completion: { _ in })


7. Call the function callPaytabPaymentGateway() into the exploit of your payment button.

8. Once the successful or unsuccessful transaction PayTabs stores the transaction ID and response code into your UserDefaults. To ensure the  payment status call checkPaymentStatus() function into your payment ViewController’s viewWillAppear function.

9. At last, you have successfully executed the PayTabs Payment Gateway in your iOS application.

Important Note:-

  • PayTabs SDK doesn’t support the XCode simulator.
  • You want to disable bitcode from the build settings of your project ambition.






Leave a Reply

Your email address will not be published. Required fields are marked *