Requirements
- You must be a client of ePay.
- You must obtain integration data:
TerminalID | Merchant payment terminal ID |
ClientID | Merchant ID |
ClientSecret | Merchant Secret Key |
Test data
ClientID | test |
ClientSecret | yF587AV9Ms94qN2QShFzVR3vFnWkhjbAK3sG |
TerminalID | 67e34d63-102f-4bd1-898e-370781d0074d |
Setup
1. Import SDK
Adding SDK aar to the project
- Download the halykepay.aar library from the link Android framework
- Move the file to the libs folder
- Import the .aar file into your project as a Jar/Aar Dependency
- Go to the File > Project Structure > Dependencies section.
- In the Declared Dependencies tab, click on "+" and select Module Dependency.
Adding Dependencies
The SDK uses the following dependencies. Add these dependencies to your project for the EpaySDK to work correctly:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50" implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.core:core-ktx:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0' implementation 'com.google.android.material:material:1.1.0' implementation 'com.google.code.gson:gson:2.8.6' def nav_version = "2.3.0-alpha01" implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" implementation "androidx.navigation:navigation-ui-ktx:$nav_version" def okhttp_version = "3.9.1" implementation "com.squareup.okhttp3:okhttp:$okhttp_version" implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version" implementation 'io.github.ihermandev:format-watcher:1.0.1' implementation 'com.github.bumptech.glide:glide:4.15.1' annotationProcessor 'com.github.bumptech.glide:compiler:4.15.1' implementation "com.google.android.gms:play-services-wallet:19.2.0-beta01" implementation "com.google.android.gms:play-services-pay:16.1.0" implementation 'io.card:android-sdk:5.5.1'
2. Authorization Setup
Create an instance of the authorization configuration. You can store the instance in constants or create it during the direct initialization of the Payment Page or Transfer Page
import com.ss.halykepay.data.model.AuthConfig
val config = AuthConfig(
merchantID = <Merchant payment TerminalID>,
merchantName = <Shop Name>,
clientID = <Merchant ClientID>,
clientSecret = <Merchant ClientSecret>
)
Initialize the EpaySDK instance to further launch the payment page or translation page.
import com.ss.halykepay.data.BuildType import com.ss.halykepay.HalykEpaySDK val halykEpaySdk = HalykEpaySDK.instance(<activity instance>, config, BuildType.PROD)
To work in the testing environment, install BuildType.DEBUG
3. Response Processing
To obtain and process the operation result, it is necessary to process the data received from the payment activity.
Data Model PaymentResult:
data class PaymentResult( val isSuccessful: Boolean, val paymentReference: String? = null, val errorCode: Int? = null, val errorMessage: String? = null )
Example:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == EPAY_SDK_REQUEST_CODE) {
val result = halykEpaySdk.getPaymentResult(requestCode, resultCode, data)
if (result.isSuccessful) {
resultTextView.text = result.paymentReference ?: "no payment reference"
} else {
resultTextView.text = result.errorMessage ?: "unknown error"
}
}
}
4. Setting up for payment or transfer
Next, when conducting the actual transaction, you will need to prepare the payment model and initiate the desired type of operation. For more details, visit the Payment Pages and Transfer Pages.