Skip to main content

Older integration (<2.1.0)

IMPORTANT

This is the documentation for versions prior to 2.1.0. It is recommended to upgrade to the latest version to take advantage of improvements and new features. For the documentation of the latest version, please refer to the section Recommended integration.

This guide provides detailed technical information on integrating the SDK into an Android application. Be sure to follow the steps and considerations below for a successful integration.

Step 1: Download the SDK

  1. Download the SDK file here.

  2. Once on the link, click the download button to get the SDK file in compressed format.

  3. Unzip the downloaded file to a location of your choice on your development machine.

Step 2: Integrating the SDK into your project

First, you need to add the SDK to your Android application project. To do this, create a folder called "libs" inside the corresponding directory and copy the library (AAR) into that folder.

Step 3: Modify the build.gradle of the "APP".

We go to build.gradle of the app and put the following lines of code.

plugins {
id 'kotlin-kapt'
id 'kotlin-android-extensions'
id 'dagger.hilt.android.plugin'
}
dependencies {
implementation files('../libs/izipay-sdk-1.2.2.aar')
implementation files('../libs/TMXAuthentication-RL-6.3-77.aar')
implementation files('../libs/TMXBehavioralBiometrics-RL-6.3-77.aar')
implementation files('../libs/TMXDeviceSecurityHealth-RL-6.3-77.aar')
implementation files('../libs/TMXProfilingConnections-RL-6.3-77.aar')
implementation files('../libs/TMXProfiling-RL-6.3-77.aar')

implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

implementation "com.google.dagger:hilt-android:2.44"
kapt "com.google.dagger:hilt-compiler:2.44"

implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation "com.squareup.retrofit2:converter-scalars:2.9.0"

implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"

implementation 'com.github.bumptech.glide:glide:4.14.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'

implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
implementation "com.github.skydoves:balloon:1.5.2"
implementation "com.github.skydoves:powerspinner:1.2.4"

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

Step 4: Modify the build.gradle of the "Project".

If you already configured Dagger Hilt in your project, you can skip this step. Otherwise we go to the Project's build.gradle and put the following lines of code:

plugins {
id 'com.google.dagger.hilt.android' version '2.44' apply false
}

then click on the Sync Now button at the top right of the Android Studio.

(*) The highlighted button in the image is the Sync Now button.

Step 5: Add @HiltAndroidApp file

If you have already added the @HiltAndroidApp annotation in your application, there is no need to repeat it. If it has not been added yet, in your App file you should add in the header the following line of code @HiltAndroidApp (If you don't have the file: App you should create one).

@HiltAndroidApp
class NombreDeTuArchivo: Application{
}
Tip

FileName is the name of your file and can look like this: SDKExampleApp

Send a CONFIGREQUEST object with these corresponding parameters

CONFIGREQUEST = {
data class ConfigRequest(
var environment: String?,
var action: String?,
var publicKey: String?,
var transactionId: String?,
var merchantCode: String?,
var facilitatorCode: String?,
var order: OrderPaymentIzipay?,
var token: TokenPaymentIzipay?,
var billing: BillingPaymentIzipay?,
var shipping: ShippingPaymentIzipay?,
var appearance: AppearencePaymentIzipay?,
var urlIPN: String?,
): Serializable

data class OrderPaymentIzipay(
var orderNumber: String?,
var currency: String?,
var amount: String?,
var payMethod: String?,
var channel: String?,
var processType: String?,
var merchantBuyerId: String?,
var dateTimeTransaction: String?
): Serializable

data class BillingPaymentIzipay(
var firstName: String?,
var lastName: String?,
var email: String?,
var phoneNumber: String?,
var street: String?,
var city: String?,
var state: String?,
var country: String?,
var postalCode: String?,
var documentType: String?,
var document: String?
): Serializable

data class ShippingPaymentIzipay(
var firstName: String?,
var lastName: String?,
var email: String?,
var phoneNumber: String?,
var street: String?,
var city: String?,
var state: String?,
var country: String?,
var postalCode: String?,
var documentType: String?,
var document: String?
): Serializable

data class AppearencePaymentIzipay(
var language: String? = "",
var formControls: AppearenceControlsPaymentIzipay?,
var visualSettings: AppearenceVisualSettingsPaymentIzipay?,
var theme: String? = "",
var customTheme: CustomThemePaymentIzipay?,
var logo: String? = "",
): Serializable

data class AppearenceVisualSettingsPaymentIzipay(
showMessageResult: Boolean? = false
)


data class AppearenceControlsPaymentIzipay(
var isAmountLabelVisible: Boolean? = false,
var isLangControlVisible: Boolean? = false,
): Serializable

data class CustomThemePaymentIzipay(
var payButtonBackgroundColor: String? = "",
var textInputBorderColor: String? = "",
var textInputPlaceholderTextColor: String? = ""
): Serializable

data class TokenPaymentIzipay(
var cardToken : String? = "",
): Serializable

}

You can send the request in the following way:

val intent = Intent(activity, ContainerActivity::class.java)
intent.putExtra(ContainerActivity.REQUEST, request) // request is an instance of CONFIGREQUEST
responseLauncher.launch(intent)
Important

Currently the SDK has two display modes: FullScreen Mode and Embedded Mode. Below you will see how both modes respond and also the steps to follow to implement the Embbedded mode.

5.1 FullScreen Screen Mode

To receive and implement, in fullscreen mode, the response of the "RESPONSE" object, the following lines of code must be added in the source code of the application. It is important to note that the response is a string in JSON format. To perform a correct reading of the response data, it is recommended to review the JSON examples provided in the use-cases chapter. These examples will serve as a reference to understand the structure of the data and to facilitate their manipulation in the implementation of the code

private val responseLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()){ result ->
val dataSignature = result.data?.getStringExtra(ContainerActivity.RESPONSESIGNTURE).orEmpty()
val dataPayLoad:PaymentResponse = Gson().fromJson(result.data?.getStringExtra(ContainerActivity.RESPONSEPAYLOAD).orEmpty(), object: TypeToken<PaymentResponse>(){}.type)

if(result.resultCode == AppCompatActivity.RESULT_OK){
val response = "$timeStamp :: $dataPayLoad->$dataSignature"
binding.etResponse.setText(response)
}else{
val response = "$timeStamp :: $dataPayLoad->$dataSignature"
binding.etResponse.setText(response)
}
}

5.2 Embedded Mode

Follow the steps below for the implementation of the Embedded mode:

  1. To employ the embedded mode, you start by adding the PayCallback class to the fragment that functions as the SDK container. Then, a libraryManager variable of type PayManager is created.
@AndroidEntryPoint
class HomeFragment : Fragment(), PayCallback {
private lateinit var libraryManager: PayManager
  1. Next, an instance of the PayManager class is created and assigned to the libraryManager variable. Then, the setCallback method is applied to the current context, since this context will be received by our PaymentsFragment (which is part of the SDK).
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {

binding = FragmentHomeBinding.inflate(inflater, container, false)

libraryManager = PayManager()
libraryManager.setCallback(this)
}
  1. Inside the intentActivity() method of your fragment that serves as the SDK container, create a Bundle object in which you include the request of type ConfigRequest. Then, invoke the PaymentsFragment as follows:
private fun intentActivity() {

val bundle = Bundle().apply {
putSerializable("data", request) //donde request es una instancia de ConfigRequest que ya esta llena de valores para el pago
}

val transaction = parentFragmentManager.beginTransaction()
var fragment = PaymentsObject.paymentsObject() as PaymentsFragment
fragment.arguments = bundle
fragment.payManager = libraryManager
transaction
.addToBackStack("HomeFragment")
.add(R.id.navContainer, fragment)
.commit()
}
  1. Implement the PayCallback interface in the fragment that acts as the SDK container, and overwrite the onDataFromPayments method as follows:
override fun onDataFromPayments(success: Boolean, pdata: PaymentResponse?, psignature:String?) {
if(success){
val response = "Success: True \n\nTra.ID: $timeStamp \n\nData: $pdata \n\nSignature: $psignature"
binding.etResponse.setText(response)
}else{
val response = "Success: False \n\nTra.ID: $timeStamp \n\nData: $pdata \n\nSignature: $psignature"
binding.etResponse.setText(response)
}

if (parentFragmentManager.backStackEntryCount > 0)
parentFragmentManager.popBackStack()
}

Note that the pdata, pdataSignature, and pdataPayload values are equivalent to those returned in fullscreen mode and are used in the same way.

Step 6: Integration with sensory branding libraries

Copy the sensory branding libraries into the libs folder (together with the Izipay SDK).

Insert the following lines in the gradle file located at application level, as shown below:

dependencies {
implementation files('../libs/izipay-sdk-1.2.2.aar')

implementation files('../libs/sonic-sdk-release-1.4.0.aar')

implementation files('../libs/visa-sensory-branding-2.1.aar')

//Other dependencies

}
Important

Integration with sensory branding libraries is a mandatory step required by brands.