-
-
Notifications
You must be signed in to change notification settings - Fork 5
feat: add standardized DiscountOffer and SubscriptionOffer types #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
87a6591
feat: add standardized DiscountOffer and SubscriptionOffer types
hyochan 880d562
fix: address PR review feedback for discount offer types
hyochan fca22cb
fix: resolve remaining PR review issues
hyochan 78873fb
fix: address remaining coderabbit review issues
hyochan 965f239
fix: use absolute paths for environment variables
hyochan 544dfa5
docs: fix markdownlint issues in sync-expo-iap.md
hyochan edec124
docs: fix step numbering in sync-expo-iap and sync-flutter-iap
hyochan a65d595
docs: add openiap-versions.json sync step to all platform sync commands
hyochan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,296 @@ | ||
| # Sync Changes to expo-iap | ||
|
|
||
| Synchronize OpenIAP changes to the [expo-iap](https://github.com/hyochan/expo-iap) repository. | ||
|
|
||
| **Target Repository:** `$IAP_REPOS_HOME/expo-iap` | ||
|
|
||
| > **Note:** Set `IAP_REPOS_HOME` environment variable (see [sync-all-platforms.md](./sync-all-platforms.md#environment-setup)) | ||
|
|
||
| ## Project Overview | ||
|
|
||
| - **Package Manager:** Bun | ||
| - **Framework:** Expo Module (React Native) | ||
| - **Current Version:** Check `package.json` | ||
| - **OpenIAP Version Tracking:** `openiap-versions.json` | ||
|
|
||
| ## Key Files | ||
|
|
||
| | File | Purpose | Auto-Generated | | ||
| |------|---------|----------------| | ||
| | `src/types.ts` | TypeScript types from OpenIAP | YES | | ||
| | `src/index.ts` | Main API exports | NO | | ||
| | `src/useIAP.ts` | React Hook for IAP | NO | | ||
| | `src/modules/ios.ts` | iOS-specific functions | NO | | ||
| | `src/modules/android.ts` | Android-specific functions | NO | | ||
| | `openiap-versions.json` | Version tracking | NO | | ||
|
|
||
| ## Sync Steps | ||
|
|
||
| ### 0. Pull Latest (REQUIRED) | ||
|
|
||
| **Always pull the latest code before starting any sync work:** | ||
|
|
||
| ```bash | ||
| cd $IAP_REPOS_HOME/expo-iap | ||
| git pull | ||
| ``` | ||
|
|
||
| ### 1. Sync openiap-versions.json (REQUIRED) | ||
|
|
||
| **IMPORTANT:** Before generating types, sync version numbers from openiap monorepo. | ||
|
|
||
| ```bash | ||
| cd $IAP_REPOS_HOME/expo-iap | ||
|
|
||
| # Check current versions in openiap monorepo | ||
| cat $OPENIAP_HOME/openiap/openiap-versions.json | ||
|
|
||
| # Update expo-iap's openiap-versions.json to match: | ||
| # - "gql": should match openiap's "gql" version | ||
| # - "apple": should match openiap's "apple" version | ||
| # - "google": should match openiap's "google" version | ||
| ``` | ||
|
|
||
| **Version fields to sync:** | ||
| | Field | Source | Purpose | | ||
| |-------|--------|---------| | ||
| | `gql` | `$OPENIAP_HOME/openiap/openiap-versions.json` | TypeScript types version | | ||
| | `apple` | `$OPENIAP_HOME/openiap/openiap-versions.json` | iOS native SDK version | | ||
| | `google` | `$OPENIAP_HOME/openiap/openiap-versions.json` | Android native SDK version | | ||
|
|
||
| ### 2. Type Synchronization | ||
|
|
||
| ```bash | ||
| cd $IAP_REPOS_HOME/expo-iap | ||
|
|
||
| # Download and regenerate types (uses versions from openiap-versions.json) | ||
| bun run generate:types | ||
|
|
||
| # Verify types | ||
| bun run typecheck | ||
| ``` | ||
|
|
||
| ### 3. Native Code Modifications | ||
|
|
||
| #### iOS Native Code | ||
|
|
||
| **Location:** `ios/` | ||
|
|
||
| Key files to update: | ||
| - `ios/ExpoIapModule.swift` - Main Expo module implementation | ||
| - `ios/ExpoIap.podspec` - CocoaPods spec (update `apple` version dependency) | ||
|
|
||
| **When to modify:** | ||
| - New iOS-specific API methods added to OpenIAP | ||
| - Type conversion changes needed | ||
| - StoreKit 2 API changes | ||
|
|
||
| **Update workflow:** | ||
| ```bash | ||
| cd $IAP_REPOS_HOME/expo-iap | ||
|
|
||
| # 1. Update apple version in openiap-versions.json | ||
| # 2. Review openiap/packages/apple/Sources/ for changes | ||
| # 3. Update ios/ExpoIapModule.swift accordingly | ||
|
|
||
| # Install updated pod | ||
| cd example/ios && pod install --repo-update | ||
| ``` | ||
|
|
||
| #### Android Native Code | ||
|
|
||
| **Location:** `android/src/main/java/` | ||
|
|
||
| Key files to update: | ||
| - `ExpoIapModule.kt` - Main Expo module implementation | ||
| - `build.gradle` - Dependencies (auto-reads `google` version) | ||
|
|
||
| **When to modify:** | ||
| - New Android-specific API methods added to OpenIAP | ||
| - Type conversion changes needed | ||
| - Play Billing API changes | ||
|
|
||
| **Update workflow:** | ||
| ```bash | ||
| cd $IAP_REPOS_HOME/expo-iap | ||
|
|
||
| # 1. Update google version in openiap-versions.json | ||
| # 2. Review openiap/packages/google/openiap/src/main/ for changes | ||
| # 3. Update android/src/main/java/ accordingly | ||
|
|
||
| # Gradle auto-syncs on build | ||
| ``` | ||
|
|
||
| ### 4. Build & Test Native Code | ||
|
|
||
| #### iOS Build Test | ||
|
|
||
| ```bash | ||
| cd $IAP_REPOS_HOME/expo-iap/example | ||
|
|
||
| # Clean and prebuild | ||
| npx expo prebuild --clean --platform ios | ||
|
|
||
| # Install pods | ||
| cd ios && pod install --repo-update && cd .. | ||
|
|
||
| # Build for simulator | ||
| npx expo run:ios --device "iPhone 15 Pro" | ||
|
|
||
| # Or build via Xcode | ||
| open ios/expoiapexample.xcworkspace | ||
| # Build: Cmd+B, Run: Cmd+R | ||
| ``` | ||
|
|
||
| #### Android Build Test | ||
|
|
||
| ```bash | ||
| cd $IAP_REPOS_HOME/expo-iap/example | ||
|
|
||
| # Clean and prebuild | ||
| npx expo prebuild --clean --platform android | ||
|
|
||
| # Build debug APK | ||
| npx expo run:android | ||
|
|
||
| # Or build via Android Studio | ||
| # Open android/ folder in Android Studio | ||
| # Build > Make Project | ||
| ``` | ||
|
|
||
| #### Android Horizon Build (Meta Quest) | ||
|
|
||
| ```bash | ||
| cd $IAP_REPOS_HOME/expo-iap/example | ||
|
|
||
| # Enable Horizon flavor in gradle.properties | ||
| echo "horizonEnabled=true" >> android/gradle.properties | ||
|
|
||
| # Prebuild and build with Horizon | ||
| npx expo prebuild --clean --platform android | ||
| npx expo run:android | ||
|
|
||
| # Revert for Play Store builds | ||
| sed -i '' '/horizonEnabled=true/d' android/gradle.properties | ||
| ``` | ||
|
|
||
| #### Full Build Matrix | ||
|
|
||
| ```bash | ||
| cd $IAP_REPOS_HOME/expo-iap | ||
|
|
||
| # TypeScript build | ||
| bun run build | ||
|
|
||
| # iOS build | ||
| cd example && npx expo run:ios | ||
|
|
||
| # Android build (Play Store) | ||
| cd example && npx expo run:android | ||
|
|
||
| # Android build (Horizon) | ||
| cd example && echo "horizonEnabled=true" >> android/gradle.properties && npx expo run:android | ||
|
|
||
| # All tests | ||
| bun run test | ||
| cd example && bun run test | ||
| ``` | ||
|
|
||
| ### 5. Update Example Code | ||
|
|
||
| **Location:** `example/app/` | ||
|
|
||
| Key example screens: | ||
| - `index.tsx` - Home/Overview | ||
| - `purchase-flow.tsx` - Purchase flow demo | ||
| - `subscription-flow.tsx` - Subscription demo | ||
| - `alternative-billing.tsx` - Android alt billing | ||
| - `offer-code.tsx` - Promo code redemption | ||
|
|
||
| ### 6. Update Tests | ||
|
|
||
| **Library Tests:** `src/__tests__/` | ||
| **Example Tests:** `example/__tests__/` | ||
|
|
||
| ```bash | ||
| # Run all tests | ||
| bun run test | ||
|
|
||
| # Run example tests | ||
| cd example && bun run test | ||
| ``` | ||
|
|
||
| ### 7. Update Documentation | ||
|
|
||
| **Location:** `docs/` | ||
| - `docs/api/` - API reference | ||
| - `docs/guides/` - Usage guides | ||
| - `docs/examples/` - Code examples | ||
|
|
||
| ### 8. Update llms.txt Files | ||
|
|
||
| **Location:** `docs/static/` | ||
|
|
||
| Update AI-friendly documentation files when APIs or types change: | ||
|
|
||
| - `docs/static/llms.txt` - Quick reference for AI assistants | ||
| - `docs/static/llms-full.txt` - Detailed AI reference | ||
|
|
||
| **When to update:** | ||
| - New API functions added | ||
| - Function signatures changed | ||
| - New types or enums added | ||
| - Usage patterns updated | ||
| - Error codes changed | ||
|
|
||
| **Content to sync:** | ||
| 1. Installation commands | ||
| 2. Core API reference (useIAP hook, direct functions) | ||
| 3. Key types (Product, Purchase, ErrorCode) | ||
| 4. Common usage patterns | ||
| 5. Platform-specific APIs (iOS/Android suffixes) | ||
| 6. Error handling examples | ||
|
|
||
| ### 9. Pre-commit Checklist | ||
|
|
||
| ```bash | ||
| bun run lint # ESLint | ||
| bun run typecheck # TypeScript | ||
| bun run test # Jest | ||
| cd example && bun run test # Example app tests | ||
| ``` | ||
|
|
||
| ## Naming Conventions | ||
|
|
||
| - **iOS-only:** `functionNameIOS` (e.g., `syncIOS`, `getPromotedProductIOS`) | ||
| - **Android-only:** `functionNameAndroid` (e.g., `validateReceiptAndroid`) | ||
| - **Cross-platform:** No suffix (e.g., `fetchProducts`, `requestPurchase`) | ||
| - **Error codes:** kebab-case (e.g., `'user-cancelled'`) | ||
|
|
||
| ## Deprecation Check | ||
|
|
||
| Search for deprecated patterns: | ||
| ```bash | ||
| cd $IAP_REPOS_HOME/expo-iap | ||
| grep -r "@deprecated" src/ | ||
| grep -r "DEPRECATED" src/ | ||
| ``` | ||
|
|
||
| Known deprecated functions: | ||
| - `requestProducts` -> Use `fetchProducts` | ||
| - `validateReceipt` -> Use `verifyPurchase` | ||
| - `validateReceiptIOS` -> Use `verifyPurchase` | ||
|
|
||
| ## Commit Message Format | ||
|
|
||
| ```text | ||
| feat: add discount offer support | ||
| fix: resolve iOS purchase verification | ||
| docs: update subscription flow guide | ||
| ``` | ||
|
|
||
| ## References | ||
|
|
||
| - **CLAUDE.md:** `$IAP_REPOS_HOME/expo-iap/CLAUDE.md` | ||
| - **OpenIAP Docs:** [openiap.dev/docs](https://openiap.dev/docs) | ||
| - **expo-iap Docs:** [expo-iap.vercel.app](https://expo-iap.vercel.app) | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.