Package-level declarations
Requirements
Tooling
AGP version
>=8.6.0Gradle version
>=8.7
App Permissions
android.Manifest.permission.NFC– the SDK uses the NFC feature of the Android device to communicate with the payment card/mobile wallet. Without this permission the Tap on Phone solution will not work.android.Manifest.permission.VIBRATE– the SDK uses the Vibrate feature of the Android device for the required Haptics and to indicate a card has been read.android.permission.INTERNET– the SDK requires access to internet to communicate to backend services – assumption is that all partner applications will be online so it should not be an additional permission for most partners.android.permission.ACCESS_NETWORK_STATE– ensures that the SDK can communicate before attempting a transaction.
Miscellaneous
Applications should prevent the screen from sleeping while waiting to accept a tap.
Usage
The main entry point is a factory method: MoovSDK.createTerminal. This initializes a terminal instance which ensures a secure environment. This method should be called as early in the application's lifecycle as is practical, as it may take a significant amount of time to complete the device attestation.
Creating an EMV authorization will grab exclusive access to the device's NFC reader, allowing tap of an EMV card.
There are two main paths to accept EMV payments:
Create an authorization via the SDK and create the
transferseparatelyDirectly create a
transferfrom the SDK
For more context on these two options, please see the Moov API documentation.
Initialization
SDK initialization requires MoovSDK.onApplicationCreated to be called in the app's Application.onCreate method. Additionally, MoovSDK.isApplicationProcess should be used to determine whether or not the app should proceed with any initialization logic in its onCreate method.
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// initialize the Moov SDK
MoovSDK.onApplicationCreated(this, logger)
// return if not being called from the main process
if (!MoovSDK.isApplicationProcess()) {
return
}
// proceed to initialize the app
}
}The SDKLogger which must be passed into onApplicationCreated is to enable debugging in the case of failed taps in production. The data passed to this logger will never contain PCI or PII data, so they are safe to share over standard communication channels. When reporting issues with production taps to Moov support, please include the contents of this log.
Examples
External transfer creation
This method accepts the EMV tap, authorizes the transaction with the card network, and returns a token which can be passed into the createTransfer API.
val terminalConfig = fetchTerminalConfig() // fetch the terminal config from the Moov API
val terminal = MoovSDK.createTerminal(
applicationContext,
terminalConfig,
)
val authorization = terminal.createTapAuthorization(
TapAuthorizationParams(
amount = 100L,
currency = Currency.getInstance("USD"),
customerAccountID = "962aa592-5993-49d6-ae54-d6d6ab917c66",
)) {
LOG.d(TAG, "EMV message received: $it")
}
}
// now, create the transfer externally using the authorization as the sourceDirect transfer creation
This method accepts the EMV tap, authorizes the transaction with the card network, creates a transfer on the Moov platform, and returns the transfer ID.
val terminalConfig = fetchTerminalConfig() // fetch the terminal config from the Moov API
val terminal = MoovSDK.createTerminal(
applicationContext,
terminalConfig,
)
val transferID = terminal.createTapTransfer(
CreateTransferParams(
TapAuthorizationParams(
amount = 100L,
currency = Currency.getInstance("USD"),
customerAccountID = "962aa592-5993-49d6-ae54-d6d6ab917c66",
),
partnerAccountID = "fd35bc72-fa52-4fef-a0f5-f99fa1280aeb",
destinationPaymentMethodID = "19a76ccb-be73-4394-a9ca-701c0a20fd8a",
description = "A fancy widget",
)) {
LOG.d(TAG, "EMV message received: $it")
}
}