expo-iap 2.2.0-rc.2 → 2.2.0-rc.3

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.
Files changed (43) hide show
  1. package/build/ExpoIap.types.js +0 -1
  2. package/build/ExpoIap.types.ts +125 -0
  3. package/build/ExpoIapModule.js +0 -1
  4. package/build/ExpoIapModule.ts +5 -0
  5. package/build/index.js +0 -1
  6. package/build/index.ts +354 -0
  7. package/build/modules/android.js +0 -1
  8. package/build/modules/android.ts +99 -0
  9. package/build/modules/ios.js +0 -1
  10. package/build/modules/ios.ts +84 -0
  11. package/build/types/ExpoIapAndroid.types.js +0 -1
  12. package/build/types/ExpoIapAndroid.types.ts +127 -0
  13. package/build/types/ExpoIapIos.types.js +0 -1
  14. package/build/types/ExpoIapIos.types.ts +136 -0
  15. package/build/useIap.js +0 -1
  16. package/build/useIap.ts +185 -0
  17. package/package.json +6 -5
  18. package/src/types/ExpoIapIos.types.ts +0 -1
  19. package/tsconfig.json +6 -1
  20. package/build/ExpoIap.types.d.ts +0 -80
  21. package/build/ExpoIap.types.d.ts.map +0 -1
  22. package/build/ExpoIap.types.js.map +0 -1
  23. package/build/ExpoIapModule.d.ts +0 -3
  24. package/build/ExpoIapModule.d.ts.map +0 -1
  25. package/build/ExpoIapModule.js.map +0 -1
  26. package/build/index.d.ts +0 -37
  27. package/build/index.d.ts.map +0 -1
  28. package/build/index.js.map +0 -1
  29. package/build/modules/android.d.ts +0 -48
  30. package/build/modules/android.d.ts.map +0 -1
  31. package/build/modules/android.js.map +0 -1
  32. package/build/modules/ios.d.ts +0 -49
  33. package/build/modules/ios.d.ts.map +0 -1
  34. package/build/modules/ios.js.map +0 -1
  35. package/build/types/ExpoIapAndroid.types.d.ts +0 -113
  36. package/build/types/ExpoIapAndroid.types.d.ts.map +0 -1
  37. package/build/types/ExpoIapAndroid.types.js.map +0 -1
  38. package/build/types/ExpoIapIos.types.d.ts +0 -119
  39. package/build/types/ExpoIapIos.types.d.ts.map +0 -1
  40. package/build/types/ExpoIapIos.types.js.map +0 -1
  41. package/build/useIap.d.ts +0 -23
  42. package/build/useIap.d.ts.map +0 -1
  43. package/build/useIap.js.map +0 -1
