Skip to content

chore: React-Native new architecture support along with old architecture#520

Open
vivekshindhe wants to merge 2 commits intomasterfrom
chore/new-architecture-v2
Open

chore: React-Native new architecture support along with old architecture#520
vivekshindhe wants to merge 2 commits intomasterfrom
chore/new-architecture-v2

Conversation

@vivekshindhe
Copy link
Contributor

@vivekshindhe vivekshindhe commented Mar 12, 2026

Summary

This PR improves the react-native-razorpay package's compatibility across different React Native versions and architectures, and adds infrastructure for automated testing.

Changes

🔧 Core Package Improvements

  • Remove Folly version hardcoding (react-native-razorpay.podspec)

    • Previously locked to 2021.07.22.00, causing conflicts with different RN versions
    • Now lets React Native specify the correct Folly version via transitive dependencies
    • Ensures compatibility with RN 0.68, 0.72, 0.83, and beyond
  • Add iOS codegen configuration (package.json)

    • Added ios.outputDir to codegenConfig for proper TurboModule code generation
    • Fixes new architecture builds when package is used as a file dependency

📱 Sample App Updates

OldArchSample (Replaced)

  • Replaced RN 0.66.5 with RN 0.68.0 example app
  • Addresses compatibility issues with modern Xcode (26.x) and Java (17+)
  • RN 0.68 provides:
    • Old architecture by default (validates legacy bridge)
    • Better tooling compatibility
    • Optional new architecture support

Expo54Sample

  • Enabled new architecture (RCT_NEW_ARCH_ENABLED=1 for iOS, newArchEnabled=true for Android)
  • Added Razorpay payment button with testID="razorpay-pay-button"
  • Implements full payment flow in the home tab

🧪 Testing Coverage

With these changes, the package is validated across:

Sample App RN Version Architecture Status
OldArchSample 0.68.0 Old (Legacy Bridge) ✅ Tested
NewArchSample 0.83.1 New (TurboModules) ✅ Tested
Expo54Sample 0.81.5 + Expo New (TurboModules) ✅ Tested

🔍 Other Changes

  • Updated .gitignore for E2E test artifacts
  • Added Android gradle.properties configuration
  • Minor Gradle version updates

Validation

All three sample apps have been manually tested:

  • ✅ Apps build successfully on iOS and Android
  • ✅ Payment checkout opens correctly
  • ✅ Payment callbacks (success/error) work
  • ✅ No crashes or architecture detection issues

Backward Compatibility

Fully backward compatible

  • Existing apps using the package will continue to work
  • No breaking changes to the public API
  • Architecture detection remains automatic

Related Issues

Resolves compatibility issues with:

  • Modern Xcode versions (26.x)
  • Modern Java versions (17+)
  • Various React Native versions (0.68 - 0.83+)

   Implements dual architecture pattern supporting both legacy bridge and new TurboModule/Fabric
   architecture with zero configuration required. Restructures sample apps to demonstrate all
   supported configurations.

   Architecture changes:
   - Android: Split source sets (newarch/oldarch) with shared RazorpayModuleImpl
   - iOS: Updated to .mm files with conditional TurboModule protocol conformance
   - JS: Auto-detection of architecture at runtime with graceful fallback
   - Added TypeScript TurboModule specs and type definitions

   Sample apps reorganization:
   - Removed legacy example/SampleApp
   - Added sampleApps/NewArchSample: React Native 0.76 with new architecture
   - Added sampleApps/OldArch: React Native 0.68 with legacy bridge
   - Added sampleApps/Expo54Sample: Expo 54 integration example
