|
| 1 | +# API Naming Conventions |
| 2 | + |
| 3 | +## Platform Suffix Rules |
| 4 | + |
| 5 | +### iOS-Specific Functions (IOS suffix) |
| 6 | + |
| 7 | +Functions only available on iOS/macOS must end with `IOS`: |
| 8 | + |
| 9 | +```text |
| 10 | +clearTransactionIOS |
| 11 | +getStorefrontIOS |
| 12 | +getPromotedProductIOS |
| 13 | +getPendingTransactionsIOS |
| 14 | +isEligibleForIntroOfferIOS |
| 15 | +subscriptionStatusIOS |
| 16 | +currentEntitlementIOS |
| 17 | +latestTransactionIOS |
| 18 | +showManageSubscriptionsIOS |
| 19 | +beginRefundRequestIOS |
| 20 | +isTransactionVerifiedIOS |
| 21 | +getTransactionJwsIOS |
| 22 | +getReceiptDataIOS |
| 23 | +syncIOS |
| 24 | +presentCodeRedemptionSheetIOS |
| 25 | +getAppTransactionIOS |
| 26 | +``` |
| 27 | + |
| 28 | +### Android-Specific Functions (Android suffix) |
| 29 | + |
| 30 | +Functions only available on Android must end with `Android`: |
| 31 | + |
| 32 | +```text |
| 33 | +acknowledgePurchaseAndroid |
| 34 | +consumePurchaseAndroid |
| 35 | +getPackageNameAndroid |
| 36 | +``` |
| 37 | + |
| 38 | +### Cross-Platform Functions (No suffix) |
| 39 | + |
| 40 | +Functions available on both platforms have no suffix: |
| 41 | + |
| 42 | +```text |
| 43 | +initConnection |
| 44 | +endConnection |
| 45 | +fetchProducts |
| 46 | +requestPurchase |
| 47 | +getAvailablePurchases |
| 48 | +finishTransaction |
| 49 | +verifyPurchase |
| 50 | +getActiveSubscriptions |
| 51 | +hasActiveSubscriptions |
| 52 | +deepLinkToSubscriptions |
| 53 | +getStorefront |
| 54 | +restorePurchases |
| 55 | +``` |
| 56 | + |
| 57 | +## Action Prefix Rules |
| 58 | + |
| 59 | +| Prefix | Usage | Example | |
| 60 | +| -------------- | -------------------- | ---------------------------- | |
| 61 | +| `get` | Retrieve data | `getPromotedProductIOS` | |
| 62 | +| `fetch` | Async data retrieval | `fetchProducts` | |
| 63 | +| `request` | Initiate action | `requestPurchase` | |
| 64 | +| `clear` | Remove/reset | `clearTransactionIOS` | |
| 65 | +| `is/has` | Boolean checks | `isEligibleForIntroOfferIOS` | |
| 66 | +| `show/present` | Display UI | `showManageSubscriptionsIOS` | |
| 67 | +| `begin` | Start process | `beginRefundRequestIOS` | |
| 68 | +| `finish/end` | Complete process | `finishTransaction` | |
| 69 | + |
| 70 | +## URL Anchor Format |
| 71 | + |
| 72 | +Use kebab-case for URL anchors: |
| 73 | + |
| 74 | +- `fetchProducts` → `#fetch-products` |
| 75 | +- `getAppTransactionIOS` → `#get-app-transaction-ios` |
| 76 | +- `verifyPurchase` → `#verify-purchase` |
| 77 | + |
| 78 | +## Package-Specific Rules |
| 79 | + |
| 80 | +### In `packages/google` (Android-only package) |
| 81 | + |
| 82 | +**DO NOT** add `Android` suffix to internal functions: |
| 83 | + |
| 84 | +```kotlin |
| 85 | +// Correct - inside Android package |
| 86 | +fun acknowledgePurchase() |
| 87 | +fun consumePurchase() |
| 88 | + |
| 89 | +// Wrong - don't add Android suffix |
| 90 | +fun acknowledgePurchaseAndroid() |
| 91 | +``` |
| 92 | + |
| 93 | +### In `packages/apple` (iOS-only package) |
| 94 | + |
| 95 | +iOS-specific functions still need `IOS` suffix for cross-platform API consistency: |
| 96 | + |
| 97 | +```swift |
| 98 | +// Correct |
| 99 | +func presentCodeRedemptionSheetIOS() |
| 100 | +func syncIOS() |
| 101 | + |
| 102 | +// Cross-platform (no suffix) |
| 103 | +func verifyPurchase() |
| 104 | +``` |
0 commit comments