PayTabs SDK makes the integration with the PayTabs payment gateway very easy by providing a ready-made payment screen that handles the card entry and, billing & shipping information and completes the missing details.


This article is dedicated to walking you through how to initiate the payment/request payload using the configuration options and parameters that have already been clarified in the previous step, " Step 2 - Native IOS SDK | Configure the integration method".


After making sure of the "Prerequisites" for this SDK, you will need to import the PaymentSDK in your code first to start, as shown below:

import PaymentSDK

Implementing this option will enable you to apply a discount for a specific bank card/s via giving card prefixes from 4 to 10 digits. To be able to do this. To be able to do this, please follow the below instructions: 


  1. Configure the billing & shipping information for this payment, noting that the shipping information is optional. To know more about this, please check our  3.1 Native IOS SDK | Manage Shipping and Billing details and 2.1.1 Native IOS SDK | Configuration Options & Parameters solution articles.
         
    let billingDetails = PaymentSDKBillingDetails(
                name: "First Last",
                email: "[email protected]",
                phone: "+2011111111",
                addressLine: "address",
                city: "City",
                state: "State",
                countryCode: "SA",  2 digit ISO Country code
                 zip: "12345")
                                                       
    let shippingDetails = PaymentSDKShippingDetails(
    name: "First Last",
                email: "[email protected]",
                phone: "+2011111111",
                addressLine: "address",
                city: "City",
                state: "State",
                countryCode: "SA",  2 digit ISO Country code
                 zip: "12345")

       

  2. Now configure the discount, note that you can apply one or more discounts using an array of  PaymentSdkCardDiscount:
       
    PaymentSdkCardDiscount: 
    'discountCards','discountValue','discountTitle', 'isPercentage'
    JavaScript
    discountCards
    Array of Strings, each string must have between 4 and 10 digits, and can't be empty.
    ["4000000","41111111"]
    JavaScript
    discountValue
     Discount value in double
    discountTitle
    String title that will be displayed to the customer.
    isPercentage
    Boolean: true discountValue is a percentage, false is an amount
    let cardDiscounts: [PaymentSDKCardDiscount] = [
                PaymentSDKCardDiscount(discountCards: ["4001"], dicsountValue: 90.0, discountTitle: "● 90% discount - 40001, 90% discount - 40001, 90% discount - 40001", isPercentage: true),
                PaymentSDKCardDiscount(discountCards: ["4000", "4111", "400012"], dicsountValue: 1.0, discountTitle: "● 1% discount - 4000,4111,400012", isPercentage: true),
                PaymentSDKCardDiscount(discountCards: ["5498", "5200"], dicsountValue: 2.0, discountTitle: "● 2% discount - 5498,5299 (977)", isPercentage: true),
                PaymentSDKCardDiscount(discountCards: ["4012"], dicsountValue: 5.0, discountTitle: "● 5 discount - 4012 (530)", isPercentage: false)
            ]


  3. Then create an object from PaymentSDKConfiguration and fill it out with your credentials and payment details.  Of course, don't forget to set the discount via "cardDiscounts" method using the array created in the previous step.  To know more about what is the exact values that should be passed here, please check our 2.1.1 Native IOS SDK | Configuration Options & Parameters solution article.
    let configuration = PaymentSDKConfiguration(
                               profileID: profileID,
                               serverKey: serverKey,
                               clientKey: clientKey,
                               currency: "AED",
                               amount: 5.0,
                               merchantCountryCode: "AE")
                .cartDescription("Flowers")
                .cartID("1234")
                .screenTitle("Pay with Card")
                .billingDetails(billingDetails)
                .cardDiscounts(cardDiscounts)


  4. Only then you will be ready to start/initiate the payment by passing your PaymentSDKConfiguration object along with the PaymentManagerDelegate object -in which you will handle the payment response- to the startAlternativePaymentMethod function. To know more about this please check our 2.2 Native IOS SDK | The PaymentSDKConfiguration Object, 2.1.2 Native IOS SDK | Delegates, and Step 5 - Native IOS SDK | Handle the payment response solution articles
    PaymentManager.startCardPayment(on: self, 
                                 configuration: configuration,
                                 delegate: self)


If the customer uses a bank card that does not match any of the discount filters, the discount will not applied and the customer will pay the full amount. 







⌂ To get familiar with the whole process and the other steps, kindly navigate to our "The Native IOS SDK Integration Manual" solution article. 

 And to navigate to the previous step in the integration process "Step 2 - Configure the integration method" kindly click here.

 And to get familiar with the rest of the steps regarding the current step " Step 3 - Native IOS SDK | Initiating the payment" click here.
Or you can navigate to the next step in the integration process "Step 4 - Accepting the payment" kindly click here.