-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathllms.txt
More file actions
228 lines (186 loc) · 5.81 KB
/
llms.txt
File metadata and controls
228 lines (186 loc) · 5.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# OpenIAP Quick Reference
> OpenIAP: Unified in-app purchase specification for iOS & Android
> Documentation: https://openiap.dev
> Full Reference: https://openiap.dev/llms-full.txt
> Generated: 2026-05-08T10:48:46.778Z
## Installation
### React Native / Expo
```bash
# expo-iap (Expo projects)
npx expo install expo-iap
# react-native-iap (React Native CLI)
npm install react-native-iap
```
### Native
```swift
// Swift Package Manager
.package(url: "https://github.com/hyodotdev/openiap.git", from: "1.0.0")
```
```kotlin
// Gradle
implementation("io.github.hyochan.openiap:openiap-google:1.0.0")
```
```yaml
# Flutter
dependencies:
flutter_inapp_purchase: ^5.0.0
```
```gdscript
# Godot
# Install godot-iap to addons/godot-iap and enable the plugin
```
```kotlin
// Kotlin Multiplatform
implementation("io.github.hyochan.kmpiap:library:1.3.8")
```
```xml
<!-- .NET MAUI -->
<PackageReference Include="OpenIap.Maui" Version="1.0.1" />
```
## Framework Libraries
- `expo-iap`: Expo Modules wrapper, same OpenIAP API as React Native.
- `react-native-iap`: Nitro Modules wrapper for React Native CLI apps.
- `flutter_inapp_purchase`: Dart API with generated OpenIAP types and streams.
- `godot-iap`: Godot 4.x plugin with GDScript functions and signals.
- `kmp-iap`: Kotlin Multiplatform API with Flow-based purchase events.
- `maui-iap`: `OpenIap.Maui` package with `Iap.Instance`,
generated `Types.cs`, IAPKit helpers (`Iap.KitApi`,
`Iap.ConnectWebhookStream`, `Iap.ParseWebhookEventData`), flattened iOS
xcframework / Android AAR bindings in one NuGet package, and MAUI example
flows matching `expo-iap`.
## Core APIs
### Connection
```typescript
// Initialize (required before any operation)
await initConnection();
// With alternative billing (Android)
await initConnection({ alternativeBillingModeAndroid: 'user-choice' });
// Cleanup on unmount
await endConnection();
```
### Fetch Products
```typescript
const products = await fetchProducts({
products: [
{ id: 'com.app.premium', type: 'inapp' },
{ id: 'com.app.monthly', type: 'subs' },
],
});
```
### Request Purchase
```typescript
// IMPORTANT: requestPurchase is event-based, not promise-based
// Set up purchaseUpdatedListener before calling
await requestPurchase({
request: {
apple: { sku: 'com.app.premium' },
google: { skus: ['com.app.premium'] },
},
type: 'inapp', // 'inapp' | 'subs'
});
```
### Finish Transaction
```typescript
// CRITICAL: Must call after verification
// Android: purchases auto-refund after 3 days if not acknowledged
await finishTransaction(purchase, isConsumable);
```
### Get Available Purchases
```typescript
const purchases = await getAvailablePurchases();
// Returns user's current entitlements
```
### Restore Purchases
```typescript
await restorePurchases();
const purchases = await getAvailablePurchases();
```
## Events (React Native/Expo)
```typescript
import { purchaseUpdatedListener, purchaseErrorListener } from 'expo-iap';
// Set up before any purchase request
const purchaseUpdateSubscription = purchaseUpdatedListener(async (purchase) => {
// 1. Verify purchase on server
// 2. Grant entitlement
// 3. Finish transaction
await finishTransaction(purchase);
});
const purchaseErrorSubscription = purchaseErrorListener((error) => {
if (error.code === 'UserCancelled') return; // Normal flow
console.error('Purchase error:', error.message);
});
// Cleanup
purchaseUpdateSubscription.remove();
purchaseErrorSubscription.remove();
```
## Core Types
### Product
```typescript
interface Product {
id: string; // Product identifier (SKU)
title: string; // Display name
description: string; // Product description
price: string; // Formatted price string
priceAmount: number; // Price as number
currency: string; // ISO 4217 currency code
type: 'inapp' | 'subs';
}
```
### Purchase
```typescript
interface Purchase {
productId: string; // Purchased product ID
transactionId: string; // Platform transaction ID
transactionDate: number; // Purchase timestamp
purchaseState: PurchaseState;
// iOS specific
originalTransactionId?: string;
// Android specific
purchaseToken?: string;
orderId?: string;
}
type PurchaseState = 'purchased' | 'pending' | 'restored';
```
### PurchaseError
```typescript
interface PurchaseError {
code: string; // Error code
message: string; // Human-readable message
productId?: string; // Related SKU
}
```
## Common Error Codes
| Code | Description | Action |
|------|-------------|--------|
| UserCancelled | User cancelled purchase | No action needed |
| ItemUnavailable | Product not in store | Check store config |
| AlreadyOwned | Already purchased | Restore purchases |
| NetworkError | Network issue | Retry with backoff |
| ServiceError | Store service error | Retry later |
| NotPrepared | initConnection not called | Call initConnection first |
## API Naming Convention
- **Cross-platform**: No suffix (fetchProducts, requestPurchase)
- **iOS-only**: `IOS` suffix (syncIOS, getStorefrontIOS)
- **Android-only**: `Android` suffix (acknowledgePurchaseAndroid)
## Platform-Specific APIs
### iOS
- syncIOS() - Sync with App Store
- presentCodeRedemptionSheetIOS() - Show offer code UI
- showManageSubscriptionsIOS() - Open subscription management
- beginRefundRequestIOS() - Start refund flow
### Android
- acknowledgePurchaseAndroid() - Acknowledge purchase
- consumePurchaseAndroid() - Consume for re-purchase
## Purchase Flow Summary
1. initConnection()
2. fetchProducts([...skus])
3. Set up purchaseUpdatedListener
4. requestPurchase({ sku })
5. In listener: verify -> grant -> finishTransaction()
6. endConnection() on cleanup
## Links
- Docs: https://openiap.dev/docs
- Types: https://openiap.dev/docs/types
- APIs: https://openiap.dev/docs/apis
- Errors: https://openiap.dev/docs/errors
- GitHub: https://github.com/hyodotdev/openiap