This app exercises @sfpy/react-native, including the native card capture field. It is an Expo development build app (Expo Go will not work).
- Node + npm
- Xcode + CocoaPods (iOS)
- Android SDK + an emulator
- Sibling repos expected by native modules:
../safepay-ios-sdk-getsafepay(used byios/Podfile)../safepay-android-sdk-getsafepay(used byandroid/settings.gradle)
If your folder names differ, update:
ios/Podfilefor the iOS SDK pathandroid/settings.gradlefor the Android SDK path
npm installConvenience scripts:
npm run ios
npm run androidBoth start Metro in dev-client mode. npm run ios also opens the simulator. npm run android does not auto-open an emulator because Expo CLI's Android device resolution is brittle when stale offline emulators are present.
-
Install pods:
cd ios pod install -
Build the dev client:
cd .. npx expo run:ios -
Start Metro and open the app:
npm run ios
The example uses the Android SDK's safePayCard module, which doesn't depend on the Cardinal Mobile SDK, so no Cardinal credentials are needed.
Build and install:
npx expo run:androidOr, if you already built once and just need to reinstall:
cd android
./gradlew installDebugThen start Metro:
cd ..
npm run androidThen launch the installed app on the emulator.
The app is a single checkout form:
- Session: paste a time-based token (TBT) and a payment tracker created on your server, and pick the environment they were created in. Nothing is hard-coded; the app doesn't create trackers itself.
- Billing address: prefilled with a sample address; edit as needed.
- Card: enter a test card into the native card field and tap Pay. Card details are handled in native code; the app only sees the brand, last four digits and validation state.
- 3-D Secure runs in a modal, and the outcome appears under Result.
See the @sfpy/react-native README for the integration this demonstrates.
- Black screen / “Unable to load script”: Metro is not running or the app can’t reach it. Start Metro with
npx expo start --dev-clientand relaunch the app. - Android install hangs: Restart adb and the emulator, then re-run
./gradlew installDebug. - Pay fails with an authorization error: the environment doesn't match the one the tracker and TBT were created in, or the TBT has expired. Create a fresh tracker and TBT.
- Expo Go /
bubblingEventTypes of null: this app uses custom native views. Use the dev client only; Expo Go will not work.