Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 35 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,20 @@ Add these lines to your project level `build.gradle`
```groovy
allprojects {
repositories {
// .. you other repositories
// .. your existing repositories

// Starting from version 2.3.0 all versions of the sdk are now hosted on a public repository
maven {
url "https://artifactory.smallcase.com/artifactory/SCGateway"
}

// Only for versions < 2.3.0
maven {
url "http://artifactory.smallcase.com/artifactory/gradle-dev-local"
url "https://artifactory.smallcase.com/artifactory/gradle-dev-local"
credentials {
username "react_native_user"
password "reactNativeUser123"
}
}
}
}
}
Expand All @@ -50,30 +57,30 @@ allprojects {
add these lines in `AndroidManifest.xml` in the main `<application />` tag

```xml
<activity android:name="com.smallcase.gateway.screens.transaction.activity.TransactionProcessActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="{YOUR_HOST_NAME}"
android:scheme="scgateway" />
</intent-filter>
<activity android:name="com.smallcase.gateway.screens.transaction.activity.TransactionProcessActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="<YOUR_GATEWAY_NAME>"
android:scheme="scgateway"
/>
</intent-filter>
</activity>

<activity android:name="com.smallcase.gateway.screens.common.RedirectActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />

<data
android:host="{YOUR_HOST_NAME}"
android:scheme="scgatewayredirect"
/>
</intent-filter>
<activity android:name="com.smallcase.gateway.screens.common.RedirectActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="<YOUR_GATEWAY_NAME>"
android:scheme="scgatewayredirect"
/>
</intent-filter>
</activity>
```

Expand All @@ -83,15 +90,14 @@ add these lines in `AndroidManifest.xml` in the main `<application />` tag
// import gateway into your file
import SmallcaseGateway from "react-native-smallcase-gateway";

// configure environment
await SmallcaseGateway.setConfigEnvironment({
isLeprechaun: true,
isAmoEnabled: true,
gatewayName: "smallcase-website",
gatewayName: "<YOUR_GATEWAY_NAME>",
// `environmentName` should always be PROD, regardless of your environment
environmentName: SmallcaseGateway.ENV.PROD,
brokerList: ["kite", "aliceblue", "trustline"],
brokerList: [],
});

// initialize session
await SmallcaseGateway.init(sdkToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun init(sdkToken: String, promise: Promise) {
Log.d(TAG, "init: start")

val initReq = InitRequest(sdkToken)
SmallcaseGatewaySdk.init(authRequest = initReq, gatewayInitialisationListener = object : DataListener<InitialisationResponse> {
Expand All @@ -84,6 +85,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun triggerTransaction(transactionId: String, utmParams: ReadableMap?, brokerList: ReadableArray?, promise: Promise) {
Log.d(TAG, "triggerTransaction: start")

var safeBrokerList = listOf<String>()

Expand All @@ -92,7 +94,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
}


val activity = currentActivity;
val activity = reactApplicationContext.currentActivity;
if (activity != null) {
val utm = readableMapToStrHashMap(utmParams)
SmallcaseGatewaySdk.triggerTransaction(utmParams = utm,
Expand All @@ -118,10 +120,10 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
@ReactMethod
fun triggerMfTransaction(transactionId: String, promise: Promise) {

if(currentActivity != null) {
if(reactApplicationContext.currentActivity != null) {

SmallcaseGatewaySdk.triggerMfTransaction(
activity = currentActivity!!,
activity = reactApplicationContext.currentActivity!!,
transactionId = transactionId,
listener = object : MFHoldingsResponseListener {

Expand All @@ -142,7 +144,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun showOrders(promise: Promise) {
val activity = currentActivity;
val activity = reactApplicationContext.currentActivity;
if (activity != null) {
SmallcaseGatewaySdk.showOrders(activity = activity, showOrdersResponseListener = object : DataListener<Any> {
override fun onSuccess(response: Any) {
Expand All @@ -159,8 +161,9 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun launchSmallplug(targetEndpoint: String, params: String, promise: Promise) {
Log.d(TAG, "launchSmallplug: start")

SmallcaseGatewaySdk.launchSmallPlug(currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener {
SmallcaseGatewaySdk.launchSmallPlug(reactApplicationContext.currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener {
override fun onFailure(errorCode: Int, errorMessage: String) {
val err = createErrorJSON(errorCode, errorMessage, null)

Expand Down Expand Up @@ -195,6 +198,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
}
}
}
Log.d(TAG, "launchSmallplugWithBranding: start")

var partnerProps: SmallplugPartnerProps? = SmallplugPartnerProps(headerColor = "#2F363F", backIconColor = "ffffff")

Expand All @@ -209,7 +213,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
} catch (e: Throwable) {
}

SmallcaseGatewaySdk.launchSmallPlug(currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener {
SmallcaseGatewaySdk.launchSmallPlug(reactApplicationContext.currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener {
override fun onFailure(errorCode: Int, errorMessage: String) {
val err = createErrorJSON(errorCode, errorMessage, null)
promise.reject("error", err)
Expand All @@ -224,6 +228,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun archiveSmallcase(iscid: String, promise: Promise) {
Log.d(TAG, "markSmallcaseArchive: start")

SmallcaseGatewaySdk.markSmallcaseArchived(iscid, object : DataListener<SmallcaseGatewayDataResponse> {

Expand All @@ -240,7 +245,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun logoutUser(promise: Promise) {
val activity = currentActivity;
val activity = reactApplicationContext.currentActivity;
if (activity != null) {
SmallcaseGatewaySdk.logoutUser(activity = activity, logoutListener = object : SmallcaseLogoutListener {
override fun onLogoutSuccessfull() {
Expand All @@ -257,15 +262,15 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun triggerLeadGen(userDetails: ReadableMap, utmData: ReadableMap) {
val activity = currentActivity;
val activity = reactApplicationContext.currentActivity;
if (activity != null) {
SmallcaseGatewaySdk.triggerLeadGen(activity = activity, utmParams = readableMapToStrHashMap(utmData), params = readableMapToStrHashMap(userDetails))
}
}

@ReactMethod
fun triggerLeadGenWithStatus(userDetails: ReadableMap, promise: Promise) {
val activity = currentActivity
val activity = reactApplicationContext.currentActivity
if (activity != null) {

SmallcaseGatewaySdk.triggerLeadGen(activity, readableMapToStrHashMap(userDetails), object : LeadGenResponseListener {
Expand All @@ -278,10 +283,10 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun triggerLeadGenWithLoginCta(userDetails: ReadableMap, utmData: ReadableMap, showLoginCta: Boolean, promise: Promise) {
if(currentActivity != null) {
if(reactApplicationContext.currentActivity != null) {

SmallcaseGatewaySdk.triggerLeadGen(
activity = currentActivity!!,
activity = reactApplicationContext.currentActivity!!,
params = readableMapToStrHashMap(userDetails),
utmParams = readableMapToStrHashMap(utmData),
retargeting = null,
Expand All @@ -296,7 +301,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun setupLoans(config: ReadableMap, promise: Promise) {
val appCompatActivity = currentActivity as? AppCompatActivity ?: return
val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return
val hashMap = readableMapToStrHashMap(config)
val gateway = hashMap["gatewayName"]
val environment = hashMap["environment"]
Expand Down Expand Up @@ -324,7 +329,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun apply(loanConfig: ReadableMap, promise: Promise) {
val appCompatActivity = currentActivity as? AppCompatActivity ?: return
val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return
val hashMap = readableMapToStrHashMap(loanConfig)
val interactionToken = hashMap["interactionToken"]
if(interactionToken == null) {
Expand All @@ -345,7 +350,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun pay(loanConfig: ReadableMap, promise: Promise) {
val appCompatActivity = currentActivity as? AppCompatActivity ?: return
val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return
val hashMap = readableMapToStrHashMap(loanConfig)
val interactionToken = hashMap["interactionToken"]
if(interactionToken == null) {
Expand All @@ -366,7 +371,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun withdraw(loanConfig: ReadableMap, promise: Promise) {
val appCompatActivity = currentActivity as? AppCompatActivity ?: return
val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return
val hashMap = readableMapToStrHashMap(loanConfig)
val interactionToken = hashMap["interactionToken"]
if(interactionToken == null) {
Expand All @@ -387,7 +392,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun service(loanConfig: ReadableMap, promise: Promise) {
val appCompatActivity = currentActivity as? AppCompatActivity ?: return
val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return
val hashMap = readableMapToStrHashMap(loanConfig)
val interactionToken = hashMap["interactionToken"]
if(interactionToken == null) {
Expand All @@ -408,7 +413,7 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte

@ReactMethod
fun triggerInteraction(loanConfig: ReadableMap, promise: Promise) {
val appCompatActivity = currentActivity as? AppCompatActivity ?: return
val appCompatActivity = reactApplicationContext.currentActivity as? AppCompatActivity ?: return
val hashMap = readableMapToStrHashMap(loanConfig)
val interactionToken = hashMap["interactionToken"]
if(interactionToken == null) {
Expand Down