Data Models
- Error Codes (
MPoCErrorCode
)
enum class MPoCErrorCode(val code: Int, val desc: String) {
SUCCESS(0, "success"),
ErrInvalidLicense(41000, "invalid license file"),
ErrInitFails(41100, "sdk initialization fails"),
ErrInsecureDeviceConfigure(41200, "insecure device settings"),
ErrInsecureRunningEnvironment(41300, "insecure execution environment"),
ErrAttestationFail(41400, "attestation result indicated fail"),
ErrInvalidParameters(41500, "provided parameters are invalid"),
ErrCryptoKeyMissing(41600, "cryptographic key invalid"),
ErrCryptoOperationFails(41700, "cryptographic fails"),
ErrRegistrationFails(41800, "registration fails"),
ErrNetworkUnreachable(41900, "network connection with host fails"),
ErrNetworkConnectionFailsOrTimeout(42000, "network connection fails or timeout"),
ErrNoSupportedEmvApp(-3, "No application in card"),
ErrKernelNoSupported(-38, "application is not supported or prohibited"),
ErrUnknownError(99999, "general unexpected unknown error");
companion object {
@JvmStatic
fun fromCode(errCode: Int): MPoCErrorCode? {
return MPoCErrorCode.entries.find { it.code == errCode } ?: ErrUnknownError
}
}
}
MPoCResult
definition
sealed class MPoCResult<out T> {
data class Success<T>(val data: T) : MPoCResult<T>()
data class Failure(val code: Int, val message: String, val contextual: String = "") : MPoCResult<Nothing>()
}
PaymentMethod
definition
enum class PaymentMethod {
VISA,
MASTERCARD,
UNIONPAY,
AMEX,
JCB,
DISCOVER,
DINERS
}
- Card CVM definition
enum class CardCVM {
NO_CVM,
SIGNATURE,
PIN,
OFFLINE_PIN,
CDCVM
}
- Encrypt mode definition
enum class EncryptMode {
CBC,
GCM
}
- UI state definition
sealed interface UiState {
//Before card reading, the SDK has to do preparations such as security checking, key preparation etc.
//Errors happens in this stage will terminate the activity and return.
sealed interface Preparing : UiState {
data object Idle : Preparing
}
//Once preparation is done, SDK card reading flow jumps into AwaitingCardScreen to start card reading.
//PIN Entry may be required during this period.
sealed interface Awaiting : UiState {
data class Idle(
val supportedPayments: List<PaymentMethod>
) : Awaiting
data object OperationErrorCheck : Awaiting
}
}
- MPoC
PaymentErrorCodes
error code (for card reading process)
enum class PaymentErrorCodes(val code: Int, val message: String) {
// general errors
InvalidInputRequest(70_001, "Invalid Input"),
// aborted,the acitivity will finsih with specify error code and error message.
AbortedProcessingTimeOut(70_009, "processing timeout"),
AbortedNfcTappingTimeOut(70_002, "Nfc card tapping timeout"),
AbortedUserCancelTapping(70_003, "User cancel card tapping"),
AbortedUserCancelPIN(70_004, "User cancel PIN Entry"),
AbortedPinEntryTimeOut(70_005, "PIN Entry timeout"),
AbortedSecurityAlert(70_006, "Security Checks fail"),
AbortedProcessQuit(70_007, "Processing Activity Quit"),
AbortedCardKeyLoadingFail(70_008, "CardKey Loading fails"),
AbortedCardReadRetryCountExceeded(70_009, "Card read retry count exceeded"),
AbortedCardReadError(70_010, "EMV card declined"),
AbortedCardDataValidationError(70_011, "Card data validation error"),
AbortedCryptoOperationError(70_012, "MPoC crypto operation error"),
AbortedCardDataEncryptionError(70_013, "MPoC crypto operation error"),
//PIN entry eror
PinKeyNotReady(71_005, "PIN Key is not ready, please retry"),
PinProcessException(71_006, "PIN Entry exception"),
PaymentProcessRetryableFail(71_004, "operation fails, please retry"),
// other resource exception
OtherSourceError(72_000, "Error from other source")
}
- SdkInfo Definition
data class SdkInitResult(
val isRegistered: Boolean = false,
val sdkId: String = "",
val sdkBuildModel: String = "DEBUG",
val sdkVersion: String = "",
val licenseId: String = "",
val customerId: String = "",
val serverUrl: String = "",
val kekCert: String = "",
val signCert: String = ""
)