@@ -0,0 +1,127 @@
1
+ import {PurchaseBase, ProductBase} from '../ExpoIap.types';
2
+
3
+ type OneTimePurchaseOfferDetails = {
4
+ priceCurrencyCode: string;
5
+ formattedPrice: string;
6
+ priceAmountMicros: string;
7
+ };
8
+
9
+ type PricingPhaseAndroid = {
10
+ formattedPrice: string;
11
+ priceCurrencyCode: string;
12
+ // P1W, P1M, P1Y
13
+ billingPeriod: string;
14
+ billingCycleCount: number;
15
+ priceAmountMicros: string;
16
+ recurrenceMode: number;
17
+ };
18
+
19
+ type PricingPhasesAndroid = {
20
+ pricingPhaseList: PricingPhaseAndroid[];
21
+ };
22
+
23
+ type SubscriptionOfferDetail = {
24
+ basePlanId: string;
25
+ offerId: string;
26
+ offerToken: string;
27
+ offerTags: string[];
28
+ pricingPhases: PricingPhasesAndroid;
29
+ };
30
+
31
+ export type ProductAndroid = ProductBase & {
32
+ name: string;
33
+ oneTimePurchaseOfferDetails?: OneTimePurchaseOfferDetails;
34
+ subscriptionOfferDetails?: SubscriptionOfferDetail[];
35
+ };
36
+
37
+ type SubscriptionOfferAndroid = {
38
+ basePlanId: string;
39
+ offerId: string | null;
40
+ offerToken: string;
41
+ pricingPhases: PricingPhasesAndroid;
42
+ offerTags: string[];
43
+ };
44
+
45
+ export type SubscriptionProductAndroid = ProductAndroid & {
46
+ subscriptionOfferDetails: SubscriptionOfferAndroid[];
47
+ };
48
+
49
+ export type RequestPurchaseAndroidProps = {
50
+ skus: string[];
51
+ obfuscatedAccountIdAndroid?: string;
52
+ obfuscatedProfileIdAndroid?: string;
53
+ isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price
54
+ };
55
+
56
+ enum ReplacementModesAndroid {
57
+ UNKNOWN_REPLACEMENT_MODE = 0,
58
+ WITH_TIME_PRORATION = 1,
59
+ CHARGE_PRORATED_PRICE = 2,
60
+ WITHOUT_PRORATION = 3,
61
+ CHARGE_FULL_PRICE = 5,
62
+ DEFERRED = 6,
63
+ }
64
+
65
+ type SubscriptionOffer = {
66
+ sku: string;
67
+ offerToken: string;
68
+ };
69
+
70
+ export type RequestSubscriptionAndroidProps = RequestPurchaseAndroidProps & {
71
+ purchaseTokenAndroid?: string;
72
+ replacementModeAndroid?: ReplacementModesAndroid;
73
+ subscriptionOffers: SubscriptionOffer[];
74
+ };
75
+
76
+ export type ReceiptAndroid = {
77
+ autoRenewing: boolean;
78
+ betaProduct: boolean;
79
+ cancelDate: number | null;
80
+ cancelReason: string;
81
+ deferredDate: number | null;
82
+ deferredSku: number | null;
83
+ freeTrialEndDate: number;
84
+ gracePeriodEndDate: number;
85
+ parentProductId: string;
86
+ productId: string;
87
+ productType: string;
88
+ purchaseDate: number;
89
+ quantity: number;
90
+ receiptId: string;
91
+ renewalDate: number;
92
+ term: string;
93
+ termSku: string;
94
+ testTransaction: boolean;
95
+ };
96
+
97
+ export enum FeatureTypeAndroid {
98
+ /** Show in-app messages. Included in documentation by the annotations: */
99
+ IN_APP_MESSAGING = 'IN_APP_MESSAGING',
100
+ /** Launch a price change confirmation flow. */
101
+ PRICE_CHANGE_CONFIRMATION = 'PRICE_CHANGE_CONFIRMATION',
102
+ /** Play billing library support for querying and purchasing with ProductDetails. */
103
+ PRODUCT_DETAILS = 'PRODUCT_DETAILS',
104
+ /** Purchase/query for subscriptions. */
105
+ SUBSCRIPTIONS = 'SUBSCRIPTIONS',
106
+ /** Subscriptions update/replace. */
107
+ SUBSCRIPTIONS_UPDATE = 'SUBSCRIPTIONS_UPDATE',
108
+ }
109
+
110
+ export enum PurchaseStateAndroid {
111
+ UNSPECIFIED_STATE = 0,
112
+ PURCHASED = 1,
113
+ PENDING = 2,
114
+ }
115
+
116
+ export type ProductPurchaseAndroid = PurchaseBase & {
117
+ ids?: string[];
118
+ dataAndroid?: string;
119
+ signatureAndroid?: string;
120
+ autoRenewingAndroid?: boolean;
121
+ purchaseStateAndroid?: PurchaseStateAndroid;
122
+ isAcknowledgedAndroid?: boolean;
123
+ packageNameAndroid?: string;
124
+ developerPayloadAndroid?: string;
125
+ obfuscatedAccountIdAndroid?: string;
126
+ obfuscatedProfileIdAndroid?: string;
127
+ };
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=ExpoIapIos.types.js.map
@@ -0,0 +1,136 @@
1
+ import {PurchaseBase, ProductBase} from '../ExpoIap.types';
2
+
3
+ type SubscriptionIosPeriod = 'DAY' | 'WEEK' | 'MONTH' | 'YEAR' | '';
4
+ type PaymentMode = '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';
5
+
6
+ type SubscriptionOffer = {
7
+ displayPrice: string;
8
+ id: string;
9
+ paymentMode: PaymentMode;
10
+ period: SubscriptionIosPeriod;
11
+ periodCount: number;
12
+ price: number;
13
+ type: 'introductory' | 'promotional';
14
+ };
15
+
16
+ type SubscriptionInfo = {
17
+ introductoryOffer?: SubscriptionOffer;
18
+ promotionalOffers?: SubscriptionOffer[];
19
+ subscriptionGroupID: string;
20
+ subscriptionPeriod: SubscriptionIosPeriod;
21
+ };
22
+
23
+ export type ProductIos = ProductBase & {
24
+ displayName: string;
25
+ displayPrice: string;
26
+ isFamilyShareable: boolean;
27
+ jsonRepresentation: string;
28
+ subscription: SubscriptionInfo;
29
+ introductoryPriceNumberOfPeriodsIOS?: string;
30
+ introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;
31
+ };
32
+
33
+ export type Discount = {
34
+ identifier: string;
35
+ type: string;
36
+ numberOfPeriods: string;
37
+ price: string;
38
+ localizedPrice: string;
39
+ paymentMode: PaymentMode;
40
+ subscriptionPeriod: string;
41
+ };
42
+
43
+ export type SubscriptionProductIos = ProductIos & {
44
+ discounts?: Discount[];
45
+ introductoryPrice?: string;
46
+ introductoryPriceAsAmountIOS?: string;
47
+ introductoryPricePaymentModeIOS?: PaymentMode;
48
+ introductoryPriceNumberOfPeriodsIOS?: string;
49
+ introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;
50
+ subscriptionPeriodNumberIOS?: string;
51
+ subscriptionPeriodUnitIOS?: SubscriptionIosPeriod;
52
+ };
53
+
54
+ export type PaymentDiscount = {
55
+ /**
56
+ * A string used to uniquely identify a discount offer for a product.
57
+ */
58
+ identifier: string;
59
+ /**
60
+ * A string that identifies the key used to generate the signature.
61
+ */
62
+ keyIdentifier: string;
63
+ /**
64
+ * A universally unique ID (UUID) value that you define.
65
+ */
66
+ nonce: string;
67
+ /**
68
+ * A UTF-8 string representing the properties of a specific discount offer, cryptographically signed.
69
+ */
70
+ signature: string;
71
+ /**
72
+ * The date and time of the signature's creation in milliseconds, formatted in Unix epoch time.
73
+ */
74
+ timestamp: number;
75
+ };
76
+
77
+ export type RequestPurchaseIosProps = {
78
+ sku: string;
79
+ /**
80
+ * UUID representing user account
81
+ */
82
+ appAccountToken?: string;
83
+ quantity?: number;
84
+ withOffer?: PaymentDiscount;
85
+ };
86
+
87
+ export type RequestSubscriptionIosProps = RequestPurchaseIosProps;
88
+
89
+ type SubscriptionStatus =
90
+ | 'expired'
91
+ | 'inBillingRetryPeriod'
92
+ | 'inGracePeriod'
93
+ | 'revoked'
94
+ | 'subscribed';
95
+
96
+ type RenewalInfo = {
97
+ jsonRepresentation?: string;
98
+ willAutoRenew: boolean;
99
+ autoRenewPreference?: string;
100
+ };
101
+
102
+ export type ProductStatusIos = {
103
+ state: SubscriptionStatus;
104
+ renewalInfo?: RenewalInfo;
105
+ };
106
+
107
+ export type ProductPurchaseIos = PurchaseBase & {
108
+ // iOS basic fields
109
+ quantityIos?: number;
110
+ originalTransactionDateIos?: number;
111
+ originalTransactionIdentifierIos?: string;
112
+ verificationResultIos?: string;
113
+ appAccountToken?: string;
114
+ // iOS additional fields from StoreKit 2
115
+ expirationDateIos?: number;
116
+ webOrderLineItemIdIos?: number;
117
+ environmentIos?: string;
118
+ storefrontCountryCodeIos?: string;
119
+ appBundleIdIos?: string;
120
+ productTypeIos?: string;
121
+ subscriptionGroupIdIos?: string;
122
+ isUpgradedIos?: boolean;
123
+ ownershipTypeIos?: string;
124
+ reasonIos?: string;
125
+ reasonStringRepresentationIos?: string;
126
+ transactionReasonIos?: 'PURCHASE' | 'RENEWAL' | string;
127
+ revocationDateIos?: number;
128
+ revocationReasonIos?: string;
129
+ offerIos?: {
130
+ id: string;
131
+ type: string;
132
+ paymentMode: string;
133
+ };
134
+ priceIos?: number;
135
+ currencyIos?: string;
136
+ };
package/build/useIap.js CHANGED
@@ -97,4 +97,3 @@ export function useIAP() {
97
97
  getPurchaseHistories: requestPurchaseHistories,
98
98
  };
