Skip to content

Commit

Permalink
Merge pull request #10 from smallcase/release/2.8.0
Browse files Browse the repository at this point in the history
Release/2.8.0
  • Loading branch information
indrajit-roy-sc authored Nov 30, 2022
2 parents 233dd70 + 033f199 commit 35aba9b
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 8 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
4 changes: 2 additions & 2 deletions .gradle/buildOutputCleanup/cache.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Wed Jul 13 17:40:30 IST 2022
gradle.version=7.4.2
#Wed Nov 09 12:03:19 IST 2022
gradle.version=7.3
4 changes: 2 additions & 2 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
</natures>
<filteredResources>
<filter>
<id>1621850988192</id>
<id>1667252335557</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
Expand Down
Binary file modified SCGateway.framework/.DS_Store
Binary file not shown.
75 changes: 75 additions & 0 deletions SCGatewayPhonegap.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.smallcase.gateway.data.listeners.DataListener;
import com.google.gson.Gson;
import com.smallcase.gateway.data.listeners.TransactionResponseListener;
import com.smallcase.gateway.data.listeners.MFHoldingsResponseListener;
import com.smallcase.gateway.data.models.TransactionResult;
import com.smallcase.gateway.data.listeners.SmallPlugResponseListener;
import com.smallcase.gateway.data.models.SmallPlugResult;
Expand Down Expand Up @@ -183,6 +184,33 @@ public void onError(int errorCode, @NonNull String errorMessage, @Nullable Strin
}
});
return true;
case "triggerMfTransaction":
SmallcaseGatewaySdk.INSTANCE.triggerMfTransaction(this.cordova.getActivity(), args.getString(0), new MFHoldingsResponseListener() {
@Override
public void onSuccess(@NonNull TransactionResult transactionResult) {
callbackContext.success(convertToJson(transactionResult));
}

@Override
public void onError(int errorCode, @NonNull String errorMessage, @Nullable String data) {

try {
JSONObject jo = new JSONObject();
jo.put("errorCode", errorCode);
jo.put("errorMessage", errorMessage);

if (data != null && !data.isEmpty()) {
jo.put("data", new JSONObject(data));
}
callbackContext.error(jo);

} catch (JSONException e) {
e.printStackTrace();
callbackContext.error("JSONException");
}
}
});
return true;
case "launchSmallplug":

SmallcaseGatewaySdk.INSTANCE.launchSmallPlug(this.cordova.getActivity(), new SmallplugData(args.getString(0), args.getString(1)), new SmallPlugResponseListener() {
Expand Down Expand Up @@ -307,6 +335,53 @@ public void onSuccess(@NonNull String leadStatusResponse) {

SmallcaseGatewaySdk.INSTANCE.triggerLeadGen(this.cordova.getActivity(), leadGenMap);

return true;
case "triggerLeadGenWithLoginCta":
Log.d("SCGatewayPhoneGap", "triggerLeadGenWithLoginCta args: " + args);
HashMap<String, String> leadGenMapUserDetails = new HashMap<String, String>();
if (args.get(0) instanceof JSONObject) {
JSONObject obj = (JSONObject) args.get(0);
Iterator<String> keys = obj.keys();
while (keys.hasNext()) {
String key = (String) keys.next(); // First key in your json object
String value = (String) obj.getString(key);
leadGenMapUserDetails.put(key, value);
}
}

HashMap<String, String> utmMap = new HashMap<String, String>();
if (args.get(1) instanceof JSONObject) {
JSONObject obj = (JSONObject) args.get(1);
Iterator<String> keys = obj.keys();
while (keys.hasNext()) {
String key = (String) keys.next(); // First key in your json object
String value = (String) obj.getString(key);
utmMap.put(key, value);
}
}

boolean showLoginCta = false;
if (args.get(2) instanceof JSONObject) {
JSONObject obj = (JSONObject) args.get(2);
try {
showLoginCta = obj.getBoolean("showLoginCta");
} catch (Exception e) {
}
}

SmallcaseGatewaySdk.INSTANCE.triggerLeadGen(
this.cordova.getActivity(),
leadGenMapUserDetails,
utmMap,
null,
showLoginCta,
new LeadGenResponseListener() {
@Override
public void onSuccess(@NonNull String leadStatusResponse) {
callbackContext.success(leadStatusResponse);
}
});

return true;
case "logout":

Expand Down
20 changes: 20 additions & 0 deletions SCGatewayPhonegap.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ exports.triggerTransaction = function(successCallback,failureCallback,args)
args);
};

exports.triggerMfTransaction = function(successCallback,failureCallback,args)
{
cordova.exec(
successCallback,
failureCallback,
"SCGatewayPhonegap",
"triggerMfTransaction",
args);
};

exports.triggerLeadGen = function(args)
{
cordova.exec(
Expand All @@ -69,6 +79,16 @@ exports.triggerLeadGenWithStatus = function(successCallback, failureCallback, ar
args);
};

exports.triggerLeadGenWithLoginCta = function(successCallback, failureCallback, args)
{
cordova.exec(
successCallback,
failureCallback,
"SCGatewayPhonegap",
"triggerLeadGenWithLoginCta",
args);
};

exports.logout = function(successCallback,failureCallback,args)
{
cordova.exec(
Expand Down
70 changes: 70 additions & 0 deletions SCGatewayPhonegap.m
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,59 @@ -(void)triggerTransaction:(CDVInvokedUrlCommand*)command{
}];
}

//MARK: Trigger Mf Transaction
-(void)triggerMfTransaction:(CDVInvokedUrlCommand*)command {
NSLog(@"transaction triggered");
__block CDVPluginResult *pluginResult = nil;
NSString *transactionId = [command.arguments objectAtIndex:0];
[SCGateway.shared
triggerMfTransactionWithPresentingController:
[[[UIApplication sharedApplication] keyWindow] rootViewController]
transactionId: transactionId
completion: ^(id response, NSError *error) {
if (error != nil) {
NSLog(@"%@", error.domain);
double delayInSeconds = 0.5;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
[responseDict setValue:[NSNumber numberWithBool:false] forKey:@"success"];
[responseDict setValue:[NSNumber numberWithInteger:error.code] forKey:@"errorCode"];
[responseDict setValue:error.domain forKey:@"error"];
[responseDict setValue:[error.userInfo objectForKey: @"data"] forKey:@"data"];
[responseDict setValue:@"ERROR" forKey:@"transaction"];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:responseDict];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
});
}

//MARK: intent - mf transaction
if ([response isKindOfClass: [ObjCTransactionIntentMfHoldingsImport class]]) {
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
ObjCTransactionIntentMfHoldingsImport *trxResponse = response;
NSData *decodedStringData = [[NSData alloc] initWithBase64EncodedString:trxResponse.data options: 0];
NSString *decodedResponse = [[NSString alloc] initWithData:decodedStringData encoding:1];
NSMutableDictionary *dict=[NSJSONSerialization JSONObjectWithData:[trxResponse.data dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:nil];
[responseDict setObject:dict forKey:@"data"];
[responseDict setValue:[NSNumber numberWithBool:true] forKey:@"success"];
[responseDict setObject:@"TRANSACTION" forKey:@"transaction"];
[responseDict setObject:@"TRANSACTION" forKey:@"transaction"];

[responseDict setObject:trxResponse.data forKey:@"data"];
NSLog(@"Decoded response %@", decodedResponse);
NSLog(@"TrxResponse data %@", trxResponse.data);
double delayInSeconds = 0.5;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:responseDict];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
});
return;
}
}];

}

