Code Snippets
Android
isInitialised
Checks if current HyperSDK has been initialised. It should be used to check the HyperSDK instance state before calling process API.
UUID
Sample snippets to generate uuid-v4 string. Used in HyperSDK as [requestId]
Backpress control
Since HyperSDK is a fragment, we will need the back-press event from the current activity to trigger events required for hardware back press.
hyperServices.onBackPressed() should be called during activity’s onBackPressed(). If the result is true, HyperSDK will consume the hardware back press.
In case the merchant wants to control backpress, they can call hyperServices.onBackPressed only when the UI is shown and Juspay can handle backpress. They can ignore the boolean response.
If the passed activity is terminated in back press (super.onBackPressed or activity.finish), in this case hyper.onBackPressed returns true, which will cause HyperSDK ui to be removed.
Activity Result for UPI Intent switches
If the merchant wants to use UPI Intent transactions (or any other transaction which requires us to switch to a third-party app) through Juspay SDK, we will need the merchant to delegate the control to the android lifecycle event onActivityResult() so that we can correctly process the result given by that corresponding android intent. To do that, the following code snippet can be used:
The above snippet can be ignored if the merchant is not overriding the onActivityResult method provided by android.
If super.onActivityResult is not accessible to the merchant, they can implement it using a similar method provided by HyperServices:
Merchants using ReactActivity must call the above code snippet, for the SDK to function as expected.
Launch Activity for React Native Merchants
ReactActivity does not forward onActivityResult to AppCompatActivity. This causes onActivityResult's requestCode to be modified, when returned to the SDK. To avoid this, we need to intercept the request before being sent to the AppCompatActivity and make the same via react context.
This can be achieved by implementing the ActivityLaunchDelegate. Sample implementation is below
Post this we will need to set the ActivityLaunchDelegate on the hyperServices instance.
Request Permission for React Native Merchants
In certain versions of React Native, onRequestPermissionResult crashes before forwarding the result to AppCompatActivity. This can be bypassed by overriding requestPermission
This can be achieved by implementing the RequestPermissionDelegate. Sample implementation is below
Post this we will need to set the ReactRequestDelegate on the hyperServices instance.
Handling Permission Results
Juspay SDK uses permissions in various flows (Example OTP Auto Read), we will need the merchant to delegate the control to the android lifecycle event onRequestPermissionsResult() so that we can correctly process the result given by that corresponding permission request. To do that, the following code snippet can be used:
The above snippet can be ignored if the merchant is not overriding the onRequestPermissionsResult method provided by android.
If super.onRequestPermissionsResult is not accessible to the merchant, they can implement it using a similar method provided by HyperServices:
Merchants using ReactActivity must call the above code snippet, for the SDK to function as expected.
iOS
Declare URL Schemes for UPI Apps
Add the following properties in the App’s Info.plist file to use canOpenURL to check available UPI Apps

