A. Performing an Authentication
This guide explains how to start Entrupy's item authentication process using the Android SDK, including how to provide item metadata and handle results via the capture flow.
✅ Pre-requisite:
Ensure SDK User Authorization is complete and the user has a valid session before initiating any capture.
1. (Optional) Pre-fetching SDK Configuration
The Entrupy SDK may need to fetch configuration data from Entrupy's servers. While this happens automatically during the first capture, you can reduce initial latency by preloading the configuration earlier (e.g., on screen load).
Kotlin:
if (EntrupySdk.getInstance().isAuthorizationValid()) {
EntrupySdk.getInstance().setConfigCallback(object : EntrupyConfigCallback {
override fun onConfigSuccess() {
Log.d("Entrupy", "Configuration fetched successfully.")
}
override fun onConfigFailure(errorCode: EntrupyErrorCode, message: String){
Log.e("Entrupy", "Failed to fetch config: $message (Code: $errorCode)")
}
})
EntrupySdk.getInstance().fetchConfiguration(EntrupySdk.ConfigType.PRODUCTION)
} else {
Log.w("Entrupy", "User not authorized. Skipping config prefetch.")
}
📌 Use ConfigurationType.DEBUG for test environments. It shortens the capture process but results in invalid outcomes.
2. Preparing Item Metadata
Before starting the capture flow, provide item details in a structured map. This metadata is required by the SDK.
Common Metadata Fields:
Key | Required | Example |
---|---|---|
brand | Yes | "nike" |
style_name | Yes | "Air Jordan 1 Retro High OG SP" |
customer_item_id | Strongly recommended | "INTERNAL_SKU_12345" |
us_size | Optional | "9.5" |
upc | Optional | "00195244532483" |
style_code | Optional | "DO7097-100" |
Kotlin Example:
val itemMetadata = mapOf(
"brand" to "Nike",
"style_name" to "Air Jordan 1 Retro High OG SP",
"customer_item_id" to "INTERNAL_SKU_12345",
"us_size" to "9.5",
"upc" to "00195244532483",
"style_code" to "DO7097-100"
)
📌 Tip: Accurate brand and style information is crucial. Contact Entrupy for supported brand IDs if unsure.
3. Starting the Capture Flow
To start the capture, pass your metadata and an Activity
context. You must implement the EntrupyCaptureCallback
interface to handle capture results.
Kotlin Example:
EntrupySdk.getInstance().startCapture(
context = this,
itemMetadata = itemMetadata,
captureCallback = object : EntrupyCaptureCallback {
override fun onCaptureSuccess(result: Map<String, Any>, item: Map<String, Any>) {
Log.d("Entrupy", "Capture submitted: $result")
}
override fun onUserCanceled(item: Map<String, Any>) {
Log.i("Entrupy", "User cancelled capture: ${item["customer_item_id"]}")
}
override fun onCaptureTimeout(item: Map<String, Any>) {
Log.w("Entrupy", "Capture timed out: ${item["customer_item_id"]}")
}
override fun onCaptureError(
errorCode: EntrupyErrorCode,
message: String,
item: Map<String, Any>
) {
Log.e("Entrupy", "Capture failed (${item["customer_item_id"]}): $message ($errorCode)")
}
}
)
Timeout Behavior:
If the user does not complete the capture within 2 hours, the SDK cancels the session and calls
onCaptureTimeout
.
4. Handling Capture Results
The initial result from onCaptureSuccess()
includes metadata like:
- Submission ID
- Item ID
- Initial status
- ETA for final result
Final Results:
These are typically delivered to your backend via webhook. Your app may display pending state or use polling for status updates if needed.
Example Flow Summary:
Actions |
---|
Authorize the user with a signed request |
(Optional) Call fetchConfiguration() to reduce capture load time |
Collect item metadata (brand, style, ID, etc.) |
Call startCapture(...) and show Entrupy's guided UI |
Handle results with EntrupyCaptureCallback |
Wait for final results via web-hook or backend query |