expo-iap 3.1.38 → 3.3.0-rc.1
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/.prettierignore +1 -0
- package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +124 -0
- package/build/index.d.ts +15 -6
- package/build/index.d.ts.map +1 -1
- package/build/index.js +30 -17
- package/build/index.js.map +1 -1
- package/build/modules/android.d.ts +53 -1
- package/build/modules/android.d.ts.map +1 -1
- package/build/modules/android.js +61 -0
- package/build/modules/android.js.map +1 -1
- package/build/types.d.ts +255 -11
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/useIAP.d.ts.map +1 -1
- package/build/useIAP.js +2 -0
- package/build/useIAP.js.map +1 -1
- package/coverage/clover.xml +147 -139
- package/coverage/coverage-final.json +5 -5
- package/coverage/lcov-report/block-navigation.js +1 -1
- package/coverage/lcov-report/index.html +23 -23
- package/coverage/lcov-report/sorter.js +7 -21
- package/coverage/lcov-report/src/ExpoIap.types.ts.html +1396 -0
- package/coverage/lcov-report/src/helpers/index.html +116 -0
- package/coverage/lcov-report/src/helpers/subscription.ts.html +499 -0
- package/coverage/lcov-report/src/index.html +14 -14
- package/coverage/lcov-report/src/index.ts.html +64 -25
- package/coverage/lcov-report/src/modules/android.ts.html +233 -8
- package/coverage/lcov-report/src/modules/index.html +15 -15
- package/coverage/lcov-report/src/modules/ios.ts.html +1 -1
- package/coverage/lcov-report/src/onside/ExpoOnsideMarketplaceAvailabilityModule.ts.html +145 -0
- package/coverage/lcov-report/src/onside/index.html +131 -0
- package/coverage/lcov-report/src/onside/index.ts.html +253 -0
- package/coverage/lcov-report/src/types/ExpoIapAndroid.types.ts.html +502 -0
- package/coverage/lcov-report/src/types/index.html +116 -0
- package/coverage/lcov-report/src/useIAP.ts.html +1654 -0
- package/coverage/lcov-report/src/utils/constants.ts.html +127 -0
- package/coverage/lcov-report/src/utils/debug.ts.html +1 -1
- package/coverage/lcov-report/src/utils/errorMapping.ts.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov.info +249 -232
- package/ios/expoiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/expoiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/openiap-versions.json +3 -3
- package/package.json +1 -1
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/src/index.ts +30 -17
- package/src/modules/android.ts +75 -0
- package/src/types.ts +273 -12
- package/src/useIAP.ts +2 -0
package/openiap-versions.json
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/
|
|
1
|
+
{"root":["./src/expoconfig.augmentation.d.ts","./src/withiap.ts","./src/withiosalternativebilling.ts","./src/withlocalopeniap.ts"],"version":"5.9.2"}
|
package/src/index.ts
CHANGED
|
@@ -424,24 +424,28 @@ function normalizeRequestProps(
|
|
|
424
424
|
| RequestSubscriptionPropsByPlatforms,
|
|
425
425
|
platform: 'ios' | 'android',
|
|
426
426
|
) {
|
|
427
|
-
//
|
|
428
|
-
|
|
427
|
+
// Support both new (apple/google) and legacy (ios/android) field names
|
|
428
|
+
// New fields take precedence over deprecated ones
|
|
429
|
+
if (platform === 'ios') {
|
|
430
|
+
return request.apple ?? request.ios;
|
|
431
|
+
}
|
|
432
|
+
return request.google ?? request.android;
|
|
429
433
|
}
|
|
430
434
|
|
|
431
435
|
/**
|
|
432
436
|
* Request a purchase for products or subscriptions.
|
|
433
437
|
*
|
|
434
438
|
* @param requestObj - Purchase request configuration
|
|
435
|
-
* @param requestObj.request -
|
|
439
|
+
* @param requestObj.request - Store-specific purchase parameters
|
|
436
440
|
* @param requestObj.type - Type of purchase: 'in-app' for products (default) or 'subs' for subscriptions
|
|
437
441
|
*
|
|
438
442
|
* @example
|
|
439
443
|
* ```typescript
|
|
440
|
-
* // Product purchase
|
|
444
|
+
* // Product purchase (recommended: use apple/google)
|
|
441
445
|
* await requestPurchase({
|
|
442
446
|
* request: {
|
|
443
|
-
*
|
|
444
|
-
*
|
|
447
|
+
* apple: { sku: productId },
|
|
448
|
+
* google: { skus: [productId] }
|
|
445
449
|
* },
|
|
446
450
|
* type: 'in-app'
|
|
447
451
|
* });
|
|
@@ -449,14 +453,23 @@ function normalizeRequestProps(
|
|
|
449
453
|
* // Subscription purchase
|
|
450
454
|
* await requestPurchase({
|
|
451
455
|
* request: {
|
|
452
|
-
*
|
|
453
|
-
*
|
|
456
|
+
* apple: { sku: subscriptionId },
|
|
457
|
+
* google: {
|
|
454
458
|
* skus: [subscriptionId],
|
|
455
459
|
* subscriptionOffers: [{ sku: subscriptionId, offerToken: 'token' }]
|
|
456
460
|
* }
|
|
457
461
|
* },
|
|
458
462
|
* type: 'subs'
|
|
459
463
|
* });
|
|
464
|
+
*
|
|
465
|
+
* // Legacy format (deprecated, but still supported)
|
|
466
|
+
* await requestPurchase({
|
|
467
|
+
* request: {
|
|
468
|
+
* ios: { sku: productId },
|
|
469
|
+
* android: { skus: [productId] }
|
|
470
|
+
* },
|
|
471
|
+
* type: 'in-app'
|
|
472
|
+
* });
|
|
460
473
|
* ```
|
|
461
474
|
*/
|
|
462
475
|
export const requestPurchase: MutationField<'requestPurchase'> = async (
|
|
@@ -471,12 +484,12 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
|
|
|
471
484
|
|
|
472
485
|
if (!normalizedRequest?.sku) {
|
|
473
486
|
throw new Error(
|
|
474
|
-
'Invalid request for
|
|
487
|
+
'Invalid request for Apple. The `sku` property is required and must be a string.\n\n' +
|
|
475
488
|
'Expected format:\n' +
|
|
476
489
|
' requestPurchase({\n' +
|
|
477
490
|
' request: {\n' +
|
|
478
|
-
'
|
|
479
|
-
'
|
|
491
|
+
' apple: { sku: "product_id" },\n' +
|
|
492
|
+
' google: { skus: ["product_id"] }\n' +
|
|
480
493
|
' },\n' +
|
|
481
494
|
' type: "in-app"\n' +
|
|
482
495
|
' })\n\n' +
|
|
@@ -519,12 +532,12 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
|
|
|
519
532
|
|
|
520
533
|
if (!normalizedRequest?.skus?.length) {
|
|
521
534
|
throw new Error(
|
|
522
|
-
'Invalid request for
|
|
535
|
+
'Invalid request for Google. The `skus` property is required and must be a non-empty array.\n\n' +
|
|
523
536
|
'Expected format:\n' +
|
|
524
537
|
' requestPurchase({\n' +
|
|
525
538
|
' request: {\n' +
|
|
526
|
-
'
|
|
527
|
-
'
|
|
539
|
+
' apple: { sku: "product_id" },\n' +
|
|
540
|
+
' google: { skus: ["product_id"] }\n' +
|
|
528
541
|
' },\n' +
|
|
529
542
|
' type: "in-app"\n' +
|
|
530
543
|
' })\n\n' +
|
|
@@ -561,12 +574,12 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
|
|
|
561
574
|
|
|
562
575
|
if (!normalizedRequest?.skus?.length) {
|
|
563
576
|
throw new Error(
|
|
564
|
-
'Invalid request for
|
|
577
|
+
'Invalid request for Google. The `skus` property is required and must be a non-empty array.\n\n' +
|
|
565
578
|
'Expected format:\n' +
|
|
566
579
|
' requestPurchase({\n' +
|
|
567
580
|
' request: {\n' +
|
|
568
|
-
'
|
|
569
|
-
'
|
|
581
|
+
' apple: { sku: "subscription_id" },\n' +
|
|
582
|
+
' google: { skus: ["subscription_id"] }\n' +
|
|
570
583
|
' },\n' +
|
|
571
584
|
' type: "subs"\n' +
|
|
572
585
|
' })\n\n' +
|
package/src/modules/android.ts
CHANGED
|
@@ -6,7 +6,11 @@ import ExpoIapModule from '../ExpoIapModule';
|
|
|
6
6
|
|
|
7
7
|
// Types
|
|
8
8
|
import type {
|
|
9
|
+
BillingProgramAndroid,
|
|
10
|
+
BillingProgramAvailabilityResultAndroid,
|
|
11
|
+
BillingProgramReportingDetailsAndroid,
|
|
9
12
|
DeepLinkOptions,
|
|
13
|
+
LaunchExternalLinkParamsAndroid,
|
|
10
14
|
MutationField,
|
|
11
15
|
VerifyPurchaseResultAndroid,
|
|
12
16
|
} from '../types';
|
|
@@ -248,3 +252,74 @@ export const createAlternativeBillingTokenAndroid: MutationField<
|
|
|
248
252
|
> = async (sku?: string) => {
|
|
249
253
|
return ExpoIapModule.createAlternativeBillingTokenAndroid(sku);
|
|
250
254
|
};
|
|
255
|
+
|
|
256
|
+
// ============================================================================
|
|
257
|
+
// Billing Programs API (Google Play Billing Library 8.2.0+)
|
|
258
|
+
// ============================================================================
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Check if a specific billing program is available for this user/device (Android only).
|
|
262
|
+
* Available in Google Play Billing Library 8.2.0+.
|
|
263
|
+
*
|
|
264
|
+
* @param program - The billing program to check ('external-offer' or 'external-content-link')
|
|
265
|
+
* @returns Promise resolving to availability result
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```typescript
|
|
269
|
+
* const result = await isBillingProgramAvailableAndroid('external-offer');
|
|
270
|
+
* if (result.isAvailable) {
|
|
271
|
+
* // Proceed with billing program flow
|
|
272
|
+
* }
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
export const isBillingProgramAvailableAndroid = async (
|
|
276
|
+
program: BillingProgramAndroid,
|
|
277
|
+
): Promise<BillingProgramAvailabilityResultAndroid> => {
|
|
278
|
+
return ExpoIapModule.isBillingProgramAvailableAndroid(program);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Launch an external link for the specified billing program (Android only).
|
|
283
|
+
* Available in Google Play Billing Library 8.2.0+.
|
|
284
|
+
*
|
|
285
|
+
* @param params - The external link parameters
|
|
286
|
+
* @returns Promise resolving when the link is launched
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```typescript
|
|
290
|
+
* await launchExternalLinkAndroid({
|
|
291
|
+
* billingProgram: 'external-offer',
|
|
292
|
+
* launchMode: 'launch-in-external-browser-or-app',
|
|
293
|
+
* linkType: 'link-to-digital-content-offer',
|
|
294
|
+
* linkUri: 'https://your-payment-site.com',
|
|
295
|
+
* });
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
export const launchExternalLinkAndroid = async (
|
|
299
|
+
params: LaunchExternalLinkParamsAndroid,
|
|
300
|
+
): Promise<void> => {
|
|
301
|
+
return ExpoIapModule.launchExternalLinkAndroid(params);
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Create billing program reporting details for Google Play reporting (Android only).
|
|
306
|
+
* Available in Google Play Billing Library 8.2.0+.
|
|
307
|
+
*
|
|
308
|
+
* Must be called AFTER successful payment in your payment system.
|
|
309
|
+
* Token must be reported to Google Play backend within 24 hours.
|
|
310
|
+
*
|
|
311
|
+
* @param program - The billing program type
|
|
312
|
+
* @returns Promise resolving to reporting details including the external transaction token
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```typescript
|
|
316
|
+
* const details = await createBillingProgramReportingDetailsAndroid('external-offer');
|
|
317
|
+
* // Report details.externalTransactionToken to Google Play within 24 hours
|
|
318
|
+
* await reportToGooglePlay(details.externalTransactionToken);
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
export const createBillingProgramReportingDetailsAndroid = async (
|
|
322
|
+
program: BillingProgramAndroid,
|
|
323
|
+
): Promise<BillingProgramReportingDetailsAndroid> => {
|
|
324
|
+
return ExpoIapModule.createBillingProgramReportingDetailsAndroid(program);
|
|
325
|
+
};
|