Feature(SDK-137): Add isSamsungPayAvailable API to check Samsung Pay readiness - #45
Merged
Merged
Conversation
sultan-algarbi
requested review from
AbdulazizAlrabiah
and
a lite review from Copilot
August 16, 2026 15:01
There was a problem hiding this comment.
Pull request overview
This PR adds a new public JS API to let host apps check whether Samsung Pay is available and ready on Android devices, backed by a dedicated native module implemented for both the old and new React Native architectures.
Changes:
- Added a new TurboModule spec (
RTNSamsungPay) and JS helperisSamsungPayAvailable(serviceId)that resolves a boolean and never rejects. - Implemented the Android native availability check (Samsung Pay status →
trueonly forSPAY_READY) and wired it up for both architectures + package registration. - Added unit tests for the helper and exported the helper from the package entry point.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/specs/NativeRTNSamsungPay.ts | Defines the TurboModule JS↔native contract and module lookup. |
| src/helpers/samsung_pay_availability.ts | Public helper with platform/serviceId guards and safe boolean-only behavior. |
| src/index.tsx | Exposes the new helper from the package entry point. |
| src/tests/helpers/samsung_pay_availability.test.ts | Adds Jest tests for the helper’s platform/blank-id/native-error behavior. |
| android/src/main/java/com/moyasarsdk/RTNSamsungPayModuleImpl.kt | Implements Samsung Pay readiness check and resolves boolean result. |
| android/src/newarch/java/com/RTNSamsungPay.java | New-architecture wrapper module bridging to the shared implementation. |
| android/src/oldarch/java/com/RTNSamsungPay.java | Old-architecture wrapper module bridging to the shared implementation. |
| android/src/main/java/com/moyasarsdk/RTNMoyasarPackage.java | Registers the new module for lookup and TurboModule info provider. |
Suppressed comments (1)
src/tests/helpers/samsung_pay_availability.test.ts:44
- Same issue here: avoid assigning to
Platform.OSdirectly; redefine it so the test compiles and works reliably.
it('returns false on non-Android platforms without calling native', async () => {
Platform.OS = 'ios';
await expect(isSamsungPayAvailable(serviceId)).resolves.toBe(false);
expect(nativeModule.isSamsungPayAvailable).not.toHaveBeenCalled();
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+16
to
+21
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| Platform.OS = 'android'; | ||
| // The helper logs via `console.error` in dev; keep test output clean. | ||
| jest.spyOn(console, 'error').mockImplementation(() => {}); | ||
| }); |
Comment on lines
+39
to
+43
| try { | ||
| if (!NativeRTNSamsungPay) { | ||
| errorLog('Moyasar SDK: Samsung Pay native module is not available'); | ||
| return false; | ||
| } |
AbdulazizAlrabiah
approved these changes
Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Exposes a new public helper,
isSamsungPayAvailable(serviceId), so apps building their own payment UI can check whether Samsung Pay is available and ready (set up and active) on the device before showing a Samsung Pay option or rendering the built-in button. Previously the nativegetSamsungPayStatusresult was only used internally to toggle the button's visibility and was never surfaced to JS. The helper is backed by a newRTNSamsungPayTurboModule that mirrors the existingRTNDeviceLanguagemodule pattern and works on both the old and new RN architectures. It resolvestrueonly when Samsung Pay isSPAY_READY, andfalsein every other case (non-Android, not supported, not set up, or any failure) — it never rejects, so callers always get a simple boolean.Ticket #:
https://moyasar-team.atlassian.net/browse/SDK-137
How to test
await isSamsungPayAvailable('<your Samsung service ID>')→ resolvestrue.false.false.falseimmediately (short-circuits without touching native).false(logs a clear error, skips the native call).NativeRTNSamsungPaySpec, and old arch registers the module manually).Deployment Notes
N/A — additive public API, no config, migrations, or breaking changes. iOS returns
falsesince Samsung Pay is Android-only (tracked as a follow-up in SDK-137).Suggested Plan for Review:
src/specs/NativeRTNSamsungPay.ts— TurboModule spec (the JS↔native contract); start here to see theisSamsungPayAvailable(serviceId): Promise<boolean>signature.src/helpers/samsung_pay_availability.ts— public helper: Platform guard, blank-serviceId guard, null-module guard, and the native call wrapped so it never rejects.src/index.tsx— exportsisSamsungPayAvailablefrom the package entry point.android/src/main/java/com/moyasarsdk/RTNSamsungPayModuleImpl.kt— the actual availability logic: buildsPartnerInfo, callsgetSamsungPayStatus, one-shot promise resolution, keeps theSamsungPayinstance alive for the async callback.android/src/newarch/java/com/RTNSamsungPay.java— new-arch wrapper extending the codegenNativeRTNSamsungPaySpec.android/src/oldarch/java/com/RTNSamsungPay.java— old-arch wrapper (ReactContextBaseJavaModule+@ReactMethod).android/src/main/java/com/moyasarsdk/RTNMoyasarPackage.java— registers the module ingetModuleandgetReactModuleInfoProvider.src/__tests__/helpers/samsung_pay_availability.test.ts— unit tests: ready/not-ready, non-Android, blank serviceId, and native rejection.🤖 Generated with Claude Code