99
99
  }
100
- //# sourceMappingURL=useIap.js.map
@@ -0,0 +1,185 @@
1
+ import {
2
+ endConnection,
3
+ initConnection,
4
+ purchaseErrorListener,
5
+ purchaseUpdatedListener,
6
+ transactionUpdatedIos,
7
+ getProducts,
8
+ getAvailablePurchases,
9
+ getPurchaseHistory,
10
+ getSubscriptions,
11
+ } from './';
12
+ import {useCallback, useEffect, useState} from 'react';
13
+ import {
14
+ Product,
15
+ ProductPurchase,
16
+ Purchase,
17
+ PurchaseError,
18
+ PurchaseResult,
19
+ SubscriptionProduct,
20
+ SubscriptionPurchase,
21
+ } from './ExpoIap.types';
22
+ import {TransactionEvent} from './modules/ios';
23
+ import {Subscription} from 'expo-modules-core';
24
+
25
+ type IAP_STATUS = {
26
+ connected: boolean;
27
+ products: Product[];
28
+ promotedProductsIOS: ProductPurchase[];
29
+ subscriptions: SubscriptionProduct[];
30
+ purchaseHistories: ProductPurchase[];
31
+ availablePurchases: ProductPurchase[];
32
+ currentPurchase?: ProductPurchase;
33
+ currentPurchaseError?: PurchaseError;
34
+ finishTransaction: ({
35
+ purchase,
36
+ isConsumable,
37
+ developerPayloadAndroid,
38
+ }: {
39
+ purchase: Purchase;
40
+ isConsumable?: boolean;
41
+ developerPayloadAndroid?: string;
42
+ }) => Promise<string | boolean | PurchaseResult | void>;
43
+ getAvailablePurchases: () => Promise<void>;
44
+ getPurchaseHistories: () => Promise<void>;
45
+ getProducts: (skus: string[]) => Promise<void>;
46
+ getSubscriptions: (skus: string[]) => Promise<void>;
47
+ };
48
+
49
+ let purchaseUpdateSubscription: Subscription;
50
+ let purchaseErrorSubscription: Subscription;
51
+ let promotedProductsSubscription: Subscription;
52
+
53
+ export function useIAP(): IAP_STATUS {
54
+ const [connected, setConnected] = useState<boolean>(false);
55
+ const [products, setProducts] = useState<Product[]>([]);
56
+ const [promotedProductsIOS, setPromotedProductsIOS] = useState<
57
+ ProductPurchase[]
58
+ >([]);
59
+ const [subscriptions, setSubscriptions] = useState<SubscriptionProduct[]>([]);
60
+ const [purchaseHistories, setPurchaseHistories] = useState<ProductPurchase[]>(
61
+ [],
62
+ );
63
+ const [availablePurchases, setAvailablePurchases] = useState<
64
+ ProductPurchase[]
65
+ >([]);
66
+ const [currentPurchase, setCurrentPurchase] = useState<ProductPurchase>();
67
+ const [currentPurchaseError, setCurrentPurchaseError] =
68
+ useState<PurchaseError>();
69
+
70
+ const requestProducts = useCallback(async (skus: string[]): Promise<void> => {
71
+ setProducts(await getProducts(skus));
72
+ }, []);
73
+
74
+ const requestSubscriptions = useCallback(
75
+ async (skus: string[]): Promise<void> => {
76
+ setSubscriptions(await getSubscriptions(skus));
77
+ },
78
+ [],
79
+ );
80
+
81
+ const requestAvailablePurchases = useCallback(async (): Promise<void> => {
82
+ setAvailablePurchases(await getAvailablePurchases());
83
+ }, []);
84
+
85
+ const requestPurchaseHistories = useCallback(async (): Promise<void> => {
86
+ setPurchaseHistories(await getPurchaseHistory());
87
+ }, []);
88
+
89
+ const finishTransaction = useCallback(
90
+ async ({
91
+ purchase,
92
+ isConsumable,
93
+ developerPayloadAndroid,
94
+ }: {
95
+ purchase: ProductPurchase;
96
+ isConsumable?: boolean;
97
+ developerPayloadAndroid?: string;
98
+ }): Promise<string | boolean | PurchaseResult | void> => {
99
+ try {
100
+ return await finishTransaction({
101
+ purchase,
102
+ isConsumable,
103
+ developerPayloadAndroid,
104
+ });
105
+ } catch (err) {
106
+ throw err;
107
+ } finally {
108
+ if (purchase.id === currentPurchase?.id) {
109
+ setCurrentPurchase(undefined);
110
+ }
111
+
112
+ if (purchase.id === currentPurchaseError?.productId) { // Note that PurchaseError still uses productId
113
+ setCurrentPurchaseError(undefined);
114
+ }
115
+ }
116
+ },
117
+ [
118
+ currentPurchase?.id,
119
+ currentPurchaseError?.productId,
120
+ setCurrentPurchase,
121
+ setCurrentPurchaseError,
122
+ ],
123
+ );
124
+
125
+ const initIapWithSubscriptions = useCallback(async (): Promise<void> => {
126
+ const result = await initConnection();
127
+
128
+ setConnected(result);
129
+
130
+ if (result) {
131
+ purchaseUpdateSubscription = purchaseUpdatedListener(
132
+ async (purchase: Purchase | SubscriptionPurchase) => {
133
+ setCurrentPurchaseError(undefined);
134
+ setCurrentPurchase(purchase);
135
+ },
136
+ );
137
+
138
+ purchaseErrorSubscription = purchaseErrorListener(
139
+ (error: PurchaseError) => {
140
+ setCurrentPurchase(undefined);
141
+ setCurrentPurchaseError(error);
142
+ },
143
+ );
144
+
145
+ promotedProductsSubscription = transactionUpdatedIos(
146
+ (event: TransactionEvent) => {
147
+ setPromotedProductsIOS((prevProducts) =>
148
+ event.transaction
149
+ ? [...prevProducts, event.transaction]
150
+ : prevProducts,
151
+ );
152
+ },
153
+ );
154
+ }
155
+ }, []);
156
+
157
+ useEffect(() => {
158
+ initIapWithSubscriptions();
159
+
160
+ return (): void => {
161
+ if (purchaseUpdateSubscription) purchaseUpdateSubscription.remove();
162
+ if (purchaseErrorSubscription) purchaseErrorSubscription.remove();
163
+ if (promotedProductsSubscription) promotedProductsSubscription.remove();
164
+
165
+ endConnection();
166
+ setConnected(false);
167
+ };
168
+ }, [initIapWithSubscriptions]);
169
+
170
+ return {
171
+ connected,
172
+ products,
173
+ promotedProductsIOS,
174
+ subscriptions,
175
+ purchaseHistories,
176
+ finishTransaction,
177
+ availablePurchases,
178
+ currentPurchase,
179
+ currentPurchaseError,
180
+ getProducts: requestProducts,
181
+ getSubscriptions: requestSubscriptions,
182
+ getAvailablePurchases: requestAvailablePurchases,
183
+ getPurchaseHistories: requestPurchaseHistories,
184
+ };
185
+ }
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "expo-iap",
3
- "version": "2.2.0-rc.2",
3
+ "version": "2.2.0-rc.3",
4
4
  "description": "In App Purchase module in Expo",
