Skip to content

feat: support multiple HyperServices instances - #193

Merged
Yaswanth0606 merged 1 commit into
mainfrom
multi-instance-core
Aug 25, 2026
Merged

feat: support multiple HyperServices instances#193
Yaswanth0606 merged 1 commit into
mainfrom
multi-instance-core

Conversation

@Yaswanth0606

Copy link
Copy Markdown
Contributor

Summary

Adds a HyperServiceInstance class so an app can run multiple independent HyperServices instances (e.g. several tenants/clients in one session) alongside the existing module-wide singleton API, which is preserved exactly.

import HyperSdkReact, { HyperServiceInstance } from 'hyper-sdk-react';

const instance = new HyperServiceInstance(tenantId, clientId);
eventEmitter.addListener(instance.getHyperEventString(), handler); // per-instance event channel
instance.initiate(payload);
instance.process(payload);
instance.terminate();

What's included

  • JS: HyperServiceInstance (create / initiate / process / processWithActivity / openPaymentPage / terminate / onBackPressed / isNull / isInitialised / per-instance merchant views / getHyperEventString), HyperFragmentView instance prop, lazy linking error, platform guards
  • Android: keyed native methods with per-key event emission, per-key ProcessActivity callbacks and back-press routing, per-instance merchant views with process-wide fallback, permission/activity-result fan-out to all live instances, invalidate() cleanup on reloads, logcat logging for every skipped call, thread-safe keyed maps
  • iOS: mirrored keyed methods, per-key SdkDelegate lifecycle, dynamic supportedEvents, synchronized dict access, invalidate cleanup
  • Build fixes: ext.rnVersion Groovy scoping crash (broke newArchEnabled=false consumers), reflective ReactHost (compiles on RN < 0.74), podspec RN-version detection + folly compiler flags
  • Docs: full merchant integration guide in the README ("Multiple HyperServices Instances"), including limitations

Verification

  • Legacy single-instance behaviour byte-compatible with main (traced API-by-API)
  • Multi-agent adversarial review across three rounds; all confirmed findings fixed
  • Verified live on an Android emulator and iOS simulator: create → keyed initiate (real SDK boot, session_metadata on the instance channel) → process → payment page rendered → terminate, zero crashes
  • javac (full module), clang, tsc, eslint, jest all green

Follow-up PR (stacked): example app modernization + multi-instance demo flows.

🤖 Generated with Claude Code

@Yaswanth0606
Yaswanth0606 force-pushed the multi-instance-core branch 3 times, most recently from 2d1e0ac to d239282 Compare August 25, 2026 09:58
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>
@Yaswanth0606
Yaswanth0606 merged commit 4dc687f into main Aug 25, 2026
8 checks passed
@Yaswanth0606
Yaswanth0606 deleted the multi-instance-core branch August 25, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants