expo-iap 5.3.0 → 5.3.2
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 → AGENTS.md} +1 -3
- package/CONTRIBUTING.md +5 -12
- package/README.md +3 -3
- package/android/src/main/java/expo/modules/iap/ExpoIapHelper.kt +87 -39
- package/android/src/main/java/expo/modules/iap/ExpoIapLog.kt +4 -0
- package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +35 -27
- package/build/index.d.ts.map +1 -1
- package/build/index.js +65 -30
- package/build/index.js.map +1 -1
- package/build/index.kepler.d.ts.map +1 -1
- package/build/index.kepler.js +9 -1
- package/build/index.kepler.js.map +1 -1
- package/build/kit-api.d.ts +119 -2
- package/build/kit-api.d.ts.map +1 -1
- package/build/kit-api.js +3 -1
- package/build/kit-api.js.map +1 -1
- package/build/types.d.ts +33 -9
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/vega-adapter.d.ts.map +1 -1
- package/build/vega-adapter.js +5 -6
- package/build/vega-adapter.js.map +1 -1
- package/bun.lock +421 -1139
- package/ios/ExpoIapHelper.swift +80 -17
- package/ios/ExpoIapLog.swift +6 -6
- package/ios/ExpoIapModule.swift +20 -7
- package/ios/onside/OnsideIapModule.swift +28 -56
- package/openiap-versions.json +3 -3
- package/osv-scanner.toml +9 -0
- package/package.json +8 -2
- package/plugin/build/withVega.js +10 -0
- package/plugin/src/withVega.ts +10 -0
- package/src/index.kepler.ts +9 -1
- package/src/index.ts +54 -9
- package/src/kit-api.ts +125 -4
- package/src/types.ts +34 -9
- package/src/vega-adapter.ts +6 -11
- package/tests/ios/ExpoIapLogTests.swift +37 -0
package/{CLAUDE.md → AGENTS.md}
RENAMED
|
@@ -24,9 +24,7 @@
|
|
|
24
24
|
- See issue: [#168](https://github.com/hyochan/expo-iap/issues/168)
|
|
25
25
|
- This is kept at `13.4` for compatibility with affected Expo SDKs
|
|
26
26
|
- The actual iOS 15.0+ requirement is enforced at build time via @available annotations
|
|
27
|
-
- Users must follow the deployment target required by their Expo SDK. The
|
|
28
|
-
validated Expo SDK 57 example uses iOS 16.4; older supported SDKs must never
|
|
29
|
-
go below the module's iOS 15.0 runtime requirement.
|
|
27
|
+
- Users must follow the deployment target required by their Expo SDK. The validated Expo SDK 57 example uses iOS 16.4; older supported SDKs must never go below the module's iOS 15.0 runtime requirement.
|
|
30
28
|
|
|
31
29
|
**tvOS Exception**: tvOS platform version MUST be `16.0` (not `13.4`) because:
|
|
32
30
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -48,14 +48,12 @@ This project includes VSCode configurations for easier development:
|
|
|
48
48
|
1. **Install recommended extensions**: When you open the project in VSCode, you'll be prompted to install recommended extensions. Accept to install them.
|
|
49
49
|
|
|
50
50
|
1. **Use Debug Configurations**: Press `F5` or go to Run → Start Debugging and select:
|
|
51
|
-
|
|
52
51
|
- `Debug iOS (Expo)` - Runs the example app on iOS simulator
|
|
53
52
|
- `Debug Android (Expo)` - Runs the example app on Android emulator
|
|
54
53
|
- `iOS + Metro` - Starts Metro bundler and iOS app together
|
|
55
54
|
- `Android + Metro` - Starts Metro bundler and Android app together
|
|
56
55
|
|
|
57
56
|
1. **Use Tasks**: Press `Cmd+Shift+P` → `Tasks: Run Task` to access:
|
|
58
|
-
|
|
59
57
|
- `Start iOS Simulator` - Opens iOS Simulator
|
|
60
58
|
- `Start Android Emulator` - Starts Android emulator
|
|
61
59
|
- `Install Pods (iOS)` - Installs CocoaPods dependencies
|
|
@@ -207,7 +205,7 @@ bun run reset-project
|
|
|
207
205
|
|
|
208
206
|
### Code Conventions and Standards
|
|
209
207
|
|
|
210
|
-
For detailed code conventions, naming standards, and implementation guidelines, please refer to [
|
|
208
|
+
For detailed code conventions, naming standards, and implementation guidelines, please refer to [AGENTS.md](./AGENTS.md). This includes:
|
|
211
209
|
|
|
212
210
|
- Platform-specific naming conventions
|
|
213
211
|
- API method naming patterns
|
|
@@ -245,25 +243,21 @@ If the JSON file is missing or malformed, build scripts (Gradle, Podspec, the ty
|
|
|
245
243
|
### Development Workflow
|
|
246
244
|
|
|
247
245
|
1. **Before starting work**:
|
|
248
|
-
|
|
249
246
|
- Pull latest changes from main branch
|
|
250
247
|
- Create a feature branch: `git checkout -b feature/your-feature`
|
|
251
|
-
- Review [
|
|
248
|
+
- Review [AGENTS.md](./AGENTS.md) for coding standards
|
|
252
249
|
|
|
253
250
|
1. **During development**:
|
|
254
|
-
|
|
255
251
|
- Make changes to the library source code in `src/`
|
|
256
252
|
- Test changes in the example app
|
|
257
253
|
- Write/update tests as needed
|
|
258
254
|
- Keep commits atomic and well-described
|
|
259
255
|
|
|
260
256
|
1. **Before committing**:
|
|
261
|
-
|
|
262
|
-
- Follow the pre-commit checks outlined in [CLAUDE.md](./CLAUDE.md)
|
|
257
|
+
- Follow the pre-commit checks outlined in [AGENTS.md](./AGENTS.md)
|
|
263
258
|
- Ensure all checks pass
|
|
264
259
|
|
|
265
260
|
1. **Testing your changes**:
|
|
266
|
-
|
|
267
261
|
- The example app automatically uses the local library code
|
|
268
262
|
- Changes to `src/` will be reflected after reloading the app
|
|
269
263
|
- Test on both iOS and Android platforms when possible
|
|
@@ -277,13 +271,13 @@ For all code conventions including:
|
|
|
277
271
|
- API method naming patterns
|
|
278
272
|
- OpenIAP specification compliance
|
|
279
273
|
|
|
280
|
-
Please refer to [
|
|
274
|
+
Please refer to [AGENTS.md](./AGENTS.md).
|
|
281
275
|
|
|
282
276
|
### AI Development Tools
|
|
283
277
|
|
|
284
278
|
We provide configuration files for AI-powered development tools:
|
|
285
279
|
|
|
286
|
-
- `
|
|
280
|
+
- `AGENTS.md` - Shared guidelines for AI assistants
|
|
287
281
|
- `.cursorrules` - Rules for Cursor IDE
|
|
288
282
|
- `.copilot-instructions.md` - Instructions for GitHub Copilot
|
|
289
283
|
|
|
@@ -410,7 +404,6 @@ Closes #123
|
|
|
410
404
|
1. Commit your changes with a descriptive message
|
|
411
405
|
1. Push to your fork
|
|
412
406
|
1. Create a Pull Request with:
|
|
413
|
-
|
|
414
407
|
- Clear description of changes
|
|
415
408
|
- Any breaking changes noted
|
|
416
409
|
- Tests for new functionality
|
package/README.md
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
[](https://npmjs.org/package/expo-iap) [](https://npmjs.org/package/expo-iap) [](https://openiap.dev) [](https://github.com/hyodotdev/openiap/actions/workflows/ci-expo-iap.yml?query=branch%3Amain) [](https://app.codecov.io/gh/hyodotdev/openiap/tree/main/libraries/expo-iap) [](https://app.fossa.com/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap?ref=badge_shield&issueType=license)
|
|
7
7
|
|
|
8
|
-
Expo IAP is a powerful in-app purchase solution for Expo and React Native applications that conforms to the
|
|
8
|
+
Expo IAP is a powerful in-app purchase solution for Expo and React Native applications that conforms to the OpenIAP specification. It provides a unified API for handling in-app purchases across iOS and Android platforms with comprehensive error handling and modern TypeScript support.
|
|
9
9
|
|
|
10
10
|
If you're shipping an app with expo-iap, we’d love to hear about it—please share your product and feedback in [expo-iap Q&A Discussions](https://github.com/hyodotdev/openiap/discussions/categories/expo-iap). Community stories help us keep improving the ecosystem.
|
|
11
11
|
|
|
12
|
-
<a href="https://openiap.dev"><img src="https://raw.githubusercontent.com/hyodotdev/openiap/main/logo.
|
|
12
|
+
<a href="https://openiap.dev"><img src="https://raw.githubusercontent.com/hyodotdev/openiap/main/logo.webp" alt="OpenIAP" height="40" /></a>
|
|
13
13
|
|
|
14
14
|
</div>
|
|
15
15
|
|
|
@@ -64,7 +64,7 @@ For detailed usage examples and error handling, see the [documentation](https://
|
|
|
64
64
|
|
|
65
65
|
## Powered by OpenIAP
|
|
66
66
|
|
|
67
|
-
<a href="https://openiap.dev"><img src="https://raw.githubusercontent.com/hyodotdev/openiap/main/logo.
|
|
67
|
+
<a href="https://openiap.dev"><img src="https://raw.githubusercontent.com/hyodotdev/openiap/main/logo.webp" alt="OpenIAP" height="50" /></a>
|
|
68
68
|
|
|
69
69
|
Expo IAP conforms to the **[OpenIAP specification](https://openiap.dev)** — an open, vendor-neutral interoperability standard for in-app purchases. OpenIAP provides:
|
|
70
70
|
|
|
@@ -75,6 +75,14 @@ object ExpoIapHelper {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
fun parsePurchaseProductQueryType(rawType: String?): ProductQueryType {
|
|
79
|
+
val type = parseProductQueryType(rawType)
|
|
80
|
+
require(type != ProductQueryType.All) {
|
|
81
|
+
"Product type all is only supported for product queries."
|
|
82
|
+
}
|
|
83
|
+
return type
|
|
84
|
+
}
|
|
85
|
+
|
|
78
86
|
internal fun parseDeepLinkSubscriptionParams(params: Map<String, Any?>): DeepLinkSubscriptionParams {
|
|
79
87
|
return DeepLinkSubscriptionParams(
|
|
80
88
|
sku = params["skuAndroid"] as? String,
|
|
@@ -87,43 +95,93 @@ object ExpoIapHelper {
|
|
|
87
95
|
// before parsing the native request.
|
|
88
96
|
val effective: Map<String, Any?> =
|
|
89
97
|
run {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
flat
|
|
104
|
-
}
|
|
105
|
-
|
|
98
|
+
if (params.containsKey("request")) {
|
|
99
|
+
val request = params["request"]
|
|
100
|
+
require(request is Map<*, *>) { "request must be an object" }
|
|
101
|
+
val nested = request["google"]
|
|
102
|
+
require(nested is Map<*, *> && nested.keys.all { it is String }) {
|
|
103
|
+
"request.google must be an object with string keys"
|
|
104
|
+
}
|
|
105
|
+
require(!nested.containsKey("type")) {
|
|
106
|
+
"type must be provided only at the purchase envelope"
|
|
107
|
+
}
|
|
108
|
+
val flat = mutableMapOf<String, Any?>()
|
|
109
|
+
// Carry over top-level fields such as the purchase type.
|
|
110
|
+
for ((k, v) in params) {
|
|
111
|
+
if (k != "request") flat[k] = v
|
|
112
|
+
}
|
|
113
|
+
// Overlay platform-specific fields.
|
|
114
|
+
for ((k, v) in nested) {
|
|
115
|
+
flat[k as String] = v
|
|
106
116
|
}
|
|
117
|
+
flat
|
|
107
118
|
} else {
|
|
108
119
|
params
|
|
109
120
|
}
|
|
110
121
|
}
|
|
111
122
|
|
|
123
|
+
require(effective["type"] == null || effective["type"] is String) {
|
|
124
|
+
"type must be a string"
|
|
125
|
+
}
|
|
126
|
+
effective["skus"]?.let { rawSkus ->
|
|
127
|
+
require(rawSkus is List<*> && rawSkus.all { it is String && it.isNotBlank() }) {
|
|
128
|
+
"skus must contain only non-empty strings"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
for (key in listOf(
|
|
132
|
+
"obfuscatedAccountId",
|
|
133
|
+
"obfuscatedProfileId",
|
|
134
|
+
"purchaseToken",
|
|
135
|
+
"originalExternalTransactionId",
|
|
136
|
+
"offerToken",
|
|
137
|
+
)) {
|
|
138
|
+
require(effective[key] == null || effective[key] is String) { "$key must be a string" }
|
|
139
|
+
}
|
|
140
|
+
require(effective["isOfferPersonalized"] == null || effective["isOfferPersonalized"] is Boolean) {
|
|
141
|
+
"isOfferPersonalized must be a boolean"
|
|
142
|
+
}
|
|
143
|
+
for (key in listOf("developerBillingOption", "subscriptionProductReplacementParams")) {
|
|
144
|
+
effective[key]?.let { value ->
|
|
145
|
+
require(value is Map<*, *> && value.keys.all { it is String }) {
|
|
146
|
+
"$key must be an object with string keys"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
effective["subscriptionOffers"]?.let { rawOffers ->
|
|
151
|
+
require(rawOffers is List<*>) { "subscriptionOffers must be a list" }
|
|
152
|
+
require(rawOffers.all { rawOffer ->
|
|
153
|
+
val offer = rawOffer as? Map<*, *> ?: return@all false
|
|
154
|
+
val sku = offer["sku"] as? String
|
|
155
|
+
val token = offer["offerToken"] as? String
|
|
156
|
+
offer.keys.all { it is String } && !sku.isNullOrBlank() && !token.isNullOrBlank()
|
|
157
|
+
}) { "subscriptionOffers must contain valid sku and offerToken strings" }
|
|
158
|
+
}
|
|
159
|
+
|
|
112
160
|
val type = effective["type"] as? String
|
|
113
|
-
val
|
|
161
|
+
val purchaseType = parsePurchaseProductQueryType(type)
|
|
162
|
+
val subscriptionOnlyFields = listOf(
|
|
163
|
+
"subscriptionOffers",
|
|
164
|
+
"subscriptionProductReplacementParams",
|
|
165
|
+
"purchaseToken",
|
|
166
|
+
"originalExternalTransactionId",
|
|
167
|
+
)
|
|
168
|
+
require(
|
|
169
|
+
purchaseType != ProductQueryType.InApp ||
|
|
170
|
+
subscriptionOnlyFields.none { effective[it] != null },
|
|
171
|
+
) { "Subscription options require product type subs" }
|
|
172
|
+
require(purchaseType != ProductQueryType.Subs || effective["offerToken"] == null) {
|
|
173
|
+
"offerToken requires product type in-app"
|
|
174
|
+
}
|
|
175
|
+
val skus = (effective["skus"] as? List<*>)?.map { it as String } ?: emptyList()
|
|
114
176
|
val obfuscatedAccountId = effective["obfuscatedAccountId"] as? String
|
|
115
177
|
val obfuscatedProfileId = effective["obfuscatedProfileId"] as? String
|
|
116
178
|
val isOfferPersonalized = effective["isOfferPersonalized"] as? Boolean ?: false
|
|
117
179
|
val explicitSubscriptionOffers =
|
|
118
|
-
(effective["subscriptionOffers"] as? List<*>)?.
|
|
119
|
-
val offerMap = rawOffer as
|
|
120
|
-
val sku = offerMap["sku"] as
|
|
121
|
-
val offerToken = offerMap["offerToken"] as
|
|
122
|
-
|
|
123
|
-
null
|
|
124
|
-
} else {
|
|
125
|
-
AndroidSubscriptionOfferInput(offerToken = offerToken, sku = sku)
|
|
126
|
-
}
|
|
180
|
+
(effective["subscriptionOffers"] as? List<*>)?.map { rawOffer ->
|
|
181
|
+
val offerMap = rawOffer as Map<*, *>
|
|
182
|
+
val sku = offerMap["sku"] as String
|
|
183
|
+
val offerToken = offerMap["offerToken"] as String
|
|
184
|
+
AndroidSubscriptionOfferInput(offerToken = offerToken, sku = sku)
|
|
127
185
|
} ?: emptyList()
|
|
128
186
|
val purchaseToken = effective["purchaseToken"] as? String
|
|
129
187
|
val originalExternalTransactionId = effective["originalExternalTransactionId"] as? String
|
|
@@ -131,23 +189,13 @@ object ExpoIapHelper {
|
|
|
131
189
|
(effective["developerBillingOption"] as? Map<*, *>)?.let { optionMap ->
|
|
132
190
|
val json =
|
|
133
191
|
optionMap.entries
|
|
134
|
-
.
|
|
135
|
-
(key as? String)?.let { it to value }
|
|
136
|
-
}.toMap()
|
|
192
|
+
.associate { (key, value) -> key as String to value }
|
|
137
193
|
DeveloperBillingOptionParamsAndroid.fromJson(json)
|
|
138
194
|
}
|
|
139
195
|
val subscriptionProductReplacementParams =
|
|
140
196
|
(effective["subscriptionProductReplacementParams"] as? Map<*, *>)?.let { paramsMap ->
|
|
141
|
-
val
|
|
142
|
-
|
|
143
|
-
if (oldProductId.isNullOrEmpty() || replacementModeStr.isNullOrEmpty()) {
|
|
144
|
-
null
|
|
145
|
-
} else {
|
|
146
|
-
SubscriptionProductReplacementParamsAndroid(
|
|
147
|
-
oldProductId = oldProductId,
|
|
148
|
-
replacementMode = parseSubscriptionReplacementMode(replacementModeStr),
|
|
149
|
-
)
|
|
150
|
-
}
|
|
197
|
+
val json = paramsMap.entries.associate { (key, value) -> key as String to value }
|
|
198
|
+
SubscriptionProductReplacementParamsAndroid.fromJson(json)
|
|
151
199
|
}
|
|
152
200
|
// offerToken for one-time purchase discounts (Android 8.0+)
|
|
153
201
|
val offerToken = effective["offerToken"] as? String
|
|
@@ -110,6 +110,10 @@ internal object ExpoIapLog {
|
|
|
110
110
|
val sanitized = linkedMapOf<String, Any?>()
|
|
111
111
|
for ((rawKey, rawValue) in source) {
|
|
112
112
|
val key = rawKey as? String ?: continue
|
|
113
|
+
if (rawValue == null || rawValue === JSONObject.NULL) {
|
|
114
|
+
sanitized[key] = JSONObject.NULL
|
|
115
|
+
continue
|
|
116
|
+
}
|
|
113
117
|
if (isSensitiveKey(key)) {
|
|
114
118
|
sanitized[key] = "hidden"
|
|
115
119
|
continue
|
|
@@ -20,6 +20,7 @@ import dev.hyo.openiap.RequestPurchaseResultPurchases
|
|
|
20
20
|
import dev.hyo.openiap.RequestSubscriptionAndroidProps
|
|
21
21
|
import dev.hyo.openiap.RequestSubscriptionPropsByPlatforms
|
|
22
22
|
import dev.hyo.openiap.VerifyPurchaseGoogleOptions
|
|
23
|
+
import dev.hyo.openiap.VerifyPurchaseHorizonOptions
|
|
23
24
|
import dev.hyo.openiap.VerifyPurchaseProps
|
|
24
25
|
import dev.hyo.openiap.VerifyPurchaseWithProviderProps
|
|
25
26
|
import dev.hyo.openiap.store.OpenIapStore
|
|
@@ -73,6 +74,31 @@ internal fun deliverPurchaseRequestFailure(
|
|
|
73
74
|
rejectPendingPromises(errorCode, errorEnvelope)
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
@Suppress("UNCHECKED_CAST")
|
|
78
|
+
internal fun verifyPurchasePropsFromMap(params: Map<String, Any?>): VerifyPurchaseProps {
|
|
79
|
+
fun requiredOption(options: Map<String, Any?>, scope: String, field: String): String =
|
|
80
|
+
(options[field] as? String)?.takeIf { it.isNotEmpty() }
|
|
81
|
+
?: throw IllegalArgumentException("Missing or empty required parameter: $scope.$field")
|
|
82
|
+
|
|
83
|
+
val googleOptions = (params["google"] as? Map<String, Any?>)?.let { options ->
|
|
84
|
+
VerifyPurchaseGoogleOptions(
|
|
85
|
+
sku = requiredOption(options, "google", "sku"),
|
|
86
|
+
accessToken = requiredOption(options, "google", "accessToken"),
|
|
87
|
+
packageName = requiredOption(options, "google", "packageName"),
|
|
88
|
+
purchaseToken = requiredOption(options, "google", "purchaseToken"),
|
|
89
|
+
isSub = options["isSub"] as? Boolean,
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
val horizonOptions = (params["horizon"] as? Map<String, Any?>)?.let { options ->
|
|
93
|
+
VerifyPurchaseHorizonOptions(
|
|
94
|
+
sku = requiredOption(options, "horizon", "sku"),
|
|
95
|
+
userId = requiredOption(options, "horizon", "userId"),
|
|
96
|
+
accessToken = requiredOption(options, "horizon", "accessToken"),
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
return VerifyPurchaseProps(google = googleOptions, horizon = horizonOptions)
|
|
100
|
+
}
|
|
101
|
+
|
|
76
102
|
class ExpoIapModule : Module() {
|
|
77
103
|
companion object {
|
|
78
104
|
const val TAG = "ExpoIapModule"
|
|
@@ -348,7 +374,7 @@ class ExpoIapModule : Module() {
|
|
|
348
374
|
val parsedParams = ExpoIapHelper.parseRequestPurchaseParams(params)
|
|
349
375
|
|
|
350
376
|
val productType =
|
|
351
|
-
when (ExpoIapHelper.
|
|
377
|
+
when (ExpoIapHelper.parsePurchaseProductQueryType(parsedParams.type)) {
|
|
352
378
|
ProductQueryType.Subs -> ProductQueryType.Subs
|
|
353
379
|
else -> ProductQueryType.InApp
|
|
354
380
|
}
|
|
@@ -497,35 +523,17 @@ class ExpoIapModule : Module() {
|
|
|
497
523
|
}
|
|
498
524
|
}
|
|
499
525
|
|
|
500
|
-
@Suppress("UNCHECKED_CAST")
|
|
501
526
|
AsyncFunction("verifyPurchase") { params: Map<String, Any?>, promise: Promise ->
|
|
502
|
-
ExpoIapLog.payload(
|
|
527
|
+
ExpoIapLog.payload(
|
|
528
|
+
"verifyPurchase",
|
|
529
|
+
mapOf(
|
|
530
|
+
"hasGoogle" to (params["google"] != null),
|
|
531
|
+
"hasHorizon" to (params["horizon"] != null),
|
|
532
|
+
),
|
|
533
|
+
)
|
|
503
534
|
scope.launch {
|
|
504
535
|
try {
|
|
505
|
-
val
|
|
506
|
-
(params["google"] as? Map<String, Any?>)?.let { opts ->
|
|
507
|
-
VerifyPurchaseGoogleOptions(
|
|
508
|
-
sku =
|
|
509
|
-
(opts["sku"] as? String)?.takeIf { it.isNotEmpty() }
|
|
510
|
-
?: throw IllegalArgumentException("Missing or empty required parameter: google.sku"),
|
|
511
|
-
accessToken =
|
|
512
|
-
(opts["accessToken"] as? String)?.takeIf { it.isNotEmpty() }
|
|
513
|
-
?: throw IllegalArgumentException("Missing or empty required parameter: google.accessToken"),
|
|
514
|
-
packageName =
|
|
515
|
-
(opts["packageName"] as? String)?.takeIf { it.isNotEmpty() }
|
|
516
|
-
?: throw IllegalArgumentException("Missing or empty required parameter: google.packageName"),
|
|
517
|
-
purchaseToken =
|
|
518
|
-
(opts["purchaseToken"] as? String)?.takeIf { it.isNotEmpty() }
|
|
519
|
-
?: throw IllegalArgumentException("Missing or empty required parameter: google.purchaseToken"),
|
|
520
|
-
isSub = opts["isSub"] as? Boolean,
|
|
521
|
-
)
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
val props =
|
|
525
|
-
VerifyPurchaseProps(
|
|
526
|
-
google = googleOptions,
|
|
527
|
-
)
|
|
528
|
-
|
|
536
|
+
val props = verifyPurchasePropsFromMap(params)
|
|
529
537
|
val result = openIap.verifyPurchase(props)
|
|
530
538
|
val resultMap = result.toJson()
|
|
531
539
|
ExpoIapLog.result("verifyPurchase", resultMap)
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAGV,sCAAsC,EAEtC,aAAa,EAEb,OAAO,EACP,gBAAgB,EAEhB,QAAQ,EAER,8BAA8B,EAC9B,UAAU,EAOV,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,sBAAsB,CAAC;AAG9B,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAGvB,oBAAY,YAAY;IACtB,eAAe,qBAAqB;IACpC,aAAa,mBAAmB;IAChC,kBAAkB,yBAAyB;IAC3C,wBAAwB,gCAAgC;IACxD;;;O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c,EAAE,aAAa,CAAC,gBAAgB,CAQ1D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,0BAA0B,EAAE,aAAa,CACpD,4BAA4B,CAmD7B,CAAC;AAEF,cAAc,UAAU,CAAC;AACzB,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,WAAW,CAAC;AAC9C,YAAY,EACV,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,UAAU,EACV,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,aAAa,IAAI,iBAAiB,EAClC,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -655,6 +655,25 @@ function normalizeRequestProps(request, platform) {
|
|
|
655
655
|
}
|
|
656
656
|
return request.google;
|
|
657
657
|
}
|
|
658
|
+
function validateAndroidPurchaseBranchOptions(request, type) {
|
|
659
|
+
if (request == null || typeof request !== 'object')
|
|
660
|
+
return;
|
|
661
|
+
const fields = request;
|
|
662
|
+
const subscriptionOnlyFields = [
|
|
663
|
+
'subscriptionOffers',
|
|
664
|
+
'subscriptionProductReplacementParams',
|
|
665
|
+
'purchaseToken',
|
|
666
|
+
'originalExternalTransactionId',
|
|
667
|
+
];
|
|
668
|
+
if ((type === 'in-app' &&
|
|
669
|
+
subscriptionOnlyFields.some((field) => fields[field] != null)) ||
|
|
670
|
+
(type === 'subs' && fields.offerToken != null)) {
|
|
671
|
+
throw createPurchaseError({
|
|
672
|
+
code: ErrorCode.DeveloperError,
|
|
673
|
+
message: 'Invalid request for Android. Purchase options must match the selected product type.',
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
}
|
|
658
677
|
/**
|
|
659
678
|
* Initiate a purchase or subscription flow. The result is delivered through
|
|
660
679
|
* `purchaseUpdatedListener` — NOT the return value.
|
|
@@ -684,20 +703,29 @@ function normalizeRequestProps(request, platform) {
|
|
|
684
703
|
export const requestPurchase = async (args) => {
|
|
685
704
|
const { request, type } = args;
|
|
686
705
|
const { canonical, native } = normalizeProductType(type);
|
|
706
|
+
if (canonical === 'all') {
|
|
707
|
+
throw createPurchaseError({
|
|
708
|
+
code: ErrorCode.DeveloperError,
|
|
709
|
+
message: 'Product type all is only supported for product queries.',
|
|
710
|
+
});
|
|
711
|
+
}
|
|
687
712
|
const isInAppPurchase = canonical === 'in-app';
|
|
688
713
|
if (Platform.OS === 'ios') {
|
|
689
714
|
const normalizedRequest = normalizeRequestProps(request, 'ios');
|
|
690
715
|
if (!normalizedRequest?.sku) {
|
|
691
|
-
throw
|
|
692
|
-
'
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
716
|
+
throw createPurchaseError({
|
|
717
|
+
message: 'Invalid request for Apple. The `sku` property is required and must be a string.\n\n' +
|
|
718
|
+
'Expected format:\n' +
|
|
719
|
+
' requestPurchase({\n' +
|
|
720
|
+
' request: {\n' +
|
|
721
|
+
' apple: { sku: "product_id" },\n' +
|
|
722
|
+
' google: { skus: ["product_id"] }\n' +
|
|
723
|
+
' },\n' +
|
|
724
|
+
' type: "in-app"\n' +
|
|
725
|
+
' })\n\n' +
|
|
726
|
+
'See: https://openiap.dev/docs/apis/request-purchase',
|
|
727
|
+
code: ErrorCode.EmptySkuList,
|
|
728
|
+
});
|
|
701
729
|
}
|
|
702
730
|
if (canonical !== 'in-app' && canonical !== 'subs') {
|
|
703
731
|
throw new Error(`Unsupported product type: ${canonical}`);
|
|
@@ -722,19 +750,23 @@ export const requestPurchase = async (args) => {
|
|
|
722
750
|
return canonical === 'subs' ? [] : null;
|
|
723
751
|
}
|
|
724
752
|
if (isAndroidStoreRuntime()) {
|
|
753
|
+
validateAndroidPurchaseBranchOptions(request?.google, canonical);
|
|
725
754
|
if (isInAppPurchase) {
|
|
726
755
|
const normalizedRequest = normalizeRequestProps(request, 'android');
|
|
727
756
|
if (!normalizedRequest?.skus?.length) {
|
|
728
|
-
throw
|
|
729
|
-
'
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
757
|
+
throw createPurchaseError({
|
|
758
|
+
message: 'Invalid request for Google. The `skus` property is required and must be a non-empty array.\n\n' +
|
|
759
|
+
'Expected format:\n' +
|
|
760
|
+
' requestPurchase({\n' +
|
|
761
|
+
' request: {\n' +
|
|
762
|
+
' apple: { sku: "product_id" },\n' +
|
|
763
|
+
' google: { skus: ["product_id"] }\n' +
|
|
764
|
+
' },\n' +
|
|
765
|
+
' type: "in-app"\n' +
|
|
766
|
+
' })\n\n' +
|
|
767
|
+
'See: https://openiap.dev/docs/apis/request-purchase',
|
|
768
|
+
code: ErrorCode.EmptySkuList,
|
|
769
|
+
});
|
|
738
770
|
}
|
|
739
771
|
const { skus, obfuscatedAccountId, obfuscatedProfileId, isOfferPersonalized, offerToken, developerBillingOption, } = normalizedRequest;
|
|
740
772
|
const result = (await invokeNativeWithPurchaseError(() => ExpoIapModule.requestPurchase({
|
|
@@ -758,16 +790,19 @@ export const requestPurchase = async (args) => {
|
|
|
758
790
|
if (canonical === 'subs') {
|
|
759
791
|
const normalizedRequest = normalizeRequestProps(request, 'android');
|
|
760
792
|
if (!normalizedRequest?.skus?.length) {
|
|
761
|
-
throw
|
|
762
|
-
'
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
793
|
+
throw createPurchaseError({
|
|
794
|
+
message: 'Invalid request for Google. The `skus` property is required and must be a non-empty array.\n\n' +
|
|
795
|
+
'Expected format:\n' +
|
|
796
|
+
' requestPurchase({\n' +
|
|
797
|
+
' request: {\n' +
|
|
798
|
+
' apple: { sku: "subscription_id" },\n' +
|
|
799
|
+
' google: { skus: ["subscription_id"] }\n' +
|
|
800
|
+
' },\n' +
|
|
801
|
+
' type: "subs"\n' +
|
|
802
|
+
' })\n\n' +
|
|
803
|
+
'See: https://openiap.dev/docs/apis/request-purchase',
|
|
804
|
+
code: ErrorCode.EmptySkuList,
|
|
805
|
+
});
|
|
771
806
|
}
|
|
772
807
|
const { skus, obfuscatedAccountId, obfuscatedProfileId, isOfferPersonalized, subscriptionOffers, purchaseToken: purchaseTokenInput, originalExternalTransactionId, developerBillingOption, subscriptionProductReplacementParams, } = normalizedRequest;
|
|
773
808
|
const normalizedOffers = subscriptionOffers ?? [];
|