expo-iap 2.3.5-rc.4 → 2.3.6
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/build/modules/ios.js.map +1 -1
- package/iap.md +38 -20
- package/package.json +1 -1
- package/src/modules/ios.ts +5 -5
package/build/modules/ios.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,IAAI,CAAC;AAGrC,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAO7C,YAAY;AACZ,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,QAA2C,EAC3C,EAAE;IACF,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;AACvE,CAAC,CAAC;AAEF,cAAc;AACd,MAAM,UAAU,YAAY,CAC1B,IAAa;IAEb,OAAO,CACL,IAAI,IAAI,IAAI;QACZ,OAAO,IAAI,KAAK,QAAQ;QACxB,UAAU,IAAI,IAAI;QAClB,IAAI,CAAC,QAAQ,KAAK,KAAK,CACxB,CAAC;AACJ,CAAC;AAED,YAAY;AACZ;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,GAAkB,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,OAAe,EAAoB,EAAE,CAC3E,aAAa,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAEjD;;GAEG;AAEH,MAAM,CAAC,MAAM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1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,aAAa,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACrC,GAAW,EAMV,EAAE;IACH,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAC3D,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import {Platform} from 'react-native';\nimport {emitter, IapEvent} from '..';\nimport {ProductPurchase, PurchaseError} from '../ExpoIap.types';\nimport type {ProductStatusIos} from '../types/ExpoIapIos.types';\nimport ExpoIapModule from '../ExpoIapModule';\n\nexport type TransactionEvent = {\n transaction?: ProductPurchase;\n error?: PurchaseError;\n};\n\n// Listeners\nexport const transactionUpdatedIos = (\n listener: (event: TransactionEvent) => void,\n) => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n\n return emitter.addListener(IapEvent.TransactionIapUpdated, listener);\n};\n\n// Type guards\nexport function isProductIos<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'ios'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n item.platform === 'ios'\n );\n}\n\n// Functions\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n */\nexport const sync = (): Promise<null> => ExpoIapModule.sync();\n\n/**\n *\n */\nexport const isEligibleForIntroOffer = (groupID: string): Promise<boolean> =>\n ExpoIapModule.isEligibleForIntroOffer(groupID);\n\n/**\n *\n */\n\nexport const subscriptionStatus = (sku: string): Promise<ProductStatusIos[]> =>\n ExpoIapModule.subscriptionStatus(sku);\n\n/**\n *\n */\nexport const currentEntitlement = (sku: string): Promise<ProductPurchase> =>\n ExpoIapModule.currentEntitlement(sku);\n\n/**\n *\n */\nexport const latestTransaction = (sku: string): Promise<ProductPurchase> =>\n ExpoIapModule.latestTransaction(sku);\n\n/**\n *\n */\ntype RefundRequestStatus = 'success' | 'userCancelled';\nexport const beginRefundRequest = (sku: string): Promise<RefundRequestStatus> =>\n ExpoIapModule.beginRefundRequest(sku);\n\n/**\n * Shows the system UI for managing subscriptions.\n * When the user changes subscription renewal status, the system will emit events to
|
|
1
|
+
{"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,IAAI,CAAC;AAGrC,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAO7C,YAAY;AACZ,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,QAA2C,EAC3C,EAAE;IACF,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;AACvE,CAAC,CAAC;AAEF,cAAc;AACd,MAAM,UAAU,YAAY,CAC1B,IAAa;IAEb,OAAO,CACL,IAAI,IAAI,IAAI;QACZ,OAAO,IAAI,KAAK,QAAQ;QACxB,UAAU,IAAI,IAAI;QAClB,IAAI,CAAC,QAAQ,KAAK,KAAK,CACxB,CAAC;AACJ,CAAC;AAED,YAAY;AACZ;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,GAAkB,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,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ACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAW,EAAmB,EAAE;IAChE,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,aAAa,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACrC,GAAW,EAMV,EAAE;IACH,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAC3D,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import {Platform} from 'react-native';\nimport {emitter, IapEvent} from '..';\nimport {ProductPurchase, PurchaseError} from '../ExpoIap.types';\nimport type {ProductStatusIos} from '../types/ExpoIapIos.types';\nimport ExpoIapModule from '../ExpoIapModule';\n\nexport type TransactionEvent = {\n transaction?: ProductPurchase;\n error?: PurchaseError;\n};\n\n// Listeners\nexport const transactionUpdatedIos = (\n listener: (event: TransactionEvent) => void,\n) => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n\n return emitter.addListener(IapEvent.TransactionIapUpdated, listener);\n};\n\n// Type guards\nexport function isProductIos<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'ios'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n item.platform === 'ios'\n );\n}\n\n// Functions\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n */\nexport const sync = (): Promise<null> => ExpoIapModule.sync();\n\n/**\n *\n */\nexport const isEligibleForIntroOffer = (groupID: string): Promise<boolean> =>\n ExpoIapModule.isEligibleForIntroOffer(groupID);\n\n/**\n *\n */\n\nexport const subscriptionStatus = (sku: string): Promise<ProductStatusIos[]> =>\n ExpoIapModule.subscriptionStatus(sku);\n\n/**\n *\n */\nexport const currentEntitlement = (sku: string): Promise<ProductPurchase> =>\n ExpoIapModule.currentEntitlement(sku);\n\n/**\n *\n */\nexport const latestTransaction = (sku: string): Promise<ProductPurchase> =>\n ExpoIapModule.latestTransaction(sku);\n\n/**\n *\n */\ntype RefundRequestStatus = 'success' | 'userCancelled';\nexport const beginRefundRequest = (sku: string): Promise<RefundRequestStatus> =>\n ExpoIapModule.beginRefundRequest(sku);\n\n/**\n * Shows the system UI for managing subscriptions.\n * When the user changes subscription renewal status, the system will emit events to\n * purchaseUpdatedListener and transactionUpdatedIos listeners.\n * @returns {Promise<null>}\n */\nexport const showManageSubscriptions = (): Promise<null> =>\n ExpoIapModule.showManageSubscriptions();\n\n/**\n * Get the receipt data from the iOS device.\n * This returns the base64 encoded receipt data which can be sent to your server\n * for verification with Apple's server.\n *\n * NOTE: For proper security, always verify receipts on your server using\n * Apple's verifyReceipt endpoint, not directly from the app.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n */\nexport const getReceiptIos = (): Promise<string> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.getReceiptData();\n};\n\n/**\n * Check if a transaction is verified through StoreKit 2.\n * StoreKit 2 performs local verification of transaction JWS signatures.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<boolean>} True if the transaction is verified\n */\nexport const isTransactionVerified = (sku: string): Promise<boolean> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.isTransactionVerified(sku);\n};\n\n/**\n * Get the JWS representation of a purchase for server-side verification.\n * The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<string>} JWS representation of the transaction\n */\nexport const getTransactionJws = (sku: string): Promise<string> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n return ExpoIapModule.getTransactionJws(sku);\n};\n\n/**\n * Validate receipt for iOS using StoreKit 2's built-in verification.\n * Returns receipt data and verification information to help with server-side validation.\n *\n * NOTE: For proper security, Apple recommends verifying receipts on your server using\n * the verifyReceipt endpoint rather than relying solely on client-side verification.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<{\n * isValid: boolean;\n * receiptData: string;\n * jwsRepresentation: string;\n * latestTransaction?: ProductPurchase;\n * }>}\n */\nexport const validateReceiptIos = async (\n sku: string,\n): Promise<{\n isValid: boolean;\n receiptData: string;\n jwsRepresentation: string;\n latestTransaction?: ProductPurchase;\n}> => {\n if (Platform.OS !== 'ios') {\n throw new Error('This method is only available on iOS');\n }\n\n const result = await ExpoIapModule.validateReceiptIos(sku);\n return result;\n};\n"]}
|
package/iap.md
CHANGED
|
@@ -209,8 +209,8 @@ Transactions map to `Purchase` or `SubscriptionPurchase` with platform-specific
|
|
|
209
209
|
Below is a simple example of fetching products and making a purchase with `expo-iap` in a managed workflow, updated to use the new `requestPurchase` signature:
|
|
210
210
|
|
|
211
211
|
```tsx
|
|
212
|
-
import {
|
|
213
|
-
import {
|
|
212
|
+
import {useEffect, useState} from 'react';
|
|
213
|
+
import {Button, Text, View} from 'react-native';
|
|
214
214
|
import {
|
|
215
215
|
initConnection,
|
|
216
216
|
endConnection,
|
|
@@ -237,7 +237,7 @@ export default function SimpleIAP() {
|
|
|
237
237
|
|
|
238
238
|
const purchaseListener = purchaseUpdatedListener(async (purchase) => {
|
|
239
239
|
if (purchase) {
|
|
240
|
-
await finishTransaction({
|
|
240
|
+
await finishTransaction({purchase, isConsumable: true});
|
|
241
241
|
alert('Purchase completed!');
|
|
242
242
|
}
|
|
243
243
|
});
|
|
@@ -252,12 +252,12 @@ export default function SimpleIAP() {
|
|
|
252
252
|
const buyItem = async () => {
|
|
253
253
|
if (!product) return;
|
|
254
254
|
await requestPurchase({
|
|
255
|
-
request: {
|
|
255
|
+
request: {skus: [product.id]}, // Android expects 'skus'; iOS would use 'sku'
|
|
256
256
|
});
|
|
257
257
|
};
|
|
258
258
|
|
|
259
259
|
return (
|
|
260
|
-
<View style={{
|
|
260
|
+
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
|
|
261
261
|
<Text>{isConnected ? 'Connected' : 'Connecting...'}</Text>
|
|
262
262
|
{product ? (
|
|
263
263
|
<>
|
|
@@ -277,7 +277,7 @@ export default function SimpleIAP() {
|
|
|
277
277
|
The `useIAP` hook simplifies managing in-app purchases. Below is an example updated to use the new `requestPurchase` signature:
|
|
278
278
|
|
|
279
279
|
```tsx
|
|
280
|
-
import {
|
|
280
|
+
import {useEffect, useState} from 'react';
|
|
281
281
|
import {
|
|
282
282
|
SafeAreaView,
|
|
283
283
|
ScrollView,
|
|
@@ -289,12 +289,20 @@ import {
|
|
|
289
289
|
InteractionManager,
|
|
290
290
|
Alert,
|
|
291
291
|
} from 'react-native';
|
|
292
|
-
import {
|
|
293
|
-
import type {
|
|
292
|
+
import {useIAP} from 'expo-iap';
|
|
293
|
+
import type {ProductPurchase, SubscriptionProduct} from 'expo-iap';
|
|
294
294
|
|
|
295
295
|
// Define SKUs
|
|
296
|
-
const productSkus = [
|
|
297
|
-
|
|
296
|
+
const productSkus = [
|
|
297
|
+
'cpk.points.1000',
|
|
298
|
+
'cpk.points.5000',
|
|
299
|
+
'cpk.points.10000',
|
|
300
|
+
'cpk.points.30000',
|
|
301
|
+
];
|
|
302
|
+
const subscriptionSkus = [
|
|
303
|
+
'cpk.membership.monthly.bronze',
|
|
304
|
+
'cpk.membership.monthly.silver',
|
|
305
|
+
];
|
|
298
306
|
|
|
299
307
|
// Define operations
|
|
300
308
|
const operations = ['getProducts', 'getSubscriptions'] as const;
|
|
@@ -321,7 +329,10 @@ export default function IAPWithHook() {
|
|
|
321
329
|
|
|
322
330
|
const initializeIAP = async () => {
|
|
323
331
|
try {
|
|
324
|
-
await Promise.all([
|
|
332
|
+
await Promise.all([
|
|
333
|
+
getProducts(productSkus),
|
|
334
|
+
getSubscriptions(subscriptionSkus),
|
|
335
|
+
]);
|
|
325
336
|
setIsReady(true);
|
|
326
337
|
} catch (error) {
|
|
327
338
|
console.error('Error initializing IAP:', error);
|
|
@@ -389,7 +400,10 @@ export default function IAPWithHook() {
|
|
|
389
400
|
<View style={styles.buttons}>
|
|
390
401
|
<ScrollView contentContainerStyle={styles.buttonsWrapper} horizontal>
|
|
391
402
|
{operations.map((operation) => (
|
|
392
|
-
<Pressable
|
|
403
|
+
<Pressable
|
|
404
|
+
key={operation}
|
|
405
|
+
onPress={() => handleOperation(operation)}
|
|
406
|
+
>
|
|
393
407
|
<View style={styles.buttonView}>
|
|
394
408
|
<Text>{operation}</Text>
|
|
395
409
|
</View>
|
|
@@ -401,10 +415,10 @@ export default function IAPWithHook() {
|
|
|
401
415
|
{!isReady ? (
|
|
402
416
|
<Text>Loading...</Text>
|
|
403
417
|
) : (
|
|
404
|
-
<View style={{
|
|
405
|
-
<Text style={{
|
|
418
|
+
<View style={{gap: 12}}>
|
|
419
|
+
<Text style={{fontSize: 20}}>Products</Text>
|
|
406
420
|
{products.map((item) => (
|
|
407
|
-
<View key={item.id} style={{
|
|
421
|
+
<View key={item.id} style={{gap: 12}}>
|
|
408
422
|
<Text>
|
|
409
423
|
{item.title} -{' '}
|
|
410
424
|
{item.platform === 'android'
|
|
@@ -415,20 +429,24 @@ export default function IAPWithHook() {
|
|
|
415
429
|
title="Buy"
|
|
416
430
|
onPress={() =>
|
|
417
431
|
requestPurchase({
|
|
418
|
-
request:
|
|
432
|
+
request:
|
|
433
|
+
item.platform === 'android'
|
|
434
|
+
? {skus: [item.id]}
|
|
435
|
+
: {sku: item.id},
|
|
419
436
|
})
|
|
420
437
|
}
|
|
421
438
|
/>
|
|
422
439
|
</View>
|
|
423
440
|
))}
|
|
424
441
|
|
|
425
|
-
<Text style={{
|
|
442
|
+
<Text style={{fontSize: 20}}>Subscriptions</Text>
|
|
426
443
|
{subscriptions.map((item) => (
|
|
427
|
-
<View key={item.id} style={{
|
|
444
|
+
<View key={item.id} style={{gap: 12}}>
|
|
428
445
|
<Text>
|
|
429
446
|
{item.title || item.displayName} -{' '}
|
|
430
447
|
{item.platform === 'android' && item.subscriptionOfferDetails
|
|
431
|
-
? item.subscriptionOfferDetails[0]?.pricingPhases
|
|
448
|
+
? item.subscriptionOfferDetails[0]?.pricingPhases
|
|
449
|
+
.pricingPhaseList[0].formattedPrice
|
|
432
450
|
: item.displayPrice}
|
|
433
451
|
</Text>
|
|
434
452
|
<Button
|
|
@@ -445,7 +463,7 @@ export default function IAPWithHook() {
|
|
|
445
463
|
offerToken: offer.offerToken,
|
|
446
464
|
})) || [],
|
|
447
465
|
}
|
|
448
|
-
: {
|
|
466
|
+
: {sku: item.id},
|
|
449
467
|
type: 'subs',
|
|
450
468
|
})
|
|
451
469
|
}
|
package/package.json
CHANGED
package/src/modules/ios.ts
CHANGED
|
@@ -73,7 +73,7 @@ export const beginRefundRequest = (sku: string): Promise<RefundRequestStatus> =>
|
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Shows the system UI for managing subscriptions.
|
|
76
|
-
* When the user changes subscription renewal status, the system will emit events to
|
|
76
|
+
* When the user changes subscription renewal status, the system will emit events to
|
|
77
77
|
* purchaseUpdatedListener and transactionUpdatedIos listeners.
|
|
78
78
|
* @returns {Promise<null>}
|
|
79
79
|
*/
|
|
@@ -84,10 +84,10 @@ export const showManageSubscriptions = (): Promise<null> =>
|
|
|
84
84
|
* Get the receipt data from the iOS device.
|
|
85
85
|
* This returns the base64 encoded receipt data which can be sent to your server
|
|
86
86
|
* for verification with Apple's server.
|
|
87
|
-
*
|
|
87
|
+
*
|
|
88
88
|
* NOTE: For proper security, always verify receipts on your server using
|
|
89
89
|
* Apple's verifyReceipt endpoint, not directly from the app.
|
|
90
|
-
*
|
|
90
|
+
*
|
|
91
91
|
* @returns {Promise<string>} Base64 encoded receipt data
|
|
92
92
|
*/
|
|
93
93
|
export const getReceiptIos = (): Promise<string> => {
|
|
@@ -100,7 +100,7 @@ export const getReceiptIos = (): Promise<string> => {
|
|
|
100
100
|
/**
|
|
101
101
|
* Check if a transaction is verified through StoreKit 2.
|
|
102
102
|
* StoreKit 2 performs local verification of transaction JWS signatures.
|
|
103
|
-
*
|
|
103
|
+
*
|
|
104
104
|
* @param {string} sku The product's SKU (on iOS)
|
|
105
105
|
* @returns {Promise<boolean>} True if the transaction is verified
|
|
106
106
|
*/
|
|
@@ -114,7 +114,7 @@ export const isTransactionVerified = (sku: string): Promise<boolean> => {
|
|
|
114
114
|
/**
|
|
115
115
|
* Get the JWS representation of a purchase for server-side verification.
|
|
116
116
|
* The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.
|
|
117
|
-
*
|
|
117
|
+
*
|
|
118
118
|
* @param {string} sku The product's SKU (on iOS)
|
|
119
119
|
* @returns {Promise<string>} JWS representation of the transaction
|
|
120
120
|
*/
|