Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EFTCLIENT-4796 #157

Merged
merged 6 commits into from
Jun 21, 2023
Merged
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
19 changes: 15 additions & 4 deletions src/android/com/handpoint/cordova/HandpointHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ public void printDetailedLog(CallbackContext callbackContext, JSONObject params)
try {
String log = params.getString("log");
Logger.getLogger("App-Detailed-Logger").warning("***[APP] -> " + log);
callbackContext.success("ok");
} catch (Exception e) {
callbackContext.error("printDetailedLog Error Message -> " + e.getMessage());
callbackContext.error("printDetailedLog Error Cause-> " + e.getCause());
}
callbackContext.success("ok");
}

// An Android Context is required to be able to handle bluetooth
Expand Down Expand Up @@ -136,7 +136,7 @@ public void sale(CallbackContext callbackContext, JSONObject params) throws Thro
}

if (result.getOperationStarted()) {
callbackContext.success("ok");
callbackContext.success(result.getTransactionReference());
} else {
callbackContext.error("Can't send sale operation to device");
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public void refund(CallbackContext callbackContext, JSONObject params) throws Th
}

if (result.getOperationStarted()) {
callbackContext.success("ok");
callbackContext.success(result.getTransactionReference());
} else {
callbackContext.error("Can't send refund operation to device");
}
Expand Down Expand Up @@ -439,6 +439,15 @@ public void getTransactionsReport(CallbackContext callbackContext, JSONObject pa
}
}

public void getTransactionStatus(CallbackContext callbackContext, JSONObject params) throws Throwable {
try {
this.api.getTransactionStatus(params.getString("transactionReference"));
callbackContext.success("ok");
} catch (JSONException ex) {
callbackContext.error("Can't execute getTransactionStatus. Incorrect parameters");
}
}

public void mposAuth(CallbackContext callbackContext, JSONObject params) throws Throwable {
try {
Class auth = Class.forName("com.handpoint.api.privateops.HapiMposAuthentication");
Expand All @@ -447,6 +456,7 @@ public void mposAuth(CallbackContext callbackContext, JSONObject params) throws
HapiMPosAuthResponse authenticationResponseHandler = new HapiMPosAuthResponse() {
@Override
public void setAuthenticationResult(AuthenticationResponse oneThing) {
callbackContext.success("ok");
authStatus(oneThing);
}
};
Expand Down Expand Up @@ -609,11 +619,12 @@ public void transactionResultReady(TransactionResult transactionResult, Device d
}

@Override
public void transactionStarted(TransactionType type, BigInteger amount, Currency currency) {
public void transactionStarted(TransactionType type, BigInteger amount, Currency currency, String transactionReference) {
SDKEvent event = new SDKEvent("transactionStarted");
event.put("type", type.toString());
event.put("amount", amount.toString());
event.put("currency", currency.getAlpha());
event.put("transactionReference", transactionReference);
PluginResult result = new PluginResult(PluginResult.Status.OK, event.toJSONObject());
result.setKeepCallback(true);
if (this.callbackContext != null) {
Expand Down
4 changes: 2 additions & 2 deletions src/android/pax.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ repositories{
dependencies {
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'org.slf4j:slf4j-android:1.7.25'
implementation ('com.handpoint.api:private-sdk:7.1001.4-RC.0') { changing = true }
implementation ('com.handpoint.api:applicationprovider:7.1001.4-RC.0') { changing = true }
implementation ('com.handpoint.api:private-sdk:7.1002.0-EZE-RC.3-SNAPSHOT') { changing = true }
implementation ('com.handpoint.api:applicationprovider:7.1002.0-EZE-RC.3-SNAPSHOT') { changing = true }
}

android {
Expand Down
11 changes: 11 additions & 0 deletions www/handpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,17 @@ Handpoint.prototype.getTransactionsReport = function (config, successCallback, e
this.exec('getTransactionsReport', config, successCallback, errorCallback);
};

/**
* Gets the transaction status.
* @param {Object} config parameters
* @param config.transactionReference The id of the transaction
* @param {Function} successCallback This function will be called if operation succeed
* @param {Function} errorCallback This function will be called if an error happened
*/
Handpoint.prototype.getTransactionStatus = function (config, successCallback, errorCallback) {
this.exec('getTransactionStatus', config, successCallback, errorCallback);
};

/**
* Starts a connection monitoring service. The service listens to events sent by the operating system about
* the connected hardware. If the service notices that a previously connected device suddenly disconnects
Expand Down