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 code | Error message | Reason |
|---|---|---|
| 1012 | user_cancelled | The user aborted the flow by closing/abandoning the UI |
| 1014 | no_compatible_browser | Android only - no compatible browser is available on the device to launch the secure flow |
| 1031 | contact_support | The user tapped the contact/support icon - redirect them to your support page or chat |
| 2000 | internal_error | |
| 2001 | missing_url_params | |
| 3001 | existing_loan_found | |
| 3004 | init_sdk | An SDK method was called before setup() completed successfully - call setup() first |
| 4000 | invalid_request | |
| 4001 | partner_inactive | |
| 4002 | guest_not_allowed | |
| 4003 | interaction_expired | |
| 4004 | invalid_intent | |
| 4005 | invalid_interaction | |
| 4006 | invalid_intent_config | |
| 4007 | api_secret_mismatch | |
| 4008 | invalid_auth_token | |
| 4009 | dashboard_already_open | JavaScript only - service() was called while a dashboard is already open |
| 4010 | element_not_found | JavaScript only - the target DOM element ID passed to service() was not found |
Refer - How to call Unity API and how to create interaction token?
Updated 15 days ago
Did this page help you?