5
5
  "main": "build/index.js",
6
- "types": "build/index.d.ts",
6
+ "types": "build/index.ts",
7
7
  "scripts": {
8
- "build": "expo-module build",
8
+ "build:compile": "expo-module tsc",
9
+ "build:copy": "mkdir -p build && rsync -a --include '*/' --include '*.ts' --exclude '*' src/ build/",
10
+ "build": "npm run build:compile && npm run build:copy",
11
+ "build:watch": "expo-module build",
9
12
  "clean": "expo-module clean",
10
13
  "lint": "eslint --ext .ts,.tsx,.js,.jsx src",
11
14
  "lint:eslint": "eslint --fix '**/*.{ts,tsx}'",
@@ -13,8 +16,6 @@
13
16
  "lint:tsc": "tsc -p tsconfig.json --noEmit --skipLibCheck",
14
17
  "lint:ci": "yarn lint:tsc && yarn lint:eslint && yarn lint:prettier",
15
18
  "test": "expo-module test",
16
- "prepare": "expo-module prepare",
17
- "prepublishOnly": "expo-module prepublishOnly",
18
19
  "expo-module": "expo-module",
19
20
  "open:ios": "xed example/ios",
20
21
  "open:android": "open -a \"Android Studio\" example/android",
@@ -23,7 +23,6 @@ type SubscriptionInfo = {
23
23
  export type ProductIos = ProductBase & {
24
24
  displayName: string;
25
25
  displayPrice: string;
26
- type: 'autoRenewable' | 'consumable' | 'nonConsumable' | 'nonRenewable'; // Maps to 'type' in base Product
27
26
  isFamilyShareable: boolean;
28
27
  jsonRepresentation: string;
29
28
  subscription: SubscriptionInfo;
package/tsconfig.json CHANGED
@@ -2,7 +2,12 @@
2
2
  {
3
3
  "extends": "expo-module-scripts/tsconfig.base",
4
4
  "compilerOptions": {
5
- "outDir": "./build"
5
+ "outDir": "./build",
6
+ "sourceMap": false,
7
+ "declaration": false,
8
+ "declarationMap": false,
9
+ "inlineSourceMap": false,
10
+ "inlineSources": false
6
11
  },
7
12
  "include": ["./src"],
8
13
  "exclude": ["**/__mocks__/*", "**/__tests__/*"]
@@ -1,80 +0,0 @@
1
- import { ProductAndroid, ProductPurchaseAndroid, RequestPurchaseAndroidProps, RequestSubscriptionAndroidProps, SubscriptionProductAndroid } from './types/ExpoIapAndroid.types';
2
- import { ProductIos, ProductPurchaseIos, RequestPurchaseIosProps, RequestSubscriptionIosProps, SubscriptionProductIos } from './types/ExpoIapIos.types';
3
- export type ChangeEventPayload = {
4
- value: string;
5
- };
6
- /**
7
- * Base product type with common properties shared between iOS and Android
8
- */
9
- export type ProductBase = {
10
- id: string;
11
- title: string;
12
- description: string;
13
- type: ProductType;
14
- displayName?: string;
15
- displayPrice?: string;
16
- price?: number;
17
- currency?: string;
18
- };
19
- export type IosPlatform = {
20
- platform: 'ios';
21
- };
22
- export type AndroidPlatform = {
23
- platform: 'android';
24
- };
25
- export declare enum ProductType {
26
- InAppPurchase = "inapp",
27
- Subscription = "subs"
28
- }
29
- export type PurchaseBase = {
30
- id: string;
31
- transactionId?: string;
32
- transactionDate: number;
33
- transactionReceipt: string;
34
- purchaseToken?: string;
35
- };
36
- export type Product = (ProductAndroid & AndroidPlatform) | (ProductIos & IosPlatform);
37
- export type ProductPurchase = (ProductPurchaseAndroid & AndroidPlatform) | (ProductPurchaseIos & IosPlatform);
38
- export type SubscriptionPurchase = (ProductPurchaseAndroid & AndroidPlatform & {
39
- autoRenewingAndroid: boolean;
40
- }) | (ProductPurchaseIos & IosPlatform);
41
- export type Purchase = ProductPurchase | SubscriptionPurchase;
42
- export type RequestPurchaseProps = RequestPurchaseIosProps | RequestPurchaseAndroidProps;
43
- export type SubscriptionProduct = (SubscriptionProductAndroid & AndroidPlatform) | (SubscriptionProductIos & IosPlatform);
44
- export type RequestSubscriptionProps = RequestSubscriptionAndroidProps | RequestSubscriptionIosProps;
45
- export type PurchaseResult = {
46
- responseCode?: number;
47
- debugMessage?: string;
48
- code?: string;
49
- message?: string;
50
- purchaseToken?: string;
51
- };
52
- export declare enum ErrorCode {
53
- E_UNKNOWN = "E_UNKNOWN",
54
- E_USER_CANCELLED = "E_USER_CANCELLED",
55
- E_USER_ERROR = "E_USER_ERROR",
56
- E_ITEM_UNAVAILABLE = "E_ITEM_UNAVAILABLE",
57
- E_REMOTE_ERROR = "E_REMOTE_ERROR",
58
- E_NETWORK_ERROR = "E_NETWORK_ERROR",
59
- E_SERVICE_ERROR = "E_SERVICE_ERROR",
60
- E_RECEIPT_FAILED = "E_RECEIPT_FAILED",
61
- E_RECEIPT_FINISHED_FAILED = "E_RECEIPT_FINISHED_FAILED",
62
- E_NOT_PREPARED = "E_NOT_PREPARED",
63
- E_NOT_ENDED = "E_NOT_ENDED",
64
- E_ALREADY_OWNED = "E_ALREADY_OWNED",
65
- E_DEVELOPER_ERROR = "E_DEVELOPER_ERROR",
66
- E_BILLING_RESPONSE_JSON_PARSE_ERROR = "E_BILLING_RESPONSE_JSON_PARSE_ERROR",
67
- E_DEFERRED_PAYMENT = "E_DEFERRED_PAYMENT",
68
- E_INTERRUPTED = "E_INTERRUPTED",
69
- E_IAP_NOT_AVAILABLE = "E_IAP_NOT_AVAILABLE"
70
- }
71
- export declare class PurchaseError implements Error {
72
- name: string;
73
- message: string;
74
- responseCode?: number | undefined;
75
- debugMessage?: string | undefined;
76
- code?: ErrorCode | undefined;
77
- productId?: string | undefined;
78
- constructor(name: string, message: string, responseCode?: number | undefined, debugMessage?: string | undefined, code?: ErrorCode | undefined, productId?: string | undefined);
79
- }
80
- //# sourceMappingURL=ExpoIap.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpoIap.types.d.ts","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAA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AI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF","sourcesContent":["import {\n ProductAndroid,\n ProductPurchaseAndroid,\n RequestPurchaseAndroidProps,\n RequestSubscriptionAndroidProps,\n SubscriptionProductAndroid,\n} from './types/ExpoIapAndroid.types';\nimport {\n ProductIos,\n ProductPurchaseIos,\n RequestPurchaseIosProps,\n RequestSubscriptionIosProps,\n SubscriptionProductIos,\n} from './types/ExpoIapIos.types';\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\n/**\n * Base product type with common properties shared between iOS and Android\n */\nexport type ProductBase = {\n id: string;\n title: string;\n description: string;\n type: ProductType;\n displayName?: string;\n displayPrice?: string;\n price?: number;\n currency?: string;\n};\n\n// Define literal platform types for better type discrimination\nexport type IosPlatform = {platform: 'ios'};\nexport type AndroidPlatform = {platform: 'android'};\n\nexport enum ProductType {\n InAppPurchase = 'inapp',\n Subscription = 'subs',\n}\n\n// Common base purchase type\nexport type PurchaseBase = {\n id: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n};\n\n// Union type for platform-specific product types with proper discriminators\nexport type Product =\n | (ProductAndroid & AndroidPlatform)\n | (ProductIos & IosPlatform);\n\n// Union type for platform-specific purchase types with proper discriminators\nexport type ProductPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform)\n | (ProductPurchaseIos & IosPlatform);\n\n// Union type for platform-specific subscription purchase types with proper discriminators\nexport type SubscriptionPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform & { autoRenewingAndroid: boolean })\n | (ProductPurchaseIos & IosPlatform);\n\nexport type Purchase = ProductPurchase | SubscriptionPurchase;\n\nexport type RequestPurchaseProps =\n | RequestPurchaseIosProps\n | RequestPurchaseAndroidProps;\n\nexport type SubscriptionProduct =\n | (SubscriptionProductAndroid & AndroidPlatform)\n | (SubscriptionProductIos & IosPlatform);\n\nexport type RequestSubscriptionProps =\n | RequestSubscriptionAndroidProps\n | RequestSubscriptionIosProps;\n\nexport type PurchaseResult = {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n purchaseToken?: string;\n};\n\nexport enum ErrorCode {\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n E_INTERRUPTED = 'E_INTERRUPTED',\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n}\n\nexport class PurchaseError implements Error {\n constructor(\n public name: string,\n public message: string,\n public responseCode?: number,\n public debugMessage?: string,\n public code?: ErrorCode,\n public productId?: string,\n ) {\n this.name = '[expo-iap]: PurchaseError';\n this.message = message;\n this.responseCode = responseCode;\n this.debugMessage = debugMessage;\n this.code = code;\n this.productId = productId;\n }\n}\n"]}
@@ -1,3 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
3
- //# sourceMappingURL=ExpoIapModule.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpoIapModule.d.ts","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":";AAIA,wBAA8C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpoIapModule.js","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAEtD,kEAAkE;AAClE,4EAA4E;AAC5E,eAAe,mBAAmB,CAAC,SAAS,CAAC,CAAC","sourcesContent":["import {requireNativeModule} from 'expo-modules-core';\n\n// It loads the native module object from the JSI or falls back to\n// the bridge module (from NativeModulesProxy) if the remote debugger is on.\nexport default requireNativeModule('ExpoIap');\n"]}
package/build/index.d.ts DELETED
@@ -1,37 +0,0 @@
1
- import { EventEmitter } from 'expo-modules-core';
2
- import { Product, ProductPurchase, Purchase, PurchaseError, PurchaseResult, RequestSubscriptionProps, SubscriptionProduct, SubscriptionPurchase } from './ExpoIap.types';
3
- import { RequestPurchaseAndroidProps } from './types/ExpoIapAndroid.types';
4
- import { RequestPurchaseIosProps } from './types/ExpoIapIos.types';
5
- export * from './modules/android';
6
- export * from './modules/ios';
7
- export declare const PI: any;
8
- export declare enum IapEvent {
9
- PurchaseUpdated = "purchase-updated",
10
- PurchaseError = "purchase-error",
11
- TransactionIapUpdated = "iap-transaction-updated"
12
- }
13
- export declare function setValueAsync(value: string): Promise<any>;
14
- export declare const emitter: EventEmitter;
15
- export declare const purchaseUpdatedListener: (listener: (event: Purchase) => void) => import("expo-modules-core").Subscription;
16
- export declare const purchaseErrorListener: (listener: (error: PurchaseError) => void) => import("expo-modules-core").Subscription;
17
- export declare function initConnection(): any;
18
- export declare const getProducts: (skus: string[]) => Promise<Product[]>;
19
- export declare const getSubscriptions: (skus: string[]) => Promise<SubscriptionProduct[]>;
20
- export declare function endConnection(): Promise<boolean>;
21
- export declare const getPurchaseHistory: ({ alsoPublishToEventListener, onlyIncludeActiveItems, }?: {
22
- alsoPublishToEventListener?: boolean;
23
- onlyIncludeActiveItems?: boolean;
24
- }) => Promise<ProductPurchase[]>;
25
- export declare const getAvailablePurchases: ({ alsoPublishToEventListener, onlyIncludeActiveItems, }?: {
26
- alsoPublishToEventListener?: boolean;
27
- onlyIncludeActiveItems?: boolean;
28
- }) => Promise<ProductPurchase[]>;
29
- export declare const requestPurchase: (request: RequestPurchaseIosProps | RequestPurchaseAndroidProps) => Promise<ProductPurchase | ProductPurchase[] | void>;
30
- export declare const requestSubscription: (request: RequestSubscriptionProps) => Promise<SubscriptionPurchase | SubscriptionPurchase[] | null | void>;
31
- export declare const finishTransaction: ({ purchase, isConsumable, developerPayloadAndroid, }: {
32
- purchase: Purchase;
33
- isConsumable?: boolean;
34
- developerPayloadAndroid?: string;
35
- }) => Promise<PurchaseResult | boolean>;
36
- export * from './useIap';
37
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EACL,OAAO,EACP,eAAe,EAEf,QAAQ,EACR,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,2BAA2B,EAE5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,uBAAuB,EAExB,MAAM,0BAA0B,CAAC;AAOlC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAG9B,eAAO,MAAM,EAAE,KAAmB,CAAC;AAEnC,oBAAY,QAAQ;IAClB,eAAe,qBAAqB;IACpC,aAAa,mBAAmB;IAChC,qBAAqB,4BAA4B;CAClD;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,gBAEhD;AAED,eAAO,MAAM,OAAO,cAEnB,CAAC;AAEF,eAAO,MAAM,uBAAuB,aACxB,CAAC,KAAK,EAAE,QAAQ,KA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