react-native-iap 14.4.9 → 14.4.11

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 (30) hide show
  1. package/README.md +0 -8
  2. package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +59 -8
  3. package/ios/RnIapHelper.swift +32 -1
  4. package/lib/module/utils/type-bridge.js +39 -1
  5. package/lib/module/utils/type-bridge.js.map +1 -1
  6. package/lib/typescript/src/specs/RnIap.nitro.d.ts +29 -0
  7. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
  8. package/lib/typescript/src/utils/type-bridge.d.ts.map +1 -1
  9. package/nitrogen/generated/android/c++/JFunc_void_NitroProduct.hpp +2 -0
  10. package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +4 -0
  11. package/nitrogen/generated/android/c++/JNitroOneTimePurchaseOfferDetail.hpp +61 -0
  12. package/nitrogen/generated/android/c++/JNitroProduct.hpp +16 -2
  13. package/nitrogen/generated/android/c++/JNitroPurchase.hpp +74 -2
  14. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroOneTimePurchaseOfferDetail.kt +35 -0
  15. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroProduct.kt +10 -1
  16. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchase.kt +55 -1
  17. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +18 -0
  18. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +3 -0
  19. package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +3 -0
  20. package/nitrogen/generated/ios/swift/NitroOneTimePurchaseOfferDetail.swift +57 -0
  21. package/nitrogen/generated/ios/swift/NitroProduct.swift +91 -1
  22. package/nitrogen/generated/ios/swift/NitroPurchase.swift +520 -1
  23. package/nitrogen/generated/shared/c++/NitroOneTimePurchaseOfferDetail.hpp +75 -0
  24. package/nitrogen/generated/shared/c++/NitroProduct.hpp +17 -2
  25. package/nitrogen/generated/shared/c++/NitroPurchase.hpp +74 -2
  26. package/openiap-versions.json +1 -1
  27. package/package.json +4 -4
  28. package/src/specs/RnIap.nitro.ts +32 -0
  29. package/src/utils/type-bridge.ts +76 -16
  30. package/android/src/main/java/com/margelo/nitro/iap/Types.kt +0 -173
