A production-ready demonstration of implementing in-app purchases in React Native using iaptic for receipt validation.
This demo implements a complete in-app purchase flow with server-side receipt validation:
✨ Secure: Server-side validation with iaptic
🔄 Reliable: Full purchase restoration support
🎮 Interactive: Token-based consumable system
📱 Production-Ready: Error handling and state management
- Node.js 16 or newer
- npm or yarn package manager
- React Native development environment
- iaptic account credentials
- iOS Developer Account with IAP enabled
- Android Developer Account with IAP enabled (for Android)
# Install dependencies
npm install
# OR using yarn
yarn install
# Configure iaptic credentials
cp src/Config-example.ts src/Config.ts- Configure your products in App Store Connect
- Run the app:
npm run ios
# OR using yarn
yarn ios-
Configure your products in Google Play Console
-
Make sure you have:
- A Google Play Developer account
- An app created in Google Play Console
- In-app products configured
- A test account added to the app's testers
-
Update your Android configuration:
- Verify your
android/app/build.gradlehas the billing permission:android { ... defaultConfig { ... manifestPlaceholders = [ ... BILLING_KEY: "your_license_key_from_play_console" ] } }
- Verify your
-
Run the app:
# Method 1: Using Gradle directly (recommended)
cd android
./gradlew clean
./gradlew installPlayDebug
cd ..
cd android && ./gradlew clean && ./gradlew installPlayDebug && cd ..
# Method 2: Using React Native CLI
cd android
./gradlew clean
cd ..
yarn android --appVariant=playDebug
# OR using npm
npm run android -- --appVariant=playDebugNote: The project uses multiple build variants. Always specify playDebug variant to ensure proper Google Play Store integration.
-
Build Variant Errors:
- If you see "Task 'app:installDebug' not found" or similar
- Use
installPlayDebuginstead ofinstallDebug - Or specify
--appVariant=playDebugwith React Native CLI
-
Package Manager Issues:
- If
yarncommand is not found, install it first:npm install -g yarn
- Or use npm commands as alternatives
- If
-
Runtime Errors:
- Verify billing permission in manifest (already added)
- Check Play Store is installed and up to date
- Ensure test account is properly set up
- Verify product IDs match exactly
-
Testing:
- Use a real device (not emulator)
- Sign in with a test account
- Make sure the app is signed with the correct key
- Verify you're using the correct product IDs
For detailed setup and troubleshooting, visit iaptic.com.
The demo is built with:
- react-native-iap - Store interactions
- iaptic - Receipt validation
- TypeScript - Type-safe implementation
src/
├── IapService.ts # Purchase and validation logic
├── Config.ts # iaptic configuration
└── TokenManager.ts # Consumable handling example
- Configure products in App Store Connect
- Use sandbox account for testing
- Configure products in Google Play Console
- Use a test account from your testers list
- Verify your app signing key matches Play Console
- Make sure billing permission is properly set
- Test with a real device (emulators may have issues)
-
Build Errors:
- Clean the project:
cd android && ./gradlew clean - Verify React Native version compatibility
- Check Android SDK version in
build.gradle
- Clean the project:
-
Runtime Errors:
- Verify billing permission in manifest
- Check Play Store is installed and up to date
- Ensure test account is properly set up
- Verify product IDs match exactly
-
Testing:
- Use a real device (not emulator)
- Sign in with a test account
- Make sure the app is signed with the correct key
- Verify you're using the correct product IDs
For detailed setup and troubleshooting, visit iaptic.com.