- Remove hardcoded Folly version from podspec for broader RN version compatibility
  - Add iOS codegen output configuration to package.json
  - Replace OldArch sample (RN 0.66.5) with RN 0.68.0 example for better tooling compatibility
  - Update Expo54Sample with new architecture enabled (RCT_NEW_ARCH_ENABLED=1)
  - Add testID props to payment buttons in sample apps for E2E testing
  - Add Razorpay payment integration to Expo54Sample
  - Update NewArchSample with production test key
  - Update .gitignore for E2E test artifacts
  - Add gradle.properties for Android configuration

  Breaking changes: None - backward compatible with existing integrations

  Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@vivekshindhe vivekshindhe added the TestingNotRequired TestingNotRequired label for BVT label Mar 12, 2026
resolved "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz"
integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==

fast-xml-parser@^4.4.1:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High severity vulnerability may affect your project—review required:
Line 3290 lists a dependency (fast-xml-parser) with a known High severity vulnerability.

ℹ️ Why this matters

Affected versions of fast-xml-parser are vulnerable to Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion'). fast-xml-parser can be denial-of-service'd via uncontrolled XML entity expansion: a crafted XML document with a DOCTYPE that defines a large plain-text entity and references it many times causes OrderedObjParser.replaceEntitiesValue() to repeatedly expand the entity without any limit on output size or replacement work, blocking the Node.js event loop and freezing the application while parsing untrusted XML (mitigate by disabling entity/DOCTYPE processing, e.g., processEntities: false).

References: GHSA, CVE

To resolve this comment:
Check if you are using fxparser on the CLI.

  • If you're affected, upgrade this dependency to at least version 4.5.4 at sampleApps/NewArchSample/yarn.lock.
  • If you're not affected, comment /fp we don't use this [condition]
💬 Ignore this finding

To ignore this, reply with:

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

You can view more details on this finding in the Semgrep AppSec Platform here.

resolved "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz"
integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==

fast-xml-parser@^4.4.1:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical severity vulnerability may affect your project—review required:
Line 3290 lists a dependency (fast-xml-parser) with a known Critical severity vulnerability.

ℹ️ Why this matters

Affected versions of fast-xml-parser are vulnerable to Incorrect Regular Expression. fast-xml-parser is vulnerable to an entity-encoding bypass when parsing untrusted XML with DOCTYPE entities enabled (the default processEntities: true): attacker-controlled DOCTYPE entity names are interpolated into RegExp() without escaping . (dot), so a name like l. becomes a wildcard regex that shadows built-in entities such as &lt;, &gt;, &amp;, &quot;, and &apos;, allowing arbitrary replacement text and leading to XSS (or other injection) when the parsed output is later rendered or used in an injection-sensitive context.

References: GHSA, CVE

To resolve this comment:
Check if you are using fxparser on the CLI.

  • If you're affected, upgrade this dependency to at least version 4.5.4 at sampleApps/NewArchSample/yarn.lock.
  • If you're not affected, comment /fp we don't use this [condition]
💬 Ignore this finding

To ignore this, reply with:

  • /fp <comment> for false positive
  • /ar <comment> for acceptable risk
  • /other <comment> for all other reasons

You can view more details on this finding in the Semgrep AppSec Platform here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/fp we don't use this. This is a sample app, and it must have been added by a third party dependency. Not related to our react-native package.

* Sends an event to JavaScript layer via DeviceEventEmitter.
* This works in both old and new architecture.
*/
private void sendEvent(String eventName, WritableMap params) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uses legacy getJSModule(RCTDeviceEventEmitter). Please confirm that in new-arch builds events still reach JS if not, we may need a different API for new arch

let RazorpayCheckoutModule;
let RazorpayEventEmitterModule;

if (isTurboModuleEnabled) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good runtime check and fallback. Please confirm both old and new arch paths are tested so we don’t regress either.

"url": "git+https://github.com/razorpay/react-native-razorpay.git"
},
"codegenConfig": {
"name": "RNRazorpayCheckoutSpec",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spec name inconsistency , Config says: RNRazorpayCheckoutSpec
Android codegen expects: NativeRazorpayCheckoutSpec please verify

Copy link

@arunsinghrazor arunsinghrazor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check this comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

TestingNotRequired TestingNotRequired label for BVT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants