Loans SDK integration guides

This document lists the key steps required to launch all SDK flows.

Integration steps


SDK Interface

class ScLoan {
  constructor({ gatewayName }) {}

  // LOS — triggers a new loan origination journey
  apply({ interactionToken }) {}

  // LMS — opens the repayment flow
  pay({ interactionToken }) {}

  // LMS — opens the principal withdrawal flow
  withdraw({ interactionToken }) {}

  // LMS — renders the loan dashboard inside a target DOM element
  // Returns { close: () => Promise, task: Promise }
  // `target` is the DOM element ID to inject the iframe into
  service({ interactionToken, target }) {}
}
class ScLoan {
    /**
     * @typedef {Object} ScLoanConfig
     * @property {String} gatewayName
     * @property {'production' | 'staging'} environment
     */

    /**
     * Setup ScLoans
     * @param {ScLoanConfig} config
     * @returns {Promise<ScLoanSuccess>}
     * @throws {ScLoanError}
     */
    const setup = async (config) => {};

    /**
     * @typedef {Object} ScLoanInfo
     * @property {String} interactionToken
     */

    /**
     * Triggers the loan interaction. The flow is determined by the interactionToken.
     * @param {ScLoanInfo} loanInfo
     * @returns {Promise<ScLoanSuccess>}
     * @throws {ScLoanError}
     */
    const triggerInteraction = async (loanInfo) => {};


    // ─── Deprecated ───────────────────────────────────────────────────────────
    // Use triggerInteraction() instead.

    /** @deprecated */
    const apply = async (loanInfo) => {};

    /** @deprecated */
    const pay = async (loanInfo) => {};

    /** @deprecated */
    const withdraw = async (loanInfo) => {};

    /** @deprecated */
    const service = async (loanInfo) => {};
}
object ScLoan {
    // Setup the ScLoan SDK
    fun setup(config: ScLoanConfig, listener: ScLoanResult)

    // Triggers the loan interaction. The flow is determined by the interactionToken.
    fun triggerInteraction(activity: Activity, config: ScLoanInfo, listener: ScLoanResult)
}

// Callback interface for every SDK method
interface ScLoanResult {
    fun onSuccess(response: ScLoanSuccess)
    fun onFailure(error: ScLoanError)
}

// Success callback returns
data class ScLoanSuccess(val data: String?, val code: Int, val message: String)

// Failure callback returns
data class ScLoanError(val code: Int, val message: String, val data: String?)

// Config object required for setup
data class ScLoanConfig(
    val gatewayName: String,
    val environment: ScLoanEnvironment = ScLoanEnvironment.PRODUCTION
)

// LoanInfo object required for triggerInteraction
class ScLoanInfo(val interactionToken: String)


// ─── Deprecated ───────────────────────────────────────────────────────────────
// Use triggerInteraction() instead.

@Deprecated fun apply(activity: Activity, config: ScLoanInfo, listener: ScLoanResult)
@Deprecated fun pay(activity: Activity, config: ScLoanInfo, listener: ScLoanResult)
@Deprecated fun withdraw(activity: Activity, config: ScLoanInfo, listener: ScLoanResult)
@Deprecated fun service(activity: Activity, config: ScLoanInfo, listener: ScLoanResult)
public class ScLoan: NSObject {
    public static let instance = ScLoan()

    // Setup the ScLoan SDK
    public func setup(
        config: ScLoanConfig,
        completion: @escaping (ScLoanResult<ScLoanSuccess>) -> Void
    )

    // Triggers the loan interaction. The flow is determined by the interactionToken.
    public func triggerInteraction(
        presentingController: UIViewController,
        loanInfo: ScLoanInfo,
        completion: @escaping (ScLoanResult<ScLoanSuccess>) -> Void
    )
}

// typealias ScLoanResult<T> = Result<T, ScLoanError>

// Config object required for setup
public class ScLoanConfig: NSObject {
    public init(gatewayName: String, environment: SCLoanEnvironment? = .production)
}

// LoanInfo object required for triggerInteraction
public class ScLoanInfo: NSObject {
    public init(interactionToken: String)
}

// Success callback — isSuccess is always true
public class ScLoanSuccess: NSObject {
    public let isSuccess: Bool  // always true
    public let data: String?
}

// Failure callback
public class ScLoanError: NSError {
    public let errorCode: Int
    public let errorMessage: String
    public let data: String?
}


// ─── Deprecated ───────────────────────────────────────────────────────────────
// Use triggerInteraction() instead.

@available(*, deprecated, message: "Use triggerInteraction() instead.")
public func apply(presentingController: UIViewController, loanInfo: ScLoanInfo, completion: ...)

@available(*, deprecated, message: "Use triggerInteraction() instead.")
public func pay(presentingController: UIViewController, loanInfo: ScLoanInfo, completion: ...)

@available(*, deprecated, message: "Use triggerInteraction() instead.")
public func withdraw(presentingController: UIViewController, loanInfo: ScLoanInfo, completion: ...)

@available(*, deprecated, message: "Use triggerInteraction() instead.")
public func service(presentingController: UIViewController, loanInfo: ScLoanInfo, completion: ...)
class ScLoan {
    // Setup the ScLoan SDK
    static Future<ScLoanSuccess> setup(ScLoanConfig config) async {}

    // Triggers the loan interaction. The flow is determined by the interactionToken.
    static Future<ScLoanSuccess> triggerInteraction(ScLoanInfo loanInfo) async {}


    // Deprecated — use triggerInteraction() for all new integrations.

    static Future<ScLoanSuccess> apply(ScLoanInfo loanInfo) async {}    // @deprecated
    static Future<ScLoanSuccess> pay(ScLoanInfo loanInfo) async {}      // @deprecated
    static Future<ScLoanSuccess> withdraw(ScLoanInfo loanInfo) async {} // @deprecated
    static Future<ScLoanSuccess> service(ScLoanInfo loanInfo) async {}  // @deprecated
}

// Config object required for setup
// Note: positional constructor — environment first, then gateway name
class ScLoanConfig {
    final ScLoanEnvironment environment;
    final String gateway;

    const ScLoanConfig(this.environment, this.gateway);
}

// LoanInfo object required for triggerInteraction
class ScLoanInfo {
    final String interactionToken;

    const ScLoanInfo(this.interactionToken);
}

enum ScLoanEnvironment { PRODUCTION, STAGING }

Error codes

All Loans SDK methods return an error object of shape { code, message, data? } when the user's intended action isn't completed. These codes are common across all platform SDKs (web, Android, iOS, Flutter, React Native) unless marked otherwise.

Error codeError messageReason
1012user_cancelledThe user aborted the flow by closing/abandoning the UI
1014no_compatible_browserAndroid only - no compatible browser is available on the device to launch the secure flow
1031contact_supportThe user tapped the contact/support icon - redirect them to your support page or chat
2000internal_error
2001missing_url_params
3001existing_loan_found
3004init_sdkAn SDK method was called before setup() completed successfully - call setup() first
4000invalid_request
4001partner_inactive
4002guest_not_allowed
4003interaction_expired
4004invalid_intent
4005invalid_interaction
4006invalid_intent_config
4007api_secret_mismatch
4008invalid_auth_token
4009dashboard_already_openJavaScript only - service() was called while a dashboard is already open
4010element_not_foundJavaScript only - the target DOM element ID passed to service() was not found
📘

Refer - How to call Unity API and how to create interaction token?



Did this page help you?