Loans SDK integation guides

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

Integration steps


SDK Interface

class ScLoan {
  constructor({ gatewayName }) {};

  // LOS (Loan origination)
  apply({ interactionToken }) {};


  // LMS (Loan servicing)
  pay({ interactionToken }) {};
  withdraw({ interactionToken }) {};
}
class ScLoan {
    /**
     * @typedef {Object} ScLoanConfig
     * @property {String} gatewayName
     * @property {'production'}  environment - environment
     */

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

    /**
     * LoanInfo object required for every SDK interaction
     * @typedef {Object} LoanInfo
     * @property {String} interactionToken
     */

    /**
     * Triggers the user journey for loan application.
     *
     * @param {LoanInfo} loanInfo
     * @returns {Promise<String>}
     */
    const apply = async (loanInfo) => {};

    /**
     * Triggers the user journey for loan repayment.
     *
     * @param {LoanInfo} loanInfo
     * @returns {Promise<String>}
     */
    const pay = async (loanInfo) => {};

    /**
     * Triggers the user journey for withdrawing the loan amount.
     *
     * @param {LoanInfo} loanInfo
     * @returns {Promise<String>}
     */
    const withdraw = async (loanInfo) => {};
}
object SCLoan {
    // Setup the SCLoan SDK
    fun setup(config: SCLoanConfig, listener: SCLoanResult)

    // Triggers the user journey for loan application
    fun apply(activity: AppCompatActivity, config: ScLoanInfo, listener: SCLoanResult)

    // Triggers the user journey for loan repayment
    fun pay(activity: AppCompatActivity, config: ScLoanInfo, listener: SCLoanResult)

    // Triggers the user journey for withdrawing the loan amount
    fun withdraw(activity: AppCompatActivity, 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 isSuccess: Boolean, val data: String?)

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

// LoanInfo object required for every SDK interaction
class ScLoanInfo(val interactionToken: String)
public class SCLoan {
  // Setup the SCLoan SDK
  @objc public func setup(
    config: SCLoanConfig,
    completion: @escaping (SCLoanSuccess?, SCLoanError?) -> Void
  )

  // where SCLoanConfig is:
  class SCLoanConfig: NSObject {
    let gatewayName: String?
    let environment: SCLoanEnvironment?
  }

  // Triggers the user journey for loan application
  @objc public func apply(
    presentingController: UIViewController,
    loanInfo: LoanInfo,
    completion: @escaping (SCLoanSuccess?, SCLoanError?) -> Void
  )

  // Triggers the user journey for loan repayment
  @objc public func pay(
    presentingController: UIViewController,
    loanInfo: LoanInfo,
    completion: @escaping (SCLoanSuccess?, SCLoanError?) -> Void
  )

  // Triggers the user journey for withdrawing the loan amount
  @objc public func withdraw(
    presentingController: UIViewController,
    loanInfo: LoanInfo,
    completion: @escaping (SCLoanSuccess?, SCLoanError?) -> Void
  )

}

// Where the success object is
public class SCLoanSuccess: NSObject {
  let isSuccess: Bool
  let data: String?
}

// And the error object is
public class SCLoanError: NSError {
  let isSuccess: Bool
  let errorCode: Int
  let errorMessage: String
  let data: String?
}

// LoanInfo object required for every SDK interaction
class LoanInfo: NSObject {
  let interactionToken: String
}

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).

Error codeError messageReason
1012user_cancelledThe user aborted the flow by closing/abandoning the UI
1031contact_supportThe user tapped the contact/support icon — redirect them to your support page or chat
2000internal_error
2001missing_url_params
3001existing_loan_found
4000invalid_request
4001partner_inactive
4002guest_not_allowed
4003interaction_expired
4004invalid_intent
4005invalid_interaction
4006invalid_intent_config
4007api_secret_mismatch
4008invalid_auth_token
📘

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