expo-iap 1.0.3 → 2.0.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.
Files changed (103) hide show
  1. package/.eslintrc.js +9 -0
  2. package/.prettierrc.js +9 -0
  3. package/.swiftlint.yml +10 -0
  4. package/README.md +28 -21
  5. package/android/build.gradle +34 -72
  6. package/android/src/main/AndroidManifest.xml +1 -4
  7. package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +535 -0
  8. package/android/src/main/java/expo/modules/iap/MissingCurrentActivityException.kt +6 -0
  9. package/android/src/main/java/expo/modules/iap/PlayUtils.kt +124 -0
  10. package/build/ExpoIap.types.d.ts +89 -0
  11. package/build/ExpoIap.types.d.ts.map +1 -0
  12. package/build/ExpoIap.types.js +59 -0
  13. package/build/ExpoIap.types.js.map +1 -0
  14. package/build/ExpoIapModule.d.ts +3 -0
  15. package/build/ExpoIapModule.d.ts.map +1 -0
  16. package/build/ExpoIapModule.js +5 -0
  17. package/build/ExpoIapModule.js.map +1 -0
  18. package/build/index.d.ts +38 -0
  19. package/build/index.d.ts.map +1 -0
  20. package/build/index.js +202 -0
  21. package/build/index.js.map +1 -0
  22. package/build/modules/android.d.ts +40 -0
  23. package/build/modules/android.d.ts.map +1 -0
  24. package/build/modules/android.js +54 -0
  25. package/build/modules/android.js.map +1 -0
  26. package/build/modules/ios.d.ts +41 -0
  27. package/build/modules/ios.d.ts.map +1 -0
  28. package/build/modules/ios.js +44 -0
  29. package/build/modules/ios.js.map +1 -0
  30. package/build/types/ExpoIapAndroid.types.d.ts +113 -0
  31. package/build/types/ExpoIapAndroid.types.d.ts.map +1 -0
  32. package/build/types/ExpoIapAndroid.types.js +23 -0
  33. package/build/types/ExpoIapAndroid.types.js.map +1 -0
  34. package/build/types/ExpoIapIos.types.d.ts +122 -0
  35. package/build/types/ExpoIapIos.types.d.ts.map +1 -0
  36. package/build/types/ExpoIapIos.types.js +2 -0
  37. package/build/types/ExpoIapIos.types.js.map +1 -0
  38. package/bun.lockb +0 -0
  39. package/expo-module.config.json +4 -8
  40. package/ios/ExpoIap.podspec +27 -0
  41. package/ios/ExpoIapModule.swift +498 -0
  42. package/ios/ProductStore.swift +27 -0
  43. package/ios/Types.swift +54 -0
  44. package/package.json +33 -62
  45. package/src/ExpoIap.types.ts +125 -0
  46. package/src/ExpoIapModule.ts +5 -0
  47. package/src/index.ts +397 -0
  48. package/src/modules/android.ts +89 -0
  49. package/src/modules/ios.ts +81 -0
  50. package/src/types/ExpoIapAndroid.types.ts +123 -0
  51. package/src/types/ExpoIapIos.types.ts +141 -0
  52. package/tsconfig.json +9 -0
  53. package/.editorconfig +0 -10
  54. package/.flowconfig +0 -11
  55. package/.monolinterrc +0 -3
  56. package/.yarn/install-state.gz +0 -0
  57. package/.yarn/releases/yarn-3.1.1.cjs +0 -768
  58. package/.yarnrc.yml +0 -3
  59. package/LICENSE +0 -21
  60. package/RNIap.podspec +0 -18
  61. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  62. package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
  63. package/android/gradle.properties +0 -2
  64. package/android/gradlew +0 -160
  65. package/android/gradlew.bat +0 -90
  66. package/android/libs/in-app-purchasing-2.0.76.jar +0 -0
  67. package/android/src/amazon/AndroidManifest.xml +0 -12
  68. package/android/src/amazon/java/com/dooboolab/RNIap/RNIapAmazonListener.kt +0 -356
  69. package/android/src/amazon/java/com/dooboolab/RNIap/RNIapAmazonModule.kt +0 -128
  70. package/android/src/amazon/java/com/dooboolab/RNIap/RNIapPackage.kt +0 -20
  71. package/android/src/main/java/com/dooboolab/RNIap/DoobooUtils.kt +0 -180
  72. package/android/src/play/java/com/dooboolab/RNIap/PlayUtils.kt +0 -77
  73. package/android/src/play/java/com/dooboolab/RNIap/RNIapModule.kt +0 -698
  74. package/android/src/play/java/com/dooboolab/RNIap/RNIapPackage.kt +0 -20
  75. package/babel.config.js +0 -10
  76. package/index.d.ts +0 -3
  77. package/index.js +0 -3
  78. package/index.js.flow +0 -9
  79. package/ios/RNIap.xcodeproj/project.pbxproj +0 -370
  80. package/ios/RNIap.xcodeproj/xcshareddata/xcschemes/RNIap.xcscheme +0 -80
  81. package/ios/RNIapIos.m +0 -60
  82. package/ios/RNIapIos.swift +0 -932
  83. package/ios/RNIapQueue.swift +0 -35
  84. package/jest.config.js +0 -194
  85. package/src/__test__/iap.test.d.ts +0 -1
  86. package/src/__test__/iap.test.js +0 -59
  87. package/src/hooks/useIAP.d.ts +0 -21
  88. package/src/hooks/useIAP.js +0 -140
  89. package/src/hooks/withIAPContext.d.ts +0 -21
  90. package/src/hooks/withIAPContext.js +0 -142
  91. package/src/iap.d.ts +0 -197
  92. package/src/iap.js +0 -625
  93. package/src/index.d.ts +0 -4
  94. package/src/index.js +0 -4
  95. package/src/types/amazon.d.ts +0 -23
  96. package/src/types/amazon.js +0 -1
  97. package/src/types/android.d.ts +0 -47
  98. package/src/types/android.js +0 -22
  99. package/src/types/apple.d.ts +0 -424
  100. package/src/types/apple.js +0 -165
  101. package/src/types/index.d.ts +0 -117
  102. package/src/types/index.js +0 -40
  103. package/test/mocks/react-native-modules.js +0 -14
