expo-iap 3.1.7 → 3.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CLAUDE.md CHANGED
@@ -156,6 +156,98 @@ public struct LoadingStates {
156
156
  - Use `status.loadings.purchasing.contains(productId)` to check if a specific product is being purchased
157
157
  - Use `status.isLoading` computed property to check if any operation is in progress
158
158
 
159
+ ### Error Handling
160
+
161
+ #### Error Code Format
162
+
163
+ All error codes in expo-iap follow the OpenIAP specification and use **kebab-case** format:
164
+
165
+ ```typescript
166
+ export enum ErrorCode {
167
+ UserCancelled = 'user-cancelled', // NOT 'E_USER_CANCELLED'
168
+ NetworkError = 'network-error',
169
+ ItemUnavailable = 'item-unavailable',
170
+ AlreadyOwned = 'already-owned',
171
+ // ...
172
+ }
173
+ ```
174
+
175
+ **Important**:
176
+
177
+ - ✅ Use `ErrorCode.UserCancelled` enum in TypeScript code
178
+ - ✅ Error codes are kebab-case strings: `'user-cancelled'`
179
+ - ❌ Never use deprecated `E_` prefix: `'E_USER_CANCELLED'`
180
+ - ❌ Never use UPPERCASE format: `'USER_CANCELLED'`
181
+
182
+ #### Error Object Structure
183
+
184
+ All errors returned from native modules have the following structure:
185
+
186
+ ```typescript
187
+ interface PurchaseError {
188
+ code: ErrorCode; // Standardized error code enum
189
+ message: string; // Human-readable error message
190
+ responseCode?: number; // Platform-specific response code
191
+ debugMessage?: string; // Additional debug information
192
+ productId?: string; // Product ID if applicable
193
+ }
194
+ ```
195
+
196
+ Example error object:
197
+
198
+ ```json
199
+ {
200
+ "code": "user-cancelled",
201
+ "message": "User cancelled the purchase",
202
+ "responseCode": 1,
203
+ "debugMessage": "User pressed cancel button",
204
+ "productId": "com.example.premium"
205
+ }
206
+ ```
207
+
208
+ #### Using Error Codes
209
+
210
+ Always use the `ErrorCode` enum for type-safe error handling:
211
+
212
+ ```typescript
213
+ import {useIAP, ErrorCode} from 'expo-iap';
214
+
215
+ const {requestPurchase} = useIAP({
216
+ onPurchaseError: (error) => {
217
+ // ✅ Correct - use ErrorCode enum
218
+ if (error.code === ErrorCode.UserCancelled) {
219
+ console.log('User cancelled');
220
+ return;
221
+ }
222
+
223
+ // ❌ Wrong - don't use string literals
224
+ if (error.code === 'E_USER_CANCELLED') {
225
+ /* ... */
226
+ }
227
+ if (error.code === 'USER_CANCELLED') {
228
+ /* ... */
229
+ }
230
+
231
+ // ✅ Correct - use switch with enum
232
+ switch (error.code) {
233
+ case ErrorCode.NetworkError:
234
+ showRetryDialog();
235
+ break;
236
+ case ErrorCode.ItemUnavailable:
237
+ showUnavailableMessage();
238
+ break;
239
+ default:
240
+ console.error(error.message);
241
+ }
242
+ },
243
+ });
244
+ ```
245
+
246
+ For complete error handling documentation, see:
247
+
248
+ - [Error Codes Reference](https://www.openiap.dev/docs/errors)
249
+ - [Error Handling Guide](https://docs.expo-iap.dev/docs/guides/error-handling)
250
+
159
251
  ## Documentation Guidelines
160
252
 
161
253
  ### Blog Post Conventions
package/bun.lockb CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <coverage generated="1759171574260" clover="3.2.0">
3
- <project timestamp="1759171574260" name="All files">
2
+ <coverage generated="1759407275851" clover="3.2.0">
3
+ <project timestamp="1759407275851" name="All files">
4
4
  <metrics statements="486" coveredstatements="470" conditionals="282" coveredconditionals="246" methods="91" coveredmethods="78" elements="859" coveredelements="794" complexity="0" loc="486" ncloc="486" packages="4" files="6" classes="6"/>
5
5
  <package name="src">
6
6
  <metrics statements="188" coveredstatements="186" conditionals="89" coveredconditionals="80" methods="39" coveredmethods="30"/>
@@ -146,7 +146,7 @@
146
146
  <div class='footer quiet pad2 space-top1 center small'>
147
147
  Code coverage generated by
148
148
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
149
- at 2025-09-29T18:46:14.242Z
149
+ at 2025-10-02T12:14:35.833Z
150
150
  </div>
151
151
  <script src="prettify.js"></script>
152
152
  <script>
@@ -101,7 +101,7 @@
101
101
  <div class='footer quiet pad2 space-top1 center small'>
102
102
  Code coverage generated by
103
103
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
104
- at 2025-09-29T18:46:14.242Z
104
+ at 2025-10-02T12:14:35.833Z
105
105
  </div>
106
106
  <script src="../../prettify.js"></script>
107
107
  <script>
@@ -484,7 +484,7 @@ export const hasActiveSubscriptions = async (
484
484
  <div class='footer quiet pad2 space-top1 center small'>
485
485
  Code coverage generated by
486
486
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
487
- at 2025-09-29T18:46:14.242Z
487
+ at 2025-10-02T12:14:35.833Z
488
488
  </div>
489
489
  <script src="../../prettify.js"></script>
490
490
  <script>
@@ -101,7 +101,7 @@
101
101
  <div class='footer quiet pad2 space-top1 center small'>
102
102
  Code coverage generated by
103
103
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
104
- at 2025-09-29T18:46:14.242Z
104
+ at 2025-10-02T12:14:35.833Z
105
105
  </div>
106
106
  <script src="../prettify.js"></script>
107
107
  <script>
@@ -1969,7 +1969,7 @@ export {<span class="fstat-no" title="function not covered" >ExpoIapConsole}</sp
1969
1969
  <div class='footer quiet pad2 space-top1 center small'>
1970
1970
  Code coverage generated by
1971
1971
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
1972
- at 2025-09-29T18:46:14.242Z
1972
+ at 2025-10-02T12:14:35.833Z
1973
1973
  </div>
1974
1974
  <script src="../prettify.js"></script>
1975
1975
  <script>
@@ -565,7 +565,7 @@ export const openRedeemOfferCodeAndroid = async (): Promise&lt;void&gt; =&gt; {
565
565
  <div class='footer quiet pad2 space-top1 center small'>
566
566
  Code coverage generated by
567
567
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
568
- at 2025-09-29T18:46:14.242Z
568
+ at 2025-10-02T12:14:35.833Z
569
569
  </div>
570
570
  <script src="../../prettify.js"></script>
571
571
  <script>
@@ -116,7 +116,7 @@
116
116
  <div class='footer quiet pad2 space-top1 center small'>
117
117
  Code coverage generated by
118
118
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
119
- at 2025-09-29T18:46:14.242Z
119
+ at 2025-10-02T12:14:35.833Z
120
120
  </div>
121
121
  <script src="../../prettify.js"></script>
122
122
  <script>
@@ -1141,7 +1141,7 @@ export const deepLinkToSubscriptionsIOS = (): Promise&lt;void&gt; =&gt;
1141
1141
  <div class='footer quiet pad2 space-top1 center small'>
1142
1142
  Code coverage generated by
1143
1143
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
1144
- at 2025-09-29T18:46:14.242Z
1144
+ at 2025-10-02T12:14:35.833Z
1145
1145
  </div>
1146
1146
  <script src="../../prettify.js"></script>
1147
1147
  <script>
@@ -268,7 +268,7 @@ export const ExpoIapConsole = createConsole();
268
268
  <div class='footer quiet pad2 space-top1 center small'>
269
269
  Code coverage generated by
270
270
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
271
- at 2025-09-29T18:46:14.242Z
271
+ at 2025-10-02T12:14:35.833Z
272
272
  </div>
273
273
  <script src="../../prettify.js"></script>
274
274
  <script>
@@ -1111,7 +1111,7 @@ export function getUserFriendlyErrorMessage(error: ErrorLike): string {
1111
1111
  <div class='footer quiet pad2 space-top1 center small'>
1112
1112
  Code coverage generated by
1113
1113
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
1114
- at 2025-09-29T18:46:14.242Z
1114
+ at 2025-10-02T12:14:35.833Z
1115
1115
  </div>
1116
1116
  <script src="../../prettify.js"></script>
1117
1117
  <script>
@@ -116,7 +116,7 @@
116
116
  <div class='footer quiet pad2 space-top1 center small'>
117
117
  Code coverage generated by
118
118
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
119
- at 2025-09-29T18:46:14.242Z
119
+ at 2025-10-02T12:14:35.833Z
120
120
  </div>
121
121
  <script src="../../prettify.js"></script>
122
122
  <script>
@@ -13,7 +13,7 @@ public final class ExpoIapModule: Module {
13
13
  nonisolated public func definition() -> ModuleDefinition {
14
14
  Name("ExpoIap")
15
15
 
16
- Constants {
16
+ Property("errorCodes") {
17
17
  OpenIapSerialization.errorCodes()
18
18
  }
19
19
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "apple": "1.2.4",
2
+ "apple": "1.2.6",
3
3
  "google": "1.2.10",
4
4
  "gql": "1.0.9"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-iap",
3
- "version": "3.1.7",
3
+ "version": "3.1.8",
4
4
  "description": "In App Purchase module in Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -1 +1 @@
1
- {"root":["./src/expoConfig.augmentation.d.ts","./src/withIAP.ts","./src/withLocalOpenIAP.ts"],"version":"5.9.2"}
1
+ {"root":["./src/expoConfig.augmentation.d.ts","./src/withIAP.ts","./src/withLocalOpenIAP.ts"],"version":"5.9.3"}