Installation

Step 1: Add to app-level build.gradle and sync project to gradle

dependencies {     
    implementation 'co.imprint.sdk:imprint-sdk:0.2.0'
}

Implementation

Step 2: Import the SDK

import co.imprint.sdk.Imprint

Step 3: Configuration

Create an instance of ImprintConfiguration with your clientSecret and environment, then assign additional optional fields as needed.

val configuration = ImprintConfiguration(
  clientSecret = "client_secret",
  environment = ImprintConfiguration.Environment.SANDBOX,
)

Step 4: Define the completion handler

Define the completion handler onCompletion to manage the terminal states when the application flow ends.

val onCompletion =
      { state: CompletionState, metadata: Map<String, Any?>? ->
        val metadataInfo = metadata?.toString() ?: "No metadata"
        val resultText = when (state) {
          CompletionState.OFFER_ACCEPTED -> {
            "Offer accepted\n$metadataInfo"
          }
          CompletionState.REJECTED -> {
            "Application rejected\n$metadataInfo"
          }
          CompletionState.IN_PROGRESS -> {
            "Incomplete application\n$metadataInfo"
          }
          CompletionState.ERROR -> {
            "Error occured\n$metadataInfo"
          }
        }
        Log.d("Application result:", resultText)
      }

Step 5: Starting the Application flow

Once you have configured the ImprintConfiguration, initiate the application flow by calling ImprintApp.startApplication. This will start within a new Activity.

  fun startApplication(
    context: Context,
    configuration: ImprintConfiguration,
    onCompletion: (CompletionState, Map<String, Any?>?) -> Unit,
  )

context: The context from which the application process will be presented

configuration: The previously created ImprintConfiguration object containing your API key and completion handler

onCompletion: The completion handler of the flow

Complete code example

fun startApplication(context: Context) {
    val configuration = ImprintConfiguration(
      clientSecret = "client_secret",
      environment = ImprintConfiguration.Environment.SANDBOX,
    )

    val onCompletion =
      { state: CompletionState, metadata: Map<String, Any?>? ->
        val metadataInfo = metadata?.toString() ?: "No metadata"
        val resultText = when (state) {
          CompletionState.OFFER_ACCEPTED -> {
            "Offer accepted\n$metadataInfo"
          }
          CompletionState.REJECTED -> {
            "Application rejected\n$metadataInfo"
          }
          CompletionState.IN_PROGRESS -> {
            "Incomplete application\n$metadataInfo"
          }
          CompletionState.ERROR -> {
            "Error occured\n$metadataInfo"
          }
        }
        Log.d("Application result:", resultText)
      }

    // Start the application process with the provided context, configuration, and callback
    Imprint.startApplication(
      context = context,
      configuration = configuration,
      onCompletion = onCompletion,
    )
  }

Request Parameters

PROPERTY NAMEREQUIREDTYPEDESCRIPTION
clientSecretTRUEStringGenerated through Create Customer Session

Response Data

PROPERTY NAMESTYPEDESCRIPTION
customer_idString | nullImprint identifier for customer
partner_customer_idString | nullPartner identifier for customer
payment_method_idString | nullID to the payment method of customer
error_codeErrorCode | nullIdentifier for the specific error encountered

ErrorCode (Enum)

ENUMDESCRIPTION
INVALID_CLIENT_SECRETIndicate Client Secret is invalid
UNKNOWN_ERRORIndicate other unexpected error happened

Application States

ENUMDESCRIPTION
OFFER_ACCEPTEDApplication has been approved and credit offer accepted. New cardholder!
REJECTEDApplication has been rejected by Imprint
IN_PROGRESSApplication has been exited, not completed
ERRORInvalid request parameters (e.g., invalid client secret)