package/src/iap.d.ts DELETED
@@ -1,197 +0,0 @@
1
- import * as Amazon from './types/amazon';
2
- import * as Android from './types/android';
3
- import * as Apple from './types/apple';
4
- import { EmitterSubscription } from 'react-native';
5
- import { InAppPurchase, InstallSourceAndroid, Product, ProductPurchase, ProrationModesAndroid, PurchaseError, PurchaseResult, Subscription, SubscriptionPurchase } from './types';
6
- export declare const getInstallSourceAndroid: () => InstallSourceAndroid;
7
- /**
8
- * Init module for purchase flow. Required on Android. In ios it will check wheter user canMakePayment.
9
- * @returns {Promise<boolean>}
10
- */
11
- export declare const initConnection: () => Promise<boolean>;
12
- /**
13
- * End module for purchase flow.
14
- * @returns {Promise<void>}
15
- */
16
- export declare const endConnection: () => Promise<void>;
17
- /**
18
- * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.
19
- * @returns {Promise<boolean>}
20
- */
21
- export declare const flushFailedPurchasesCachedAsPendingAndroid: () => Promise<string[]>;
22
- /**
23
- * Get a list of products (consumable and non-consumable items, but not subscriptions)
24
- * @param {string[]} skus The item skus
25
- * @returns {Promise<Product[]>}
26
- */
27
- export declare const getProducts: (skus: string[]) => Promise<Array<Product>>;
28
- /**
29
- * Get a list of subscriptions
30
- * @param {string[]} skus The item skus
31
- * @returns {Promise<Subscription[]>}
32
- */
33
- export declare const getSubscriptions: (skus: string[]) => Promise<Subscription[]>;
34
- /**
35
- * Gets an inventory of purchases made by the user regardless of consumption status
36
- * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}
37
- */
38
- export declare const getPurchaseHistory: () => Promise<(InAppPurchase | SubscriptionPurchase)[]>;
39
- /**
40
- * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)
41
- * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}
42
- */
43
- export declare const getAvailablePurchases: () => Promise<(InAppPurchase | SubscriptionPurchase)[]>;
44
- /**
45
- * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
46
- * @param {string} sku The product's sku/ID
47
- * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.
48
- * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
49
- * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
50
- * @returns {Promise<InAppPurchase>}
51
- */
52
- export declare const requestPurchase: (sku: string, andDangerouslyFinishTransactionAutomaticallyIOS?: boolean, obfuscatedAccountIdAndroid?: string | undefined, obfuscatedProfileIdAndroid?: string | undefined) => Promise<InAppPurchase>;
53
- /**
54
- * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
55
- * @param {string} [sku] The product's sku/ID
56
- * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.
57
- * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).
58
- * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED
59
- * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
60
- * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
61
- * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise
62
- */
63
- export declare const requestSubscription: (sku: string, andDangerouslyFinishTransactionAutomaticallyIOS?: boolean, purchaseTokenAndroid?: string | undefined, prorationModeAndroid?: ProrationModesAndroid, obfuscatedAccountIdAndroid?: string | undefined, obfuscatedProfileIdAndroid?: string | undefined) => Promise<SubscriptionPurchase | null>;
64
- /**
65
- * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
66
- * @param {string} sku The product's sku/ID
67
- * @returns {Promise<void>}
68
- */
69
- export declare const requestPurchaseWithQuantityIOS: (sku: string, quantity: number) => Promise<InAppPurchase>;
70
- /**
71
- * Finish Transaction (both platforms)
72
- * Abstracts Finish Transaction
73
- * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.
74
- * Call this after you have persisted the purchased state to your server or local data in your app.
75
- * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**
76
- * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.
77
- * @param {object} purchase The purchase that you would like to finish.
78
- * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.
79
- * @param {string} developerPayloadAndroid Android developerPayload.
80
- * @returns {Promise<string | void> }
81
- */
82
- export declare const finishTransaction: (purchase: InAppPurchase | ProductPurchase, isConsumable?: boolean | undefined, developerPayloadAndroid?: string | undefined) => Promise<string | void>;
83
- /**
84
- * Clear Transaction (iOS only)
85
- * Finish remaining transactions. Related to issue #257 and #801
86
- * link : https://github.com/dooboolab/react-native-iap/issues/257
87
- * https://github.com/dooboolab/react-native-iap/issues/801
88
- * @returns {Promise<void>}
89
- */
90
- export declare const clearTransactionIOS: () => Promise<void>;
91
- /**
92
- * Clear valid Products (iOS only)
93
- * Remove all products which are validated by Apple server.
94
- * @returns {void}
95
- */
96
- export declare const clearProductsIOS: () => Promise<void>;
97
- /**
98
- * Acknowledge a product (on Android.) No-op on iOS.
99
- * @param {string} token The product's token (on Android)
100
- * @returns {Promise<PurchaseResult | void>}
101
- */
102
- export declare const acknowledgePurchaseAndroid: (token: string, developerPayload?: string | undefined) => Promise<PurchaseResult | void>;
103
- /**
104
- * Deep link to subscriptions screen on Android. No-op on iOS.
105
- * @param {string} sku The product's SKU (on Android)
106
- * @returns {Promise<void>}
107
- */
108
- export declare const deepLinkToSubscriptionsAndroid: (sku: string) => Promise<void>;
109
- /**
110
- * Should Add Store Payment (iOS only)
111
- * Indicates the the App Store purchase should continue from the app instead of the App Store.
112
- * @returns {Promise<Product | null>} promoted product
113
- */
114
- export declare const getPromotedProductIOS: () => Promise<Product | null>;
115
- /**
116
- * Buy the currently selected promoted product (iOS only)
117
- * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.
118
- * @returns {Promise<void>}
119
- */
120
- export declare const buyPromotedProductIOS: () => Promise<void>;
121
- /**
122
- * Buy products or subscriptions with offers (iOS only)
123
- *
124
- * Runs the payment process with some infor you must fetch
125
- * from your server.
126
- * @param {string} sku The product identifier
127
- * @param {string} forUser An user identifier on you system
128
- * @param {Apple.PaymentDiscount} withOffer The offer information
129
- * @param {string} withOffer.identifier The offer identifier
130
- * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature
131
- * @param {string} withOffer.nonce An UUID returned from the server
132
- * @param {string} withOffer.signature The actual signature returned from the server
133
- * @param {number} withOffer.timestamp The timestamp of the signature
134
- * @returns {Promise<void>}
135
- */
136
- export declare const requestPurchaseWithOfferIOS: (sku: string, forUser: string, withOffer: Apple.PaymentDiscount) => Promise<void>;
137
- /**
138
- * Validate receipt for iOS.
139
- * @param {object} receiptBody the receipt body to send to apple server.
140
- * @param {boolean} isTest whether this is in test environment which is sandbox.
141
- * @returns {Promise<Apple.ReceiptValidationResponse | false>}
142
- */
143
- export declare const validateReceiptIos: (receiptBody: Record<string, unknown>, isTest?: boolean | undefined) => Promise<Apple.ReceiptValidationResponse | false>;
144
- /**
145
- * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including
146
- * your access token in the binary you ship to users is potentially dangerous.
147
- * Use server side validation instead for your production builds
148
- * @param {string} packageName package name of your app.
149
- * @param {string} productId product id for your in app product.
150
- * @param {string} productToken token for your purchase.
151
- * @param {string} accessToken accessToken from googleApis.
152
- * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.
153
- * @returns {Promise<object>}
154
- */
155
- export declare const validateReceiptAndroid: (packageName: string, productId: string, productToken: string, accessToken: string, isSub?: boolean | undefined) => Promise<Android.ReceiptType>;
156
- /**
157
- * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including
158
- * your developer secret in the binary you ship to users is potentially dangerous.
159
- * Use server side validation instead for your production builds
160
- * @param {string} developerSecret: from the Amazon developer console.
161
- * @param {string} userId who purchased the item.
162
- * @param {string} receiptId long obfuscated string returned when purchasing the item
163
- * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.
164
- * @returns {Promise<object>}
165
- */
166
- export declare const validateReceiptAmazon: (developerSecret: string, userId: string, receiptId: string, useSandbox?: boolean) => Promise<Amazon.ReceiptType>;
167
- /**
168
- * Add IAP purchase event
169
- * @returns {callback(e: InAppPurchase | ProductPurchase)}
170
- */
171
- export declare const purchaseUpdatedListener: (listener: (event: InAppPurchase | SubscriptionPurchase) => void) => EmitterSubscription;
172
- /**
173
- * Add IAP purchase error event
174
- * @returns {callback(e: PurchaseError)}
175
- */
176
- export declare const purchaseErrorListener: (listener: (errorEvent: PurchaseError) => void) => EmitterSubscription;
177
- /**
178
- * Get the current receipt base64 encoded in IOS.
179
- * @param {forceRefresh?:boolean}
180
- * @returns {Promise<string>}
181
- */
182
- export declare const getReceiptIOS: (forceRefresh?: boolean | undefined) => Promise<string>;
183
- /**
184
- * Get the pending purchases in IOS.
185
- * @returns {Promise<ProductPurchase[]>}
186
- */
187
- export declare const getPendingPurchasesIOS: () => Promise<ProductPurchase[]>;
188
- /**
189
- * Launches a modal to register the redeem offer code in IOS.
190
- * @returns {Promise<null>}
191
- */
192
- export declare const presentCodeRedemptionSheetIOS: () => Promise<null>;
193
- /**
194
- * Checks if the internal client is ready to be used (Android only)
195
- * @returns {Promise<boolean>}
196
- */
197
- export declare const isReadyAndroid: () => Promise<boolean>;