- (void)launchSmallplug:(CDVInvokedUrlCommand *)command {
__block CDVPluginResult *pluginResult = nil;

Expand Down Expand Up @@ -320,6 +373,23 @@ - (void)setConfigEnvironment:(CDVInvokedUrlCommand*)command{

}

- (void)triggerLeadGenWithLoginCta:(CDVInvokedUrlCommand*)command{
NSDictionary *userDetailsDict = [command.arguments objectAtIndex:0];
NSDictionary *utmDict = [command.arguments objectAtIndex:1];
NSDictionary *leadGenProps = [command.arguments objectAtIndex:2];

BOOL showLoginCta = false;

if([leadGenProps[@"showLoginCta"] boolValue] == 1) {
showLoginCta = true;
}

[SCGateway.shared triggerLeadGenWithPresentingController:[[[UIApplication sharedApplication] keyWindow] rootViewController] params:userDetailsDict utmParams:utmDict retargeting:false showLoginCta:showLoginCta completion:^(NSString * leadStatusResponse) {
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:leadStatusResponse];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}

- (void)triggerLeadGenWithStatus:(CDVInvokedUrlCommand*)command{
NSDictionary *dict = [command.arguments objectAtIndex:0];
[SCGateway.shared triggerLeadGenWithPresentingController:[[[UIApplication sharedApplication] keyWindow] rootViewController] params:dict completion:^(NSString * leadStatusResponse) {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ repositories {
}

dependencies {
implementation 'com.smallcase.gateway:sdk:3.5.3';
implementation 'com.smallcase.gateway:sdk:3.6.4';
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.scgateway.phonegap",
"version": "2.7.0",
"version": "2.8.0",
"description": "Scgateway wrapper Cordova Plugin",
"cordova": {
"id": "com.scgateway.phonegap",
Expand Down
4 changes: 2 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.scgateway.phonegap" version="2.7.0">
id="com.scgateway.phonegap" version="2.8.0">
<name>Scgateway SDK</name>
<description>Scgateway wrapper Cordova Plugin</description>
<keywords>scgateway,gateway</keywords>
Expand Down Expand Up @@ -42,7 +42,7 @@
<source url="https://github.com/smallcase/cocoapodspecs.git" />
</config>
<pods use-frameworks="true" >
<pod name="SCGateway" spec="3.5.3" />
<pod name="SCGateway" spec="3.7.2" />
</pods>
</podspec>
<header-file src="SCGatewayPhonegap.h" />
Expand Down

0 comments on commit 35aba9b

Please sign in to comment.