@@ -1,173 +0,0 @@
1
- package com.margelo.nitro.iap
2
-
3
- import com.android.billingclient.api.BillingClient
4
-
5
- /**
6
- * Error codes for IAP operations - centralized error code management
7
- * Single source of truth for all error codes used across the module
8
- */
9
- object IapErrorCode {
10
- // Connection and initialization errors
11
- const val E_NOT_PREPARED = "E_NOT_PREPARED"
12
- const val E_INIT_CONNECTION = "E_INIT_CONNECTION"
13
- const val E_SERVICE_DISCONNECTED = "E_SERVICE_DISCONNECTED"
14
- const val E_ALREADY_PREPARED = "E_ALREADY_PREPARED"
15
- const val E_CONNECTION_CLOSED = "E_CONNECTION_CLOSED"
16
-
17
- // Product and purchase errors
18
- const val E_QUERY_PRODUCT = "E_QUERY_PRODUCT"
19
- const val E_SKU_NOT_FOUND = "E_SKU_NOT_FOUND"
20
- const val E_SKU_OFFER_MISMATCH = "E_SKU_OFFER_MISMATCH"
21
- const val E_PURCHASE_ERROR = "E_PURCHASE_ERROR"
22
- const val E_USER_CANCELLED = "E_USER_CANCELLED"
23
- const val E_PENDING = "E_PENDING"
24
-
25
- // Service and developer errors
26
- const val E_SERVICE_ERROR = "E_SERVICE_ERROR"
27
- const val E_DEVELOPER_ERROR = "E_DEVELOPER_ERROR"
28
- const val E_ITEM_UNAVAILABLE = "E_ITEM_UNAVAILABLE"
29
- const val E_ALREADY_OWNED = "E_ALREADY_OWNED"
30
- const val E_ITEM_NOT_OWNED = "E_ITEM_NOT_OWNED"
31
-
32
- // Network and billing errors
33
- const val E_NETWORK_ERROR = "E_NETWORK_ERROR"
34
- const val E_BILLING_UNAVAILABLE = "E_BILLING_UNAVAILABLE"
35
- const val E_FEATURE_NOT_SUPPORTED = "E_FEATURE_NOT_SUPPORTED"
36
- const val E_BILLING_RESPONSE_JSON_PARSE_ERROR = "E_BILLING_RESPONSE_JSON_PARSE_ERROR"
37
-
38
- // Activity and UI errors
39
- const val E_ACTIVITY_UNAVAILABLE = "E_ACTIVITY_UNAVAILABLE"
40
-
41
- // User and remote errors
42
- const val E_USER_ERROR = "E_USER_ERROR"
43
- const val E_REMOTE_ERROR = "E_REMOTE_ERROR"
44
- const val E_NOT_ENDED = "E_NOT_ENDED"
45
-
46
- // Validation errors
47
- const val E_EMPTY_SKU_LIST = "E_EMPTY_SKU_LIST"
48
- const val E_RECEIPT_FAILED = "E_RECEIPT_FAILED"
49
-
50
- // Unknown error
51
- const val E_UNKNOWN = "E_UNKNOWN"
52
- }
53
-
54
- /**
55
- * Data class for billing error information
56
- */
57
- data class BillingErrorData(
58
- val code: String,
59
- val message: String
60
- )
61
-
62
- /**
63
- * Helper object for billing response handling
64
- */
65
- object BillingUtils {
66
-
67
- /**
68
- * Get error data from billing response code
69
- */
70
- fun getBillingErrorData(responseCode: Int): BillingErrorData {
71
- return when (responseCode) {
72
- BillingClient.BillingResponseCode.OK ->
73
- BillingErrorData("OK", "Success")
74
-
75
- BillingClient.BillingResponseCode.USER_CANCELED ->
76
- BillingErrorData(IapErrorCode.E_USER_CANCELLED, "User cancelled the purchase")
77
-
78
- BillingClient.BillingResponseCode.SERVICE_UNAVAILABLE ->
79
- BillingErrorData(IapErrorCode.E_SERVICE_ERROR, "Network connection is down")
80
-
81
- BillingClient.BillingResponseCode.BILLING_UNAVAILABLE ->
82
- BillingErrorData(IapErrorCode.E_BILLING_UNAVAILABLE, "Billing API version is not supported for the type requested")
83
-
84
- BillingClient.BillingResponseCode.ITEM_UNAVAILABLE ->
85
- BillingErrorData(IapErrorCode.E_ITEM_UNAVAILABLE, "Requested product is not available for purchase")
86
-
87
- BillingClient.BillingResponseCode.DEVELOPER_ERROR ->
88
- BillingErrorData(IapErrorCode.E_DEVELOPER_ERROR, "Invalid arguments provided to the API")
89
-
90
- BillingClient.BillingResponseCode.ERROR ->
91
- BillingErrorData(IapErrorCode.E_UNKNOWN, "Fatal error during the API action")
92
-
93
- BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED ->
94
- BillingErrorData(IapErrorCode.E_ALREADY_OWNED, "Failure to purchase since item is already owned")
95
-
96
- BillingClient.BillingResponseCode.ITEM_NOT_OWNED ->
97
- BillingErrorData(IapErrorCode.E_ITEM_NOT_OWNED, "Failure to consume since item is not owned")
98
-
99
- BillingClient.BillingResponseCode.SERVICE_DISCONNECTED ->
100
- BillingErrorData(IapErrorCode.E_SERVICE_DISCONNECTED, "Play Store service is not connected now")
101
-
102
- BillingClient.BillingResponseCode.FEATURE_NOT_SUPPORTED ->
103
- BillingErrorData(IapErrorCode.E_FEATURE_NOT_SUPPORTED, "The requested feature is not supported by Play Store on the current device")
104
-
105
- BillingClient.BillingResponseCode.NETWORK_ERROR ->
106
- BillingErrorData(IapErrorCode.E_NETWORK_ERROR, "A network error occurred during the operation")
107
-
108
- else ->
109
- BillingErrorData(IapErrorCode.E_UNKNOWN, "Unknown billing error (code: $responseCode)")
110
- }
111
- }
112
-
113
- /**
114
- * Get error message for Google Play Services availability
115
- */
116
- fun getPlayServicesErrorMessage(resultCode: Int): String {
117
- return when (resultCode) {
118
- com.google.android.gms.common.ConnectionResult.SERVICE_MISSING ->
119
- "Google Play Services is missing on this device"
120
-
121
- com.google.android.gms.common.ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED ->
122
- "Google Play Services needs to be updated"
123
-
124
- com.google.android.gms.common.ConnectionResult.SERVICE_DISABLED ->
125
- "Google Play Services is disabled"
126
-
127
- com.google.android.gms.common.ConnectionResult.SERVICE_INVALID ->
128
- "Google Play Services is invalid"
129
-
130
- else ->
131
- "Google Play Services is not available (error code: $resultCode)"
132
- }
133
- }
134
-
135
- /**
136
- * Create JSON error string from error data and additional info
137
- */
138
- fun createErrorJson(
139
- code: String,
140
- message: String,
141
- responseCode: Int? = null,
142
- debugMessage: String? = null,
143
- productId: String? = null,
144
- additionalData: Map<String, Any> = emptyMap()
145
- ): String {
146
- val errorMap = mutableMapOf<String, Any>(
147
- "code" to code,
148
- "message" to message
149
- )
150
-
151
- responseCode?.let { errorMap["responseCode"] = it }
152
- debugMessage?.let { errorMap["debugMessage"] = it }
153
- productId?.let { errorMap["productId"] = it }
154
- errorMap.putAll(additionalData)
155
-
156
- return try {
157
- // Simple JSON serialization for basic types
158
- val jsonPairs = errorMap.map { (key, value) ->
159
- val valueStr = when (value) {
160
- is String -> "\"${value.replace("\"", "\\\"")}\""
161
- is Number -> value.toString()
162
- is Boolean -> value.toString()
163
- else -> "\"$value\""
164
- }
165
- "\"$key\":$valueStr"
166
- }
167
- "{${jsonPairs.joinToString(",")}}"
168
- } catch (e: Exception) {
169
- // Fallback to simple format
170
- "$code: $message"
171
- }
172
- }
173
- }