You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds a HyperServiceInstance class that creates independent, keyed
HyperServices objects alongside the existing module-wide singleton API,
each with its own event channel. This PR covers the core integration:
create, initiate, process, terminate, back-press and status helpers.
Merchant views, HyperFragmentView and processWithActivity/openPaymentPage
per instance follow in a separate PR.
JS:
- HyperServiceInstance: constructor(tenantId?, clientId?), initiate,
process, terminate, onBackPressed, isNull, isInitialised and
getHyperEventString() as the instance's event channel
- lazy linking error; platform guards for iOS-only gaps
Android:
- keyed create/initiate/process/terminate/back-press/isInitialised with
per-key event emission
- permission and activity results forwarded to every live instance
- invalidate() terminates and clears keyed state on React reloads
- every skipped call logged to logcat alongside SdkTracker telemetry
- legacy single-instance API behaviour preserved exactly
- resolve ReactHost reflectively so the module compiles on RN < 0.74
- fix rnVersion Groovy scoping crash for newArchEnabled=false consumers
iOS:
- keyed methods mirrored with per-key delegate retention, dynamic
supportedEvents, synchronized dict access, and invalidate cleanup
- podspec: RN version detection for development layouts; folly compiler
flags applied
Example app:
- toolchain modernized: React Native 0.79.7 (react 19), AGP 8.9 via RNGP,
Gradle 8.13, compileSdk 36, Kotlin 2.0.21, RN 0.79 Podfile, Flipper
removed; Jetifier re-enabled for the Juspay micro-SDKs with RN AARs on
the ignorelist
- demo flows for multiple instances: create/select instances, initiate,
process and terminate per instance with per-instance event listeners
- generateSign accepts PKCS#8/PKCS#1 keys with or without PEM armor on
both platforms, with errors surfaced in the UI
Docs:
- README section covering merchant integration for multiple instances
Co-authored-by: Anurag Singh <as6003688@gmail.com>
Co-authored-by: yuvrajjsingh0 <yuvraj.singh@juspay.in>
export default HyperSdkReact as HyperSdkReactType;
111
111
```
112
112
113
+
For apps that need more than one tenant / client in the same session, the module also exports a
114
+
`HyperServiceInstance` class. See [Multiple HyperServices Instances](#multiple-hyperservices-instances).
115
+
116
+
```ts
117
+
import HyperSdkReact, { HyperServiceInstance } from 'hyper-sdk-react';
118
+
```
119
+
113
120
### Import HyperSDK
114
121
115
122
```ts
@@ -134,6 +141,9 @@ This method creates an instance of `HyperServices` class in the React Bridge Mod
134
141
HyperSdkReact.createHyperServices();
135
142
```
136
143
144
+
This creates a single, module-wide instance. If you need several independent instances (multiple
145
+
tenants / clients), use [`HyperServiceInstance`](#multiple-hyperservices-instances) instead.
146
+
137
147
### Step-2: Initiate
138
148
139
149
This method should be called on the render of the host screen. This will boot up the SDK and start the Hyper engine. It takes a `stringified JSON` as its argument which will contain the base parameters for the entire session and remains static throughout one SDK instance lifetime.
@@ -340,7 +350,7 @@ If your view dynamically computes height. Height can be obtained by adding the f
340
350
useLayoutEffect(() => {
341
351
if (ref.current?.measure) {
342
352
ref.current.measure((x, y, width, height, pageX, pageY) => {
The constructor allocates the native object immediately and generates the instance key.
404
+
405
+
```ts
406
+
// Default tenant / client
407
+
const instance = new HyperServiceInstance();
408
+
409
+
// Explicit tenant and client
410
+
const tenantInstance = new HyperServiceInstance(tenantId, clientId);
411
+
```
412
+
413
+
On Android the native object can only be created while an activity is in the foreground, and creation
414
+
happens asynchronously on the native side — so a synchronous `isNull()` right after the constructor
415
+
will still report `true`. If you want to confirm creation succeeded, check `isNull()` on a later tick
416
+
(for example just before calling `initiate`). Hold on to the object for the whole
417
+
lifetime of the flow — an instance can only be addressed through the reference you keep in JS. A common pattern is a `Map` keyed by `getHyperEventString()`:
418
+
419
+
```ts
420
+
const instances = new Map<string, HyperServiceInstance>();
421
+
const instance = new HyperServiceInstance(tenantId, clientId);
and **`HyperFragmentView`** are not instance-aware yet; they operate on the single-instance
536
+
(module-level) API. Use `HyperSdkReact.*` for flows that need them.
537
+
-**Permission and activity results** are offered to every live instance and routed internally by
538
+
request code. If two instances trigger flows that wait on the same Android request code at the same
539
+
moment, results cannot be disambiguated — avoid two simultaneous permission-driven flows.
540
+
- The single-instance `HyperSdkReact.*` API and `HyperServiceInstance` can coexist in one app.
541
+
372
542
## Payload Structure
373
543
374
544
Please refer [here for Express Checkout SDK](https://developer.juspay.in/v2.0/docs/payload) and [here for Payment Page SDK](https://developer.juspay.in/v4.0/docs/payload), for all request and response payload structure.
0 commit comments