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 - Configure the integration method".


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


import com.payment.paymentsdk.PaymentSdkActivity.Companion.startAlternativePaymentMethods
import com.payment.paymentsdk.PaymentSdkConfigBuilder 
import com.payment.paymentsdk.integrationmodels.* 
import com.payment.paymentsdk.sharedclasses.interfaces.CallbackPaymentInterface 


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, please follow the below instructions:


  1. Make sure your current Activity or Fragment extends CallbackPaymentInterface class.

  2. 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 Android SDK | Manage Shipping and Billing details and 2.1 Native Android SDK | Configuration Options & Parameters solution articles.

    val billingData = PaymentSdkBillingDetails( 
            "City", 
            "SA", //2 digit iso Country code 
            "[email protected]", 
            "First Last Name", 
            "phone",
            "state", 
            "address street",
            "zip" 
        ) 
    
        val shippingData = PaymentSdkShippingDetails( 
            "City", 
            "SA", //2 digit iso Country code 
            "[email protected]", 
            "First Last Name", 
            "phone",
            "state", 
            "address street",
            "zip" 
        ) 


  3. Now configure the discount, note that you can apply one or more discounts using a list of  PaymentSdkCardDiscount:

    PaymentSdkCardDiscount('discountCards','discountValue','discountTitle', 'isPercentage')
    discountCards
    List of Strings, each string must have between 4 and 10 digits, and can't be empty.
    listOf("4000000","41111111")
    discountValue
     Discount value in double
    discountTitle
    String title that will be displayed to the customer.
    isPercentage
    Boolean: true discountValue is a percentage, false is amount

    // List of card discount
    val cardDiscount = listOf(
        PaymentSdkCardDiscount(
            // list of card prefixes from 4 to 10 digits.
            listOf("40001"),
            // discount percentage or value
            10.0,
            // discount description
            "● 10% discount on VISA cards starts with 40001",
            // discount type percentage or value
            true
        ),
        PaymentSdkCardDiscount(
            // list of card prefixes from 4 to 10 digits.
            listOf("520000"),
            // discount percentage or value
            20.0,
            // discount description
            "● 20.0 SAR discount on MasterCard cards starts with 520000",
            // discount type percentage or value
            false
        )
    )



  4. Then create an object from PaymentSdkConfigBuilder and fill it out with your credentials and payment details. Of course, don't forget to set the discount via "setCardDiscount()" method using the list created in the previous step. To know more about what is the exact values that should be passed here, please check our 2.1 Native Android SDK | Configuration Options & Parameters and 2.2 Native Android SDK | The PaymentSdkConfigBuilder Object solution articles.   

    val configData = PaymentSdkConfigBuilder(profileId, serverKey, clientKey, amount ?: 0.0, currency) 
            .setCartDescription(cartDesc) 
            .setLanguageCode(locale) 
            .setBillingData(billingData) 
            .setMerchantCountryCode("SA") // ISO alpha 2 
            .setShippingData(shippingData) 
            .setCartId("123") 
            .setTransactionType(transType) 
            .setCardDiscount(cardDiscount)
            .build();


  5. Only then you will be ready to start/initiate the payment by passing your PaymentSdkConfigBuilder object along with the current CallbackPaymentInterface inherited activity/fragment instance -in which you will handle the payment response to the startCardPayment function. To know more about this please check our 2.2 Native Android SDK | The PaymentSdkConfigBuilder Object and Step 5 - Native Android SDK | Handle the payment response solution articles.

    PaymentSdkActivity.startCardPayment(this, configData, callback = this)

   

Discount title dialog, will show onle two titles, if you have set more than two then you will have to select the "See All" to display the full list:
Once you press the See All, a sheet will display showing all applied discounts configured.
     

    

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 Android SDK Integration Manual" solution article. 

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

 And to get familiar with the rest of the steps regarding the current step "Step 3 - 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.