This SDK allows you to implement BankPay payments in your Android app and is written for the Kotlin programming language. Included you will find a Fragment layout with a Class file for processing intents via a WebView.
Installing the SDK
SDK Files
Requirements
- Android Studio
- Minimum Android SDK 19 (min tested version SDK 25)
- Target SDK Version 29
Set up
In Android Studio go to File > New > New Module
and choose Import .JAR/.AAR Package
.
Next, download the BankPay SDK .arr and import it into your project.
And finally, Implement the BankPay SDK’s transitive dependencies in your app level build.gradle file.
dependencies: {
...
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.10.1'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.1'
implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-kotlin', version: '2.9.8'
implementation 'io.reactivex.rxjava3:rxjava:3.0.0'
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
...
}
If your app does not already have permissions enabled for internet use, add the following to your app’s AndroidManifest.xml
<manifest>
...
<uses-permission android:name="android.permission.INTERNET" />
...
</manifest>
Using the SDK
For Enrollments:
Incorporate your logic into a Fragment Activity() and declare a variable of the BankPay class.
package com.your_app
...
import com.certegy.bankpay_sdk_android.BankPay
...
class YourEnrollmentActivity : FragmentActivity() {
private lateinit var BankPay: BankPay
}
Build the BankPaySdkOptions object & Instantiate BankPay
Provide the required params as a BankPaySdkOptions object to be passed as a constructor to the BankPay class.
Required SDK Options
- environment: ([String]) – The API version. Possible values are
cce
orproduction
- publishableKey: ([String]) – Your BankPay publishableKey
Optional SDK Options
- openBankingRedirect: ([String]) – Your redirect URL for Open Banking.
HTTPS
protocol is enforced if not using a custom scheme.
val sdkOptions = BankPaySdkOptions(
"environment",
"publishableKey",
"openBankingRedirect"
)
BankPay = BankPay(sdkOptions)
Setup subscriptions and handlers to the SDK’s event responses
BankPay.addSubscription(EventName.CANCEL) { handleBankPayCancelEvent() }
BankPay.addSubscription(EventName.CLOSE) { handleBankPayCloseEvent() }
BankPay.addSubscription(EventName.FAILURE) { handleBankPayFailureEvent(it as BankPayFailureEvent) }
BankPay.addSubscription(EventName.READY_FOR_AUTHORIZATION) { handleBankPayReadyForAuthorizationEvent(it as BankPayReadyForAuthorizationEvent) }
BankPay.addSubscription(EventName.SUCCESS) { handleBankPaySuccessEvent(it as BankPaySuccessEvent) }
Note: See the Events section below for the BankPay SDK’s event response types.
Start the enrollment WebView
After subscribing to events. Pass your enrollment_intent_id
returned from the enrollment intent creation as well as context to the createEnrollmentWebView
function.
val bankPayWebView = BankPay.createEnrollmentWebview("enrollment_intent_id", this)
setContentView(bankPayWebView)
For Transactions:
Just like for enrollments, you should incorporate your logic into a FragmentActivity() and declare a variable of the BankPay class.
package com.your_app
...
import com.certegy.bankpay_sdk_android.BankPay
...
class YourTransactionActivity : FragmentActivity() {
private lateinit var BankPay: BankPay
}
Build the BankPaySdkOptions object & Instantiate BankPay
Provide the required params as a BankPaySdkOptions object to be passed as a constructor to the BankPay class.
Required SDK Options
- environment: ([String]) – The API version. Possible values are
cce
orproduction
- publishableKey: ([String]) – Your BankPay publishableKey
val sdkOptions = BankPaySdkOptions(
"environment",
"publishableKey",
)
BankPay = BankPay(sdkOptions)
Setup subscriptions and handlers to the SDK’s event responses
BankPay.addSubscription(EventName.CANCEL) { handleBankPayCancelEvent() }
BankPay.addSubscription(EventName.CLOSE) { handleBankPayCloseEvent() }
BankPay.addSubscription(EventName.FAILURE) { handleBankPayFailureEvent(it as BankPayFailureEvent) }
BankPay.addSubscription(EventName.READY_FOR_AUTHORIZATION) { handleBankPayReadyForAuthorizationEvent(it as BankPayReadyForAuthorizationEvent) }
BankPay.addSubscription(EventName.SUCCESS) { handleBankPaySuccessEvent(it as BankPaySuccessEvent) }
Note: See the Events section below for the BankPay SDK’s event response types.
Start the transaction WebView
After subscribing to events. Pass your transaction_intent_id
returned from the transaction intent creation as well as context to the createTransactionWebView
function.
val bankPayWebView = BankPay.createTransactionWebView("transaction_intent_id", this)
setContentView(bankPayWebView)
Supporting Open Banking
To support open banking you must setup a URL scheme or Deep Links then provide it using the openBankingRedirect
option in the BankPay SDK. For more information see Open Banking.
Events
The webview will emit events at various points during the enrollment and transaction flows. These are defined with the EventName
enum and dispatched through EventService
.
EventName.CANCEL
This is called whenever the user leaves the webview without finishing their enrollment or transaction.
Data
N/A
Handling
fun handleBankPayCancelEvent() {
// Handle cancel events
}
EventName.CLOSE
This is called whenever the user performs an action which should end the webview. This will be called after CANCEL
, FAILURE
, and SUCCESS
events.
Data
N/A
Handling
fun handleBankPayCloseEvent() {
// Handle close events
}
EventName.FAILURE
This is called when the user leaves the webview after their enrollment or transaction has failed.
Data
data class BankPayFailureEventData(
val message: String, // A description of the outcome.
val status: String // The status of the intent (Example: "declined")
)
Handling
fun handleBankPayFailureEvent(data: BankPayFailureEventData) {
// Handle failure events
}
EventName.READY_FOR_AUTHORIZATION
This is called when the user is finished with the enrollment or transaction and the intent is ready for authorization.
Data
data class BankPayReadyForAuthorizationEventData(
val intentId: String // The enrollment or transaction intent ID.
)
Handling
fun handleBankPayReadyForAuthorizationEvent(data: BankPayReadyForAuthorizationEventData) {
// Authorize enrollment intent using data.intentId
}
EventName.SUCCESS
This is called when the user leaves the webview after their enrollment or transaction has succeeded.
Data
data class BankPaySuccessEventData(
val message: String, // A description of the outcome.
val status: String // The status of the intent (Example: "accepted")
)
Handling
fun handleBankPaySuccessEvent(data: BankPaySuccessEventData) {
// Handle success events
}
Example
class EnrollmentActivity : FragmentActivity() {
private lateinit var BankPay: BankPay
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
startEnrollment()
}
private fun startEnrollment() {
val sdkOptions = BankPaySdkOptions(
"cce",
"publishableKey",
"my-custom-scheme://my-host"
)
BankPay = BankPay(sdkOptions)
BankPay.addSubscription(EventName.CANCEL) { handleBankPayCancelEvent() }
BankPay.addSubscription(EventName.CLOSE) { handleBankPayCloseEvent() }
BankPay.addSubscription(EventName.FAILURE) { handleBankPayFailureEvent(it as BankPayFailureEvent) }
BankPay.addSubscription(EventName.READY_FOR_AUTHORIZATION) { handleBankPayReadyForAuthorizationEvent(it as BankPayReadyForAuthorizationEvent) }
BankPay.addSubscription(EventName.SUCCESS) { handleBankPaySuccessEvent(it as BankPaySuccessEvent) }
val bankPayWebView = BankPay.createEnrollmentWebView("FAKE-INTENT-TOKEN", this)
setContentView(bankPayWebView)
}
fun handleBankPayCancelEvent() {
// Handle cancel events
}
fun handleBankPayCloseEvent() {
finish()
}
fun handleBankPayFailureEvent(event: BankPayFailureEvent) {
val data = event.data
// Handle failure events
}
fun handleBankPayReadyForAuthorizationEvent(event: BankPayReadyForAuthorizationEvent) {
val data = event.data
// Authorize enrollment intent using data.intentId
}
fun handleBankPaySuccessEvent(event: BankPaySuccessEvent) {
val data = event.data
// Handle success events
}
}