Best Practices
Please follow the Android Studio guidelines for writing code, this can be found using this link.
Error Handling:
Plain text
val parsedAmount = parseAmount(street) ?: run {
Toast.makeText(this, "Invalid amount", Toast.LENGTH_SHORT).show()
return
}Logging
Plain text
Log.d("SDK", "Sending transaction: $request")Threading
Always update UI with runOnUiThread { }
Project Structure Example
Plain text
app/
├── build.gradle.kts
├── src/
│ └── main/
│ ├── java/ // Kotlin source code
│ ├── res/ // JSON/xml resources
│ └── aidl/ // AIDL interface files from SDK
├── libs/
│ └── tnsi-sdk.aar // Payment SDK binaryKey Notes
- Validation: Ensure
amount,currency, andreaderTypematch business rules before sending the request. - Error Handling: The SDK should provide exceptions or status codes for invalid input (e.g., missing
msgType). - Security: Sensitive data (e.g.,
agreementID,jsonMsg) should be encrypted if transmitted outside the app. - Logging: Debug logs can track
invoiceNbrandorigTransNofor auditing. - Validation: Always validate parsing results (
?.takeIf { it > 0 }). - Default Values:
invoiceNbrandcurrencyare hardcoded (USD). - Tokenization: If
tokenRequestis checked,agreementIDandagreementTypeare included.
Disclaimers / Consent
The app/merchant should allow for the display of disclaimers/collect consent whenever applicable. eg. during Tokenization.
If requesting a token for a cardholder, you need to ensure the merchant collects consent from the customer to allow the merchant to store the card token information and to perform future transactions
.
Was this section helpful?
On this page
- Best Practices