Skip to content

Commit

Permalink
fix: fixed isInitialized function to give response in separate callback
Browse files Browse the repository at this point in the history
  • Loading branch information
subhash authored and harshgarg18 committed Aug 22, 2023
1 parent 565d46e commit 8fbe064
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 35 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ hyperSDKRef.process(JSON.stringify(completePayload));

Process payload - All payload ref is available at [HyperSDK process](https://developer.juspay.in/v2.0/docs/process-payload).

### Optional: isInitialised

This is a helper / optional method to check whether SDK has been initialised after [step-2](#step-2-initiate). It returns a `boolean` value in the callback function.

```javascript
hyperSDKRef.isInitialised((response) => {
// Make process call here if response is true
});
```

## License

hyper-sdk-plugin (HyperSDK Cordova) is distributed under [AGPL-3.0-only](https://github.com/juspay/hyper-sdk-cordova/src/release/LICENSE.md) license.
2 changes: 1 addition & 1 deletion scripts/postInstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports = (context) => {
let rootGradlePath = context.opts.projectRoot + '/platforms/android/build.gradle';
var rootGradleString = fs.readFileSync(rootGradlePath).toString();

let pluginClassPath = `classpath "in.juspay:hypersdk.plugin:2.0.2"`;
let pluginClassPath = `classpath "in.juspay:hypersdk.plugin:2.0.4"`;
let clientIdExt = `ext {\n\t\tclientId = "<clientId shared by Juspay team>"\n\t}\n`;
let finalString = (clientIdExt + '\tdependencies {\n\t\t' + pluginClassPath).replace(/\t/g, ' ')
rootGradleString = rootGradleString.replace('dependencies {', finalString);
Expand Down
68 changes: 34 additions & 34 deletions www/hypersdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,40 @@
* LICENSE file in the root directory of this source tree.
*/

var cordova = require("cordova"),
exec = require("cordova/exec");
var cordova = require("cordova"),
exec = require("cordova/exec");

// Using shared callback as HyperSDK is more event based
// than callback based
var sharedCallback;
// Using shared callback as HyperSDK is more event based
// than callback based
var sharedCallback;

// Helper method to call the native plugin
function callNative(name, args, pluginCallback) {
args = args || []
exec(pluginCallback, pluginCallback, "HyperSDKPlugin", name, [args])
}
// Helper method to call the native plugin
function callNative(name, args, pluginCallback) {
args = args || []
exec(pluginCallback, pluginCallback, "HyperSDKPlugin", name, [args])
}

/**
* @module HyperSDK
*/
module.exports = {
preFetch: function (payload, callback) {
callNative("preFetch", payload, callback);
},
initiate: function (payload, callback) {
sharedCallback = callback;
callNative("initiate", payload, sharedCallback);
},
process: function (payload) {
callNative("process", payload, sharedCallback);
},
onBackPress: function (callback) {
callNative("backPress", {}, callback);
},
terminate: function () {
callNative("terminate", {}, sharedCallback);
},
isInitialised: function () {
callNative("isInitialised", {}, sharedCallback);
}
}
/**
* @module HyperSDK
*/
module.exports = {
preFetch: function (payload, callback) {
callNative("preFetch", payload, callback);
},
initiate: function (payload, callback) {
sharedCallback = callback;
callNative("initiate", payload, sharedCallback);
},
process: function (payload) {
callNative("process", payload, sharedCallback);
},
onBackPress: function (callback) {
callNative("backPress", {}, callback);
},
terminate: function () {
callNative("terminate", {}, sharedCallback);
},
isInitialised: function (callback) {
callNative("isInitialised", {}, callback);
}
}

0 comments on commit 8fbe064

Please sign in to comment.