react-native-iap 12.4.3 → 12.4.5
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/android/build.gradle +3 -0
- package/android/src/amazon/java/com/dooboolab/RNIap/PurchasingServiceProxy.kt +20 -0
- package/android/src/amazon/java/com/dooboolab/RNIap/PurchasingServiceProxyAmazonImpl.kt +33 -0
- package/android/src/amazon/java/com/dooboolab/RNIap/RNIapAmazonListener.kt +19 -34
- package/android/src/amazon/java/com/dooboolab/RNIap/RNIapAmazonModule.kt +24 -21
- package/android/src/testAmazon/java/com/dooboolab/RNIap/RNIapAmazonModuleTest.kt +151 -0
- package/ios/IapTypes.swift +1 -1
- package/ios/RNIapIos.swift +2 -2
- package/lib/commonjs/types/appleSk2.js +1 -1
- package/lib/commonjs/types/appleSk2.js.map +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/types/appleSk2.js +1 -1
- package/lib/module/types/appleSk2.js.map +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/types/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/types/appleSk2.ts +1 -1
- package/src/types/index.ts +2 -2
package/android/build.gradle
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package com.dooboolab.RNIap
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.amazon.device.iap.PurchasingListener
|
|
5
|
+
import com.amazon.device.iap.model.FulfillmentResult
|
|
6
|
+
import com.amazon.device.iap.model.RequestId
|
|
7
|
+
|
|
8
|
+
interface PurchasingServiceProxy {
|
|
9
|
+
fun registerListener(var0: Context?, var1: PurchasingListener?)
|
|
10
|
+
|
|
11
|
+
fun getUserData(): RequestId
|
|
12
|
+
|
|
13
|
+
fun purchase(var0: String?): RequestId
|
|
14
|
+
|
|
15
|
+
fun getProductData(var0: Set<String?>?): RequestId
|
|
16
|
+
|
|
17
|
+
fun getPurchaseUpdates(var0: Boolean): RequestId
|
|
18
|
+
|
|
19
|
+
fun notifyFulfillment(var0: String?, var1: FulfillmentResult?)
|
|
20
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.dooboolab.RNIap
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.amazon.device.iap.PurchasingListener
|
|
5
|
+
import com.amazon.device.iap.PurchasingService
|
|
6
|
+
import com.amazon.device.iap.model.FulfillmentResult
|
|
7
|
+
import com.amazon.device.iap.model.RequestId
|
|
8
|
+
|
|
9
|
+
class PurchasingServiceProxyAmazonImpl : PurchasingServiceProxy {
|
|
10
|
+
override fun registerListener(var0: Context?, var1: PurchasingListener?) {
|
|
11
|
+
return PurchasingService.registerListener(var0, var1)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun getUserData(): RequestId {
|
|
15
|
+
return PurchasingService.getUserData()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override fun purchase(var0: String?): RequestId {
|
|
19
|
+
return PurchasingService.purchase(var0)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override fun getProductData(var0: Set<String?>?): RequestId {
|
|
23
|
+
return PurchasingService.getProductData(var0)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override fun getPurchaseUpdates(var0: Boolean): RequestId {
|
|
27
|
+
return PurchasingService.getPurchaseUpdates(var0)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun notifyFulfillment(var0: String?, var1: FulfillmentResult?) {
|
|
31
|
+
return PurchasingService.notifyFulfillment(var0, var1)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -2,8 +2,6 @@ package com.dooboolab.RNIap
|
|
|
2
2
|
|
|
3
3
|
import android.util.Log
|
|
4
4
|
import com.amazon.device.iap.PurchasingListener
|
|
5
|
-
import com.amazon.device.iap.PurchasingService
|
|
6
|
-
import com.amazon.device.iap.model.Product
|
|
7
5
|
import com.amazon.device.iap.model.ProductDataResponse
|
|
8
6
|
import com.amazon.device.iap.model.ProductType
|
|
9
7
|
import com.amazon.device.iap.model.PurchaseResponse
|
|
@@ -18,26 +16,21 @@ import com.facebook.react.bridge.WritableNativeArray
|
|
|
18
16
|
import com.facebook.react.bridge.WritableNativeMap
|
|
19
17
|
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
|
|
20
18
|
import java.lang.NumberFormatException
|
|
21
|
-
import java.util.ArrayList
|
|
22
19
|
|
|
23
20
|
val ProductType.typeString: String
|
|
24
21
|
get() = if (this == ProductType.ENTITLED || this == ProductType.CONSUMABLE) "inapp" else "subs"
|
|
25
22
|
|
|
26
|
-
class RNIapAmazonListener(
|
|
27
|
-
private val
|
|
23
|
+
class RNIapAmazonListener(
|
|
24
|
+
private val reactContext: ReactContext,
|
|
25
|
+
private val purchasingService: PurchasingServiceProxy
|
|
26
|
+
) : PurchasingListener {
|
|
28
27
|
|
|
29
28
|
override fun onProductDataResponse(response: ProductDataResponse) {
|
|
30
|
-
val requestId = response.requestId.toString()
|
|
31
29
|
when (response.requestStatus) {
|
|
32
30
|
ProductDataResponse.RequestStatus.SUCCESSFUL -> {
|
|
33
31
|
val productData = response.productData
|
|
34
|
-
val unavailableSkus = response.unavailableSkus
|
|
35
32
|
val items = WritableNativeArray()
|
|
36
33
|
for ((_, product) in productData) {
|
|
37
|
-
if (!skus.contains(product)) {
|
|
38
|
-
skus.add(product)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
34
|
var priceNumber: Number = 0.00
|
|
42
35
|
val priceString = product.price
|
|
43
36
|
try {
|
|
@@ -107,7 +100,7 @@ class RNIapAmazonListener(private val reactContext: ReactContext) : PurchasingLi
|
|
|
107
100
|
availableItems.pushMap(promiseItem)
|
|
108
101
|
}
|
|
109
102
|
if (response.hasMore()) {
|
|
110
|
-
|
|
103
|
+
purchasingService.getPurchaseUpdates(false)
|
|
111
104
|
} else {
|
|
112
105
|
if (purchases.size > 0 && promiseItem != null) {
|
|
113
106
|
PromiseUtils
|
|
@@ -197,13 +190,8 @@ class RNIapAmazonListener(private val reactContext: ReactContext) : PurchasingLi
|
|
|
197
190
|
override fun onPurchaseResponse(response: PurchaseResponse) {
|
|
198
191
|
val requestId = response.requestId.toString()
|
|
199
192
|
val userId = response.userData.userId
|
|
200
|
-
val status = response.requestStatus
|
|
201
193
|
|
|
202
|
-
|
|
203
|
-
val debugMessage: String?
|
|
204
|
-
var errorCode = PromiseUtils.E_UNKNOWN
|
|
205
|
-
val error = Arguments.createMap()
|
|
206
|
-
when (status) {
|
|
194
|
+
when (response.requestStatus) {
|
|
207
195
|
PurchaseResponse.RequestStatus.SUCCESSFUL -> {
|
|
208
196
|
val receipt = response.receipt
|
|
209
197
|
val userData = response.userData
|
|
@@ -218,8 +206,9 @@ class RNIapAmazonListener(private val reactContext: ReactContext) : PurchasingLi
|
|
|
218
206
|
)
|
|
219
207
|
}
|
|
220
208
|
PurchaseResponse.RequestStatus.ALREADY_PURCHASED -> {
|
|
221
|
-
|
|
222
|
-
|
|
209
|
+
val error = Arguments.createMap()
|
|
210
|
+
val debugMessage = "You already own this item."
|
|
211
|
+
val errorCode = PromiseUtils.E_ALREADY_OWNED
|
|
223
212
|
error.putInt("responseCode", 0)
|
|
224
213
|
error.putString("debugMessage", debugMessage)
|
|
225
214
|
error.putString("code", errorCode)
|
|
@@ -234,9 +223,10 @@ class RNIapAmazonListener(private val reactContext: ReactContext) : PurchasingLi
|
|
|
234
223
|
)
|
|
235
224
|
}
|
|
236
225
|
PurchaseResponse.RequestStatus.FAILED -> {
|
|
237
|
-
|
|
226
|
+
val error = Arguments.createMap()
|
|
227
|
+
val debugMessage =
|
|
238
228
|
"An unknown or unexpected error has occurred. Please try again later."
|
|
239
|
-
errorCode = PromiseUtils.E_UNKNOWN
|
|
229
|
+
val errorCode = PromiseUtils.E_UNKNOWN
|
|
240
230
|
error.putInt("responseCode", 0)
|
|
241
231
|
error.putString("debugMessage", debugMessage)
|
|
242
232
|
error.putString("code", errorCode)
|
|
@@ -251,8 +241,9 @@ class RNIapAmazonListener(private val reactContext: ReactContext) : PurchasingLi
|
|
|
251
241
|
)
|
|
252
242
|
}
|
|
253
243
|
PurchaseResponse.RequestStatus.INVALID_SKU -> {
|
|
254
|
-
|
|
255
|
-
|
|
244
|
+
val error = Arguments.createMap()
|
|
245
|
+
val debugMessage = "That item is unavailable."
|
|
246
|
+
val errorCode = PromiseUtils.E_ITEM_UNAVAILABLE
|
|
256
247
|
error.putInt("responseCode", 0)
|
|
257
248
|
error.putString("debugMessage", debugMessage)
|
|
258
249
|
error.putString("code", errorCode)
|
|
@@ -267,8 +258,9 @@ class RNIapAmazonListener(private val reactContext: ReactContext) : PurchasingLi
|
|
|
267
258
|
)
|
|
268
259
|
}
|
|
269
260
|
PurchaseResponse.RequestStatus.NOT_SUPPORTED -> {
|
|
270
|
-
|
|
271
|
-
|
|
261
|
+
val error = Arguments.createMap()
|
|
262
|
+
val debugMessage = "This feature is not available on your device."
|
|
263
|
+
val errorCode = PromiseUtils.E_SERVICE_ERROR
|
|
272
264
|
error.putInt("responseCode", 0)
|
|
273
265
|
error.putString("debugMessage", debugMessage)
|
|
274
266
|
error.putString("code", errorCode)
|
|
@@ -314,11 +306,8 @@ class RNIapAmazonListener(private val reactContext: ReactContext) : PurchasingLi
|
|
|
314
306
|
)
|
|
315
307
|
}
|
|
316
308
|
}
|
|
317
|
-
fun clear() {
|
|
318
|
-
skus.clear()
|
|
319
|
-
}
|
|
320
309
|
|
|
321
|
-
|
|
310
|
+
fun sendEvent(
|
|
322
311
|
reactContext: ReactContext,
|
|
323
312
|
eventName: String,
|
|
324
313
|
params: WritableMap?
|
|
@@ -344,8 +333,4 @@ class RNIapAmazonListener(private val reactContext: ReactContext) : PurchasingLi
|
|
|
344
333
|
private const val E_USER_DATA_RESPONSE_NOT_SUPPORTED = "E_USER_DATA_RESPONSE_NOT_SUPPORTED"
|
|
345
334
|
const val TAG = "RNIapAmazonListener"
|
|
346
335
|
}
|
|
347
|
-
|
|
348
|
-
init {
|
|
349
|
-
skus = ArrayList()
|
|
350
|
-
}
|
|
351
336
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
package com.dooboolab.RNIap
|
|
2
2
|
|
|
3
|
+
import android.os.Handler
|
|
4
|
+
import android.os.Looper
|
|
3
5
|
import android.util.Log
|
|
4
6
|
import com.amazon.device.drm.LicensingService
|
|
5
7
|
import com.amazon.device.drm.model.LicenseResponse
|
|
6
|
-
import com.amazon.device.iap.
|
|
8
|
+
import com.amazon.device.iap.PurchasingListener
|
|
7
9
|
import com.amazon.device.iap.model.FulfillmentResult
|
|
8
10
|
import com.facebook.react.bridge.LifecycleEventListener
|
|
9
11
|
import com.facebook.react.bridge.Promise
|
|
@@ -11,14 +13,17 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
11
13
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
12
14
|
import com.facebook.react.bridge.ReactMethod
|
|
13
15
|
import com.facebook.react.bridge.ReadableArray
|
|
14
|
-
import com.facebook.react.bridge.UiThreadUtil
|
|
15
16
|
import com.facebook.react.module.annotations.ReactModule
|
|
16
17
|
|
|
17
18
|
@ReactModule(name = RNIapAmazonModule.TAG)
|
|
18
|
-
class RNIapAmazonModule(
|
|
19
|
+
class RNIapAmazonModule(
|
|
20
|
+
reactContext: ReactApplicationContext,
|
|
21
|
+
private val purchasingService: PurchasingServiceProxy = PurchasingServiceProxyAmazonImpl(),
|
|
22
|
+
private val handler: Handler = Handler(Looper.getMainLooper()),
|
|
23
|
+
private val amazonListener: PurchasingListener = RNIapAmazonListener(reactContext, purchasingService)
|
|
24
|
+
) :
|
|
19
25
|
ReactContextBaseJavaModule(reactContext) {
|
|
20
26
|
var hasListener = false
|
|
21
|
-
private var amazonListener: RNIapAmazonListener? = null
|
|
22
27
|
override fun getName(): String {
|
|
23
28
|
return TAG
|
|
24
29
|
}
|
|
@@ -26,20 +31,19 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
|
|
|
26
31
|
@ReactMethod
|
|
27
32
|
fun initConnection(promise: Promise) {
|
|
28
33
|
val context = reactApplicationContext
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
UiThreadUtil.runOnUiThread {
|
|
34
|
+
|
|
35
|
+
handler.postDelayed({
|
|
32
36
|
try {
|
|
33
|
-
|
|
37
|
+
purchasingService.registerListener(context.applicationContext, amazonListener)
|
|
34
38
|
hasListener = true
|
|
35
39
|
// Prefetch user and purchases as per Amazon SDK documentation:
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
purchasingService.getUserData()
|
|
41
|
+
purchasingService.getPurchaseUpdates(false)
|
|
38
42
|
promise.safeResolve(true)
|
|
39
43
|
} catch (e: Exception) {
|
|
40
44
|
promise.safeReject("Error initializing Amazon appstore sdk", e)
|
|
41
45
|
}
|
|
42
|
-
}
|
|
46
|
+
}, 0L)
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
@ReactMethod
|
|
@@ -84,14 +88,13 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
|
|
|
84
88
|
@ReactMethod
|
|
85
89
|
fun endConnection(promise: Promise) {
|
|
86
90
|
PromiseUtils.rejectAllPendingPromises()
|
|
87
|
-
amazonListener?.clear()
|
|
88
91
|
hasListener = false
|
|
89
92
|
promise.resolve(true)
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
@ReactMethod
|
|
93
96
|
fun getUser(promise: Promise) {
|
|
94
|
-
val requestId =
|
|
97
|
+
val requestId = purchasingService.getUserData()
|
|
95
98
|
PromiseUtils.addPromiseForKey(PROMISE_GET_USER_DATA, promise)
|
|
96
99
|
}
|
|
97
100
|
|
|
@@ -114,13 +117,13 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
|
|
|
114
117
|
ii++
|
|
115
118
|
}
|
|
116
119
|
PromiseUtils.addPromiseForKey(PROMISE_GET_PRODUCT_DATA, promise)
|
|
117
|
-
val requestId =
|
|
120
|
+
val requestId = purchasingService.getProductData(productSkus)
|
|
118
121
|
}
|
|
119
122
|
|
|
120
123
|
@ReactMethod
|
|
121
124
|
fun getAvailableItems(promise: Promise) {
|
|
122
125
|
PromiseUtils.addPromiseForKey(PROMISE_QUERY_AVAILABLE_ITEMS, promise)
|
|
123
|
-
|
|
126
|
+
purchasingService.getPurchaseUpdates(true)
|
|
124
127
|
}
|
|
125
128
|
|
|
126
129
|
@ReactMethod
|
|
@@ -129,7 +132,7 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
|
|
|
129
132
|
promise: Promise
|
|
130
133
|
) {
|
|
131
134
|
PromiseUtils.addPromiseForKey(PROMISE_BUY_ITEM, promise)
|
|
132
|
-
val requestId =
|
|
135
|
+
val requestId = purchasingService.purchase(sku)
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
@ReactMethod
|
|
@@ -138,7 +141,7 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
|
|
|
138
141
|
developerPayLoad: String?,
|
|
139
142
|
promise: Promise
|
|
140
143
|
) {
|
|
141
|
-
|
|
144
|
+
purchasingService.notifyFulfillment(token, FulfillmentResult.FULFILLED)
|
|
142
145
|
promise.resolve(true)
|
|
143
146
|
}
|
|
144
147
|
|
|
@@ -148,13 +151,13 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
|
|
|
148
151
|
developerPayLoad: String?,
|
|
149
152
|
promise: Promise
|
|
150
153
|
) {
|
|
151
|
-
|
|
154
|
+
purchasingService.notifyFulfillment(token, FulfillmentResult.FULFILLED)
|
|
152
155
|
promise.resolve(true)
|
|
153
156
|
}
|
|
154
157
|
|
|
155
158
|
private fun sendUnconsumedPurchases(promise: Promise) {
|
|
156
159
|
PromiseUtils.addPromiseForKey(PROMISE_QUERY_PURCHASES, promise)
|
|
157
|
-
|
|
160
|
+
purchasingService.getPurchaseUpdates(false)
|
|
158
161
|
}
|
|
159
162
|
|
|
160
163
|
@ReactMethod
|
|
@@ -189,8 +192,8 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
|
|
|
189
192
|
*/
|
|
190
193
|
override fun onHostResume() {
|
|
191
194
|
if (hasListener) {
|
|
192
|
-
|
|
193
|
-
|
|
195
|
+
purchasingService.getUserData()
|
|
196
|
+
purchasingService.getPurchaseUpdates(false)
|
|
194
197
|
}
|
|
195
198
|
}
|
|
196
199
|
override fun onHostPause() {}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
package com.dooboolab.RNIap
|
|
2
|
+
|
|
3
|
+
import android.os.Handler
|
|
4
|
+
import com.amazon.device.iap.model.PurchaseResponse
|
|
5
|
+
import com.amazon.device.iap.model.Receipt
|
|
6
|
+
import com.amazon.device.iap.model.RequestId
|
|
7
|
+
import com.amazon.device.iap.model.UserData
|
|
8
|
+
import com.facebook.react.bridge.Arguments
|
|
9
|
+
import com.facebook.react.bridge.Promise
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
|
+
import com.facebook.react.bridge.WritableMap
|
|
12
|
+
import io.mockk.MockKAnnotations
|
|
13
|
+
import io.mockk.Runs
|
|
14
|
+
import io.mockk.every
|
|
15
|
+
import io.mockk.impl.annotations.MockK
|
|
16
|
+
import io.mockk.impl.annotations.RelaxedMockK
|
|
17
|
+
import io.mockk.just
|
|
18
|
+
import io.mockk.mockk
|
|
19
|
+
import io.mockk.mockkStatic
|
|
20
|
+
import io.mockk.slot
|
|
21
|
+
import io.mockk.spyk
|
|
22
|
+
import io.mockk.verify
|
|
23
|
+
import org.junit.Assert.assertEquals
|
|
24
|
+
import org.junit.Before
|
|
25
|
+
import org.junit.Test
|
|
26
|
+
import java.util.*
|
|
27
|
+
|
|
28
|
+
class RNIapAmazonModuleTest {
|
|
29
|
+
|
|
30
|
+
@MockK
|
|
31
|
+
lateinit var context: ReactApplicationContext
|
|
32
|
+
|
|
33
|
+
@RelaxedMockK
|
|
34
|
+
lateinit var purchasingServiceProxy: PurchasingServiceProxy
|
|
35
|
+
|
|
36
|
+
@MockK
|
|
37
|
+
lateinit var mainThreadHandler: Handler
|
|
38
|
+
|
|
39
|
+
private lateinit var listener: RNIapAmazonListener
|
|
40
|
+
|
|
41
|
+
private lateinit var module: RNIapAmazonModule
|
|
42
|
+
|
|
43
|
+
@Before
|
|
44
|
+
fun setUp() {
|
|
45
|
+
MockKAnnotations.init(this, relaxUnitFun = true)
|
|
46
|
+
listener = spyk(RNIapAmazonListener(context, purchasingServiceProxy))
|
|
47
|
+
module = RNIapAmazonModule(context, purchasingServiceProxy, mainThreadHandler, listener)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@Test
|
|
51
|
+
fun `initConnection should resolve to true`() {
|
|
52
|
+
every { context.applicationContext } returns mockk()
|
|
53
|
+
|
|
54
|
+
val promise = mockk<Promise>(relaxed = true)
|
|
55
|
+
val slot = slot<Runnable>()
|
|
56
|
+
every { mainThreadHandler.postDelayed(capture(slot), any()) } answers { slot.captured.run(); true }
|
|
57
|
+
module.initConnection(promise)
|
|
58
|
+
verify(exactly = 0) { promise.reject(any(), any<String>()) }
|
|
59
|
+
verify { promise.resolve(true) }
|
|
60
|
+
verify { purchasingServiceProxy.registerListener(any(), any()) }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Test
|
|
64
|
+
fun `Purchase Item`() {
|
|
65
|
+
val purchaseResponse = mockk<PurchaseResponse>() {
|
|
66
|
+
every { requestId } returns RequestId.fromString("0")
|
|
67
|
+
|
|
68
|
+
every { requestStatus } returns PurchaseResponse.RequestStatus.SUCCESSFUL
|
|
69
|
+
val mReceipt = mockk<Receipt>(relaxed = true) {
|
|
70
|
+
every { sku } returns "mySku"
|
|
71
|
+
every { purchaseDate } returns Date()
|
|
72
|
+
every { receiptId } returns "rId"
|
|
73
|
+
}
|
|
74
|
+
every { receipt } returns mReceipt
|
|
75
|
+
val mUserData = mockk<UserData>(relaxed = true) {
|
|
76
|
+
every { userId } returns "uid1"
|
|
77
|
+
}
|
|
78
|
+
every { userData } returns mUserData
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
every { listener.sendEvent(any(), any(), any()) } just Runs
|
|
82
|
+
|
|
83
|
+
every { purchasingServiceProxy.purchase(any()) } answers {
|
|
84
|
+
listener.onPurchaseResponse(
|
|
85
|
+
purchaseResponse
|
|
86
|
+
); RequestId.fromString("0")
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
val itemsMap = mockk<WritableMap>(relaxed = true) {
|
|
90
|
+
every { getString("productId") } returns "mySku"
|
|
91
|
+
}
|
|
92
|
+
mockkStatic(Arguments::class)
|
|
93
|
+
|
|
94
|
+
every { Arguments.createMap() } returns itemsMap
|
|
95
|
+
|
|
96
|
+
val promise = mockk<Promise>(relaxed = true)
|
|
97
|
+
|
|
98
|
+
module.buyItemByType("mySku", promise)
|
|
99
|
+
verify(exactly = 0) { promise.reject(any(), any<String>()) }
|
|
100
|
+
val response = slot<WritableMap>()
|
|
101
|
+
verify { promise.resolve(capture(response)) }
|
|
102
|
+
assertEquals("mySku", response.captured.getString("productId"))
|
|
103
|
+
verify { listener.sendEvent(any(), "purchase-updated", any()) }
|
|
104
|
+
verify(exactly = 0) { purchasingServiceProxy.getPurchaseUpdates(false) }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// @Test
|
|
108
|
+
// fun `initConnection Play Services not available on device should reject`() {
|
|
109
|
+
// }
|
|
110
|
+
//
|
|
111
|
+
// @Test
|
|
112
|
+
// fun `initConnection start new connection fails`() {
|
|
113
|
+
// }
|
|
114
|
+
//
|
|
115
|
+
// @Test
|
|
116
|
+
// fun `endConnection resolves`() {
|
|
117
|
+
// }
|
|
118
|
+
//
|
|
119
|
+
// @Test
|
|
120
|
+
// fun `flushFailedPurchasesCachedAsPending resolves to false if no pending purchases`() {
|
|
121
|
+
// }
|
|
122
|
+
//
|
|
123
|
+
// @Test
|
|
124
|
+
// fun `flushFailedPurchasesCachedAsPending resolves to true if pending purchases`() {
|
|
125
|
+
// }
|
|
126
|
+
//
|
|
127
|
+
// @Test
|
|
128
|
+
// fun getItemsByType() {
|
|
129
|
+
// }
|
|
130
|
+
//
|
|
131
|
+
// @Test
|
|
132
|
+
// fun getAvailableItemsByType() {
|
|
133
|
+
// }
|
|
134
|
+
//
|
|
135
|
+
// @Test
|
|
136
|
+
// fun getPurchaseHistoryByType() {
|
|
137
|
+
// }
|
|
138
|
+
//
|
|
139
|
+
//
|
|
140
|
+
// @Test
|
|
141
|
+
// fun acknowledgePurchase() {
|
|
142
|
+
// }
|
|
143
|
+
//
|
|
144
|
+
// @Test
|
|
145
|
+
// fun consumeProduct() {
|
|
146
|
+
// }
|
|
147
|
+
//
|
|
148
|
+
// @Test
|
|
149
|
+
// fun onPurchasesUpdated() {
|
|
150
|
+
// }
|
|
151
|
+
}
|
package/ios/IapTypes.swift
CHANGED
package/ios/RNIapIos.swift
CHANGED
|
@@ -796,7 +796,7 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
|
|
|
796
796
|
block(nil)
|
|
797
797
|
} else {
|
|
798
798
|
var purchase = [
|
|
799
|
-
"transactionDate": transaction.transactionDate?.
|
|
799
|
+
"transactionDate": transaction.transactionDate?.millisecondsSince1970,
|
|
800
800
|
"transactionId": transaction.transactionIdentifier,
|
|
801
801
|
"productId": transaction.payment.productIdentifier,
|
|
802
802
|
"transactionReceipt": receiptData?.base64EncodedString(options: [.endLineWithCarriageReturn])
|
|
@@ -804,7 +804,7 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
|
|
|
804
804
|
|
|
805
805
|
// originalTransaction is available for restore purchase and purchase of cancelled/expired subscriptions
|
|
806
806
|
if let originalTransaction = transaction.original {
|
|
807
|
-
purchase["originalTransactionDateIOS"] = originalTransaction.transactionDate?.
|
|
807
|
+
purchase["originalTransactionDateIOS"] = originalTransaction.transactionDate?.millisecondsSince1970
|
|
808
808
|
purchase["originalTransactionIdentifierIOS"] = originalTransaction.transactionIdentifier
|
|
809
809
|
}
|
|
810
810
|
|
|
@@ -78,7 +78,7 @@ const transactionSk2Map = _ref3 => {
|
|
|
78
78
|
purchaseToken: '',
|
|
79
79
|
//Not avaiable
|
|
80
80
|
quantityIOS: purchasedQuantity,
|
|
81
|
-
originalTransactionDateIOS:
|
|
81
|
+
originalTransactionDateIOS: originalPurchaseDate,
|
|
82
82
|
originalTransactionIdentifierIOS: originalID
|
|
83
83
|
};
|
|
84
84
|
return purchase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["productSk2Map","id","description","displayName","price","displayPrice","prod","title","productId","String","type","localizedPrice","currency","subscriptionSk2Map","subscription","platform","SubscriptionPlatform","ios","subscriptionPeriodNumberIOS","subscriptionPeriod","value","subscriptionPeriodUnitIOS","unit","toUpperCase","transactionSk2Map","originalPurchaseDate","productID","purchaseDate","purchasedQuantity","originalID","purchase","transactionId","transactionDate","transactionReceipt","purchaseToken","quantityIOS","originalTransactionDateIOS","originalTransactionIdentifierIOS","offerSk2Map","offer","undefined","offerID","identifier","keyID","keyIdentifier","nonce","signature","timestamp","toString"],"sources":["appleSk2.ts"],"sourcesContent":["import type {PurchaseError} from '../purchaseError';\n\nimport type {\n ProductIOS,\n Purchase,\n SubscriptionIOS,\n SubscriptionIosPeriod,\n} from '.';\nimport type * as Apple from './apple';\nimport {SubscriptionPlatform} from '.';\n\nexport type SubscriptionPeriod = {\n unit: 'day' | 'week' | 'month' | 'year';\n value: number;\n};\n\nexport type PaymentMode = 'freeTrial' | 'payAsYouGo' | 'payUpFront';\n\nexport type SubscriptionOffer = {\n displayPrice: string;\n id: string;\n paymentMode: PaymentMode;\n period: SubscriptionPeriod;\n periodCount: number;\n price: number;\n type: 'introductory' | 'promotional';\n};\n\nexport type SubscriptionInfo = {\n introductoryOffer?: SubscriptionOffer;\n promotionalOffers?: SubscriptionOffer[];\n subscriptionGroupID: string;\n subscriptionPeriod: SubscriptionPeriod;\n};\n\nexport type RefundRequestStatus = 'success' | 'userCancelled';\n\nexport type ProductSk2 = {\n description: string;\n displayName: string;\n displayPrice: string;\n id: number;\n isFamilyShareable: boolean;\n jsonRepresentation: string;\n price: number;\n subscription: SubscriptionInfo;\n type: 'autoRenewable' | 'consumable' | 'nonConsumable' | 'nonRenewable';\n};\nexport const productSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n}: ProductSk2): ProductIOS => {\n const prod: ProductIOS = {\n title: displayName,\n productId: String(id),\n description,\n type: 'iap',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', // Not avaiable on new API, use localizedPrice instead\n };\n return prod;\n};\n\nexport const subscriptionSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n subscription,\n}: ProductSk2): SubscriptionIOS => {\n const prod: SubscriptionIOS = {\n platform: SubscriptionPlatform.ios,\n title: displayName,\n productId: String(id),\n description,\n type: 'subs',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', // Not avaiable on new API, use localizedPrice instead\n subscriptionPeriodNumberIOS: `${subscription?.subscriptionPeriod?.value}`,\n subscriptionPeriodUnitIOS:\n subscription?.subscriptionPeriod?.unit.toUpperCase() as SubscriptionIosPeriod,\n };\n return prod;\n};\n\nexport type TransactionSk2 = {\n appAccountToken: string;\n appBundleID: string;\n debugDescription: string;\n deviceVerification: string;\n deviceVerificationNonce: string;\n expirationDate: number;\n id: number;\n isUpgraded: boolean;\n jsonRepresentation: string;\n offerID: string;\n offerType: string;\n originalID: string;\n originalPurchaseDate: number;\n ownershipType: string;\n productID: string;\n productType: string;\n purchaseDate: number;\n purchasedQuantity: number;\n revocationDate: number;\n revocationReason: string;\n signedDate: number;\n subscriptionGroupID: number;\n webOrderLineItemID: number;\n};\n\nexport type TransactionError = PurchaseError;\n\n/**\n * Only one of `transaction` and `error` is not undefined at the time\n */\nexport type TransactionEvent = {\n transaction?: TransactionSk2;\n error?: TransactionError;\n};\n\nexport type SubscriptionStatus =\n | 'expired'\n | 'inBillingRetryPeriod'\n | 'inGracePeriod'\n | 'revoked'\n | 'subscribed';\n\nexport type ProductStatus = {\n state: SubscriptionStatus;\n};\n\nexport const transactionSk2Map = ({\n id,\n originalPurchaseDate,\n productID,\n purchaseDate,\n purchasedQuantity,\n originalID,\n}: TransactionSk2): Purchase => {\n const purchase: Purchase = {\n productId: productID,\n transactionId: String(id),\n transactionDate: purchaseDate, //??\n transactionReceipt: '', // Not available\n purchaseToken: '', //Not avaiable\n quantityIOS: purchasedQuantity,\n originalTransactionDateIOS:
|
|
1
|
+
{"version":3,"names":["productSk2Map","id","description","displayName","price","displayPrice","prod","title","productId","String","type","localizedPrice","currency","subscriptionSk2Map","subscription","platform","SubscriptionPlatform","ios","subscriptionPeriodNumberIOS","subscriptionPeriod","value","subscriptionPeriodUnitIOS","unit","toUpperCase","transactionSk2Map","originalPurchaseDate","productID","purchaseDate","purchasedQuantity","originalID","purchase","transactionId","transactionDate","transactionReceipt","purchaseToken","quantityIOS","originalTransactionDateIOS","originalTransactionIdentifierIOS","offerSk2Map","offer","undefined","offerID","identifier","keyID","keyIdentifier","nonce","signature","timestamp","toString"],"sources":["appleSk2.ts"],"sourcesContent":["import type {PurchaseError} from '../purchaseError';\n\nimport type {\n ProductIOS,\n Purchase,\n SubscriptionIOS,\n SubscriptionIosPeriod,\n} from '.';\nimport type * as Apple from './apple';\nimport {SubscriptionPlatform} from '.';\n\nexport type SubscriptionPeriod = {\n unit: 'day' | 'week' | 'month' | 'year';\n value: number;\n};\n\nexport type PaymentMode = 'freeTrial' | 'payAsYouGo' | 'payUpFront';\n\nexport type SubscriptionOffer = {\n displayPrice: string;\n id: string;\n paymentMode: PaymentMode;\n period: SubscriptionPeriod;\n periodCount: number;\n price: number;\n type: 'introductory' | 'promotional';\n};\n\nexport type SubscriptionInfo = {\n introductoryOffer?: SubscriptionOffer;\n promotionalOffers?: SubscriptionOffer[];\n subscriptionGroupID: string;\n subscriptionPeriod: SubscriptionPeriod;\n};\n\nexport type RefundRequestStatus = 'success' | 'userCancelled';\n\nexport type ProductSk2 = {\n description: string;\n displayName: string;\n displayPrice: string;\n id: number;\n isFamilyShareable: boolean;\n jsonRepresentation: string;\n price: number;\n subscription: SubscriptionInfo;\n type: 'autoRenewable' | 'consumable' | 'nonConsumable' | 'nonRenewable';\n};\nexport const productSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n}: ProductSk2): ProductIOS => {\n const prod: ProductIOS = {\n title: displayName,\n productId: String(id),\n description,\n type: 'iap',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', // Not avaiable on new API, use localizedPrice instead\n };\n return prod;\n};\n\nexport const subscriptionSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n subscription,\n}: ProductSk2): SubscriptionIOS => {\n const prod: SubscriptionIOS = {\n platform: SubscriptionPlatform.ios,\n title: displayName,\n productId: String(id),\n description,\n type: 'subs',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', // Not avaiable on new API, use localizedPrice instead\n subscriptionPeriodNumberIOS: `${subscription?.subscriptionPeriod?.value}`,\n subscriptionPeriodUnitIOS:\n subscription?.subscriptionPeriod?.unit.toUpperCase() as SubscriptionIosPeriod,\n };\n return prod;\n};\n\nexport type TransactionSk2 = {\n appAccountToken: string;\n appBundleID: string;\n debugDescription: string;\n deviceVerification: string;\n deviceVerificationNonce: string;\n expirationDate: number;\n id: number;\n isUpgraded: boolean;\n jsonRepresentation: string;\n offerID: string;\n offerType: string;\n originalID: string;\n originalPurchaseDate: number;\n ownershipType: string;\n productID: string;\n productType: string;\n purchaseDate: number;\n purchasedQuantity: number;\n revocationDate: number;\n revocationReason: string;\n signedDate: number;\n subscriptionGroupID: number;\n webOrderLineItemID: number;\n};\n\nexport type TransactionError = PurchaseError;\n\n/**\n * Only one of `transaction` and `error` is not undefined at the time\n */\nexport type TransactionEvent = {\n transaction?: TransactionSk2;\n error?: TransactionError;\n};\n\nexport type SubscriptionStatus =\n | 'expired'\n | 'inBillingRetryPeriod'\n | 'inGracePeriod'\n | 'revoked'\n | 'subscribed';\n\nexport type ProductStatus = {\n state: SubscriptionStatus;\n};\n\nexport const transactionSk2Map = ({\n id,\n originalPurchaseDate,\n productID,\n purchaseDate,\n purchasedQuantity,\n originalID,\n}: TransactionSk2): Purchase => {\n const purchase: Purchase = {\n productId: productID,\n transactionId: String(id),\n transactionDate: purchaseDate, //??\n transactionReceipt: '', // Not available\n purchaseToken: '', //Not avaiable\n quantityIOS: purchasedQuantity,\n originalTransactionDateIOS: originalPurchaseDate,\n originalTransactionIdentifierIOS: originalID,\n };\n return purchase;\n};\n\n/**\n * Payment discount interface @see https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc\n */\nexport interface PaymentDiscountSk2 {\n /**\n * A string used to uniquely identify a discount offer for a product.\n */\n offerID: string;\n\n /**\n * A string that identifies the key used to generate the signature.\n */\n keyID: string;\n\n /**\n * A universally unique ID (UUID) value that you define.\n */\n nonce: string;\n\n /**\n * A UTF-8 string representing the properties of a specific discount offer, cryptographically signed.\n */\n signature: string;\n\n /**\n * The date and time of the signature's creation in milliseconds, formatted in Unix epoch time.\n */\n timestamp: number;\n}\n\nexport const offerSk2Map = (\n offer: Apple.PaymentDiscount | undefined,\n): Record<keyof PaymentDiscountSk2, string> | undefined => {\n if (!offer) {\n return undefined;\n }\n return {\n offerID: offer.identifier,\n keyID: offer.keyIdentifier,\n nonce: offer.nonce,\n signature: offer.signature,\n timestamp: offer.timestamp.toString(),\n };\n};\n"],"mappings":";;;;;;;AASA;;AAuCO,MAAMA,aAAa,GAAG,QAMC;EAAA,IANA;IAC5BC,EAD4B;IAE5BC,WAF4B;IAG5BC,WAH4B;IAI5BC,KAJ4B;IAK5BC;EAL4B,CAMA;EAC5B,MAAMC,IAAgB,GAAG;IACvBC,KAAK,EAAEJ,WADgB;IAEvBK,SAAS,EAAEC,MAAM,CAACR,EAAD,CAFM;IAGvBC,WAHuB;IAIvBQ,IAAI,EAAE,KAJiB;IAKvBN,KAAK,EAAEK,MAAM,CAACL,KAAD,CALU;IAMvBO,cAAc,EAAEN,YANO;IAOvBO,QAAQ,EAAE,EAPa,CAOT;;EAPS,CAAzB;EASA,OAAON,IAAP;AACD,CAjBM;;;;AAmBA,MAAMO,kBAAkB,GAAG,SAOC;EAAA;;EAAA,IAPA;IACjCZ,EADiC;IAEjCC,WAFiC;IAGjCC,WAHiC;IAIjCC,KAJiC;IAKjCC,YALiC;IAMjCS;EANiC,CAOA;EACjC,MAAMR,IAAqB,GAAG;IAC5BS,QAAQ,EAAEC,sBAAA,CAAqBC,GADH;IAE5BV,KAAK,EAAEJ,WAFqB;IAG5BK,SAAS,EAAEC,MAAM,CAACR,EAAD,CAHW;IAI5BC,WAJ4B;IAK5BQ,IAAI,EAAE,MALsB;IAM5BN,KAAK,EAAEK,MAAM,CAACL,KAAD,CANe;IAO5BO,cAAc,EAAEN,YAPY;IAQ5BO,QAAQ,EAAE,EARkB;IAQd;IACdM,2BAA2B,EAAG,GAAEJ,YAAH,aAAGA,YAAH,gDAAGA,YAAY,CAAEK,kBAAjB,0DAAG,sBAAkCC,KAAM,EAT5C;IAU5BC,yBAAyB,EACvBP,YADuB,aACvBA,YADuB,iDACvBA,YAAY,CAAEK,kBADS,2DACvB,uBAAkCG,IAAlC,CAAuCC,WAAvC;EAX0B,CAA9B;EAaA,OAAOjB,IAAP;AACD,CAtBM;;;;AAuEA,MAAMkB,iBAAiB,GAAG,SAOD;EAAA,IAPE;IAChCvB,EADgC;IAEhCwB,oBAFgC;IAGhCC,SAHgC;IAIhCC,YAJgC;IAKhCC,iBALgC;IAMhCC;EANgC,CAOF;EAC9B,MAAMC,QAAkB,GAAG;IACzBtB,SAAS,EAAEkB,SADc;IAEzBK,aAAa,EAAEtB,MAAM,CAACR,EAAD,CAFI;IAGzB+B,eAAe,EAAEL,YAHQ;IAGM;IAC/BM,kBAAkB,EAAE,EAJK;IAID;IACxBC,aAAa,EAAE,EALU;IAKN;IACnBC,WAAW,EAAEP,iBANY;IAOzBQ,0BAA0B,EAAEX,oBAPH;IAQzBY,gCAAgC,EAAER;EART,CAA3B;EAUA,OAAOC,QAAP;AACD,CAnBM;AAqBP;AACA;AACA;;;;;AA4BO,MAAMQ,WAAW,GACtBC,KADyB,IAEgC;EACzD,IAAI,CAACA,KAAL,EAAY;IACV,OAAOC,SAAP;EACD;;EACD,OAAO;IACLC,OAAO,EAAEF,KAAK,CAACG,UADV;IAELC,KAAK,EAAEJ,KAAK,CAACK,aAFR;IAGLC,KAAK,EAAEN,KAAK,CAACM,KAHR;IAILC,SAAS,EAAEP,KAAK,CAACO,SAJZ;IAKLC,SAAS,EAAER,KAAK,CAACQ,SAAN,CAAgBC,QAAhB;EALN,CAAP;AAOD,CAbM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid","ProductType","SubscriptionPlatform"],"sources":["index.ts"],"sourcesContent":["import type {\n AmazonModuleProps,\n AndroidModuleProps,\n IosModuleProps,\n} from '../modules';\nimport type {IosModulePropsSk2} from '../modules/iosSk2';\n\nimport type * as Apple from './apple';\n\nexport type Sku = string;\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n IMMEDIATE_AND_CHARGE_FULL_PRICE = 5,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport enum ProductType {\n /** Subscription */\n subs = 'subs',\n\n /** Subscription */\n sub = 'sub',\n\n /** Consumable */\n inapp = 'inapp',\n\n /** Consumable */\n iap = 'iap',\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string; //iOS\n productIds?: string[];\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?:
|
|
1
|
+
{"version":3,"names":["ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid","ProductType","SubscriptionPlatform"],"sources":["index.ts"],"sourcesContent":["import type {\n AmazonModuleProps,\n AndroidModuleProps,\n IosModuleProps,\n} from '../modules';\nimport type {IosModulePropsSk2} from '../modules/iosSk2';\n\nimport type * as Apple from './apple';\n\nexport type Sku = string;\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n IMMEDIATE_AND_CHARGE_FULL_PRICE = 5,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport enum ProductType {\n /** Subscription */\n subs = 'subs',\n\n /** Subscription */\n sub = 'sub',\n\n /** Consumable */\n inapp = 'inapp',\n\n /** Consumable */\n iap = 'iap',\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string; //iOS\n productIds?: string[];\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?: number;\n originalTransactionIdentifierIOS?: string;\n //Android\n productIds?: string[];\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n //Amazon\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n isCanceledAmazon?: boolean;\n}\n\nexport interface PurchaseResult {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n purchaseToken?: string;\n}\n\nexport interface SubscriptionPurchase extends ProductPurchase {\n autoRenewingAndroid?: boolean;\n originalTransactionDateIOS?: number;\n originalTransactionIdentifierIOS?: string;\n}\n\nexport type Purchase = ProductPurchase | SubscriptionPurchase;\n\nexport interface Discount {\n identifier: string;\n type: string;\n numberOfPeriods: string;\n price: string;\n localizedPrice: string;\n paymentMode: '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';\n subscriptionPeriod: string;\n}\n\nexport interface ProductAndroid extends ProductCommon {\n type: 'inapp' | 'iap';\n oneTimePurchaseOfferDetails?: {\n priceCurrencyCode: string;\n formattedPrice: string;\n priceAmountMicros: string;\n };\n}\nexport interface ProductIOS extends ProductCommon {\n type: 'inapp' | 'iap';\n}\n\nexport type Product = ProductAndroid & ProductIOS;\n\n/**\n * Can be used to distinguish the different platforms' subscription information\n */\nexport enum SubscriptionPlatform {\n android = 'android',\n amazon = 'amazon',\n ios = 'ios',\n}\n\n/** Android Billing v5 type */\nexport interface SubscriptionAndroid {\n platform: SubscriptionPlatform.android;\n productType: 'subs';\n name: string;\n title: string;\n description: string;\n productId: string;\n subscriptionOfferDetails: SubscriptionOfferAndroid[];\n}\n\nexport interface SubscriptionOfferAndroid {\n offerToken: string;\n pricingPhases: {\n pricingPhaseList: PricingPhaseAndroid[];\n };\n offerTags: string[];\n}\n\nexport interface PricingPhaseAndroid {\n formattedPrice: string;\n priceCurrencyCode: string;\n /**\n * P1W, P1M, P1Y\n */\n billingPeriod: string;\n billingCycleCount: number;\n priceAmountMicros: string;\n recurrenceMode: number;\n}\n\n/**\n * TODO: As of 2022-10-10, this typing is not verified against the real\n * Amazon API. Please update this if you have a more accurate type.\n */\nexport interface SubscriptionAmazon extends ProductCommon {\n platform: SubscriptionPlatform.amazon;\n type: 'subs';\n\n productType?: string;\n name?: string;\n}\n\nexport type SubscriptionIosPeriod = 'DAY' | 'WEEK' | 'MONTH' | 'YEAR' | '';\nexport interface SubscriptionIOS extends ProductCommon {\n platform: SubscriptionPlatform.ios;\n type: 'subs';\n discounts?: Discount[];\n introductoryPrice?: string;\n introductoryPriceAsAmountIOS?: string;\n introductoryPricePaymentModeIOS?:\n | ''\n | 'FREETRIAL'\n | 'PAYASYOUGO'\n | 'PAYUPFRONT';\n introductoryPriceNumberOfPeriodsIOS?: string;\n introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;\n\n subscriptionPeriodNumberIOS?: string;\n subscriptionPeriodUnitIOS?: SubscriptionIosPeriod;\n}\n\nexport type Subscription =\n | SubscriptionAndroid\n | SubscriptionAmazon\n | SubscriptionIOS;\n\nexport interface RequestPurchaseBaseAndroid {\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price\n}\n\nexport interface RequestPurchaseAndroid extends RequestPurchaseBaseAndroid {\n skus: Sku[];\n}\n\nexport interface RequestPurchaseIOS {\n sku: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n /**\n * UUID representing user account\n */\n appAccountToken?: string;\n quantity?: number;\n withOffer?: Apple.PaymentDiscount;\n}\n\n/** As of 2022-10-12, we only use the `sku` field for Amazon purchases */\nexport type RequestPurchaseAmazon = RequestPurchaseIOS;\n\nexport type RequestPurchase =\n | RequestPurchaseAndroid\n | RequestPurchaseAmazon\n | RequestPurchaseIOS;\n\n/**\n * In order to purchase a new subscription, every sku must have a selected offerToken\n * @see SubscriptionAndroid.subscriptionOfferDetails.offerToken\n */\nexport interface SubscriptionOffer {\n sku: Sku;\n offerToken: string;\n}\n\nexport interface RequestSubscriptionAndroid extends RequestPurchaseBaseAndroid {\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n subscriptionOffers: SubscriptionOffer[];\n}\n\nexport type RequestSubscriptionIOS = RequestPurchaseIOS;\n\n/** As of 2022-10-12, we only use the `sku` field for Amazon subscriptions */\nexport type RequestSubscriptionAmazon = RequestSubscriptionIOS;\n\nexport type RequestSubscription =\n | RequestSubscriptionAndroid\n | RequestSubscriptionAmazon\n | RequestSubscriptionIOS;\n\ndeclare module 'react-native' {\n interface NativeModulesStatic {\n RNIapIos: IosModuleProps;\n RNIapIosSk2: IosModulePropsSk2;\n RNIapModule: AndroidModuleProps;\n RNIapAmazonModule: AmazonModuleProps;\n }\n}\n"],"mappings":";;;;;;IAWYA,qB;;;WAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,qCAAAA,qB;;IASAC,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB;;AAML,MAAMC,gBAAgB,GAAG,sBAAzB;;IAEKC,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB;;IAMAC,W;;;WAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,2BAAAA,W;;AA8FZ;AACA;AACA;IACYC,oB;AAMZ;;;;WANYA,oB;EAAAA,oB;EAAAA,oB;EAAAA,oB;GAAAA,oB,oCAAAA,oB"}
|
|
@@ -64,7 +64,7 @@ export const transactionSk2Map = _ref3 => {
|
|
|
64
64
|
purchaseToken: '',
|
|
65
65
|
//Not avaiable
|
|
66
66
|
quantityIOS: purchasedQuantity,
|
|
67
|
-
originalTransactionDateIOS:
|
|
67
|
+
originalTransactionDateIOS: originalPurchaseDate,
|
|
68
68
|
originalTransactionIdentifierIOS: originalID
|
|
69
69
|
};
|
|
70
70
|
return purchase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SubscriptionPlatform","productSk2Map","id","description","displayName","price","displayPrice","prod","title","productId","String","type","localizedPrice","currency","subscriptionSk2Map","subscription","platform","ios","subscriptionPeriodNumberIOS","subscriptionPeriod","value","subscriptionPeriodUnitIOS","unit","toUpperCase","transactionSk2Map","originalPurchaseDate","productID","purchaseDate","purchasedQuantity","originalID","purchase","transactionId","transactionDate","transactionReceipt","purchaseToken","quantityIOS","originalTransactionDateIOS","originalTransactionIdentifierIOS","offerSk2Map","offer","undefined","offerID","identifier","keyID","keyIdentifier","nonce","signature","timestamp","toString"],"sources":["appleSk2.ts"],"sourcesContent":["import type {PurchaseError} from '../purchaseError';\n\nimport type {\n ProductIOS,\n Purchase,\n SubscriptionIOS,\n SubscriptionIosPeriod,\n} from '.';\nimport type * as Apple from './apple';\nimport {SubscriptionPlatform} from '.';\n\nexport type SubscriptionPeriod = {\n unit: 'day' | 'week' | 'month' | 'year';\n value: number;\n};\n\nexport type PaymentMode = 'freeTrial' | 'payAsYouGo' | 'payUpFront';\n\nexport type SubscriptionOffer = {\n displayPrice: string;\n id: string;\n paymentMode: PaymentMode;\n period: SubscriptionPeriod;\n periodCount: number;\n price: number;\n type: 'introductory' | 'promotional';\n};\n\nexport type SubscriptionInfo = {\n introductoryOffer?: SubscriptionOffer;\n promotionalOffers?: SubscriptionOffer[];\n subscriptionGroupID: string;\n subscriptionPeriod: SubscriptionPeriod;\n};\n\nexport type RefundRequestStatus = 'success' | 'userCancelled';\n\nexport type ProductSk2 = {\n description: string;\n displayName: string;\n displayPrice: string;\n id: number;\n isFamilyShareable: boolean;\n jsonRepresentation: string;\n price: number;\n subscription: SubscriptionInfo;\n type: 'autoRenewable' | 'consumable' | 'nonConsumable' | 'nonRenewable';\n};\nexport const productSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n}: ProductSk2): ProductIOS => {\n const prod: ProductIOS = {\n title: displayName,\n productId: String(id),\n description,\n type: 'iap',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', // Not avaiable on new API, use localizedPrice instead\n };\n return prod;\n};\n\nexport const subscriptionSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n subscription,\n}: ProductSk2): SubscriptionIOS => {\n const prod: SubscriptionIOS = {\n platform: SubscriptionPlatform.ios,\n title: displayName,\n productId: String(id),\n description,\n type: 'subs',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', // Not avaiable on new API, use localizedPrice instead\n subscriptionPeriodNumberIOS: `${subscription?.subscriptionPeriod?.value}`,\n subscriptionPeriodUnitIOS:\n subscription?.subscriptionPeriod?.unit.toUpperCase() as SubscriptionIosPeriod,\n };\n return prod;\n};\n\nexport type TransactionSk2 = {\n appAccountToken: string;\n appBundleID: string;\n debugDescription: string;\n deviceVerification: string;\n deviceVerificationNonce: string;\n expirationDate: number;\n id: number;\n isUpgraded: boolean;\n jsonRepresentation: string;\n offerID: string;\n offerType: string;\n originalID: string;\n originalPurchaseDate: number;\n ownershipType: string;\n productID: string;\n productType: string;\n purchaseDate: number;\n purchasedQuantity: number;\n revocationDate: number;\n revocationReason: string;\n signedDate: number;\n subscriptionGroupID: number;\n webOrderLineItemID: number;\n};\n\nexport type TransactionError = PurchaseError;\n\n/**\n * Only one of `transaction` and `error` is not undefined at the time\n */\nexport type TransactionEvent = {\n transaction?: TransactionSk2;\n error?: TransactionError;\n};\n\nexport type SubscriptionStatus =\n | 'expired'\n | 'inBillingRetryPeriod'\n | 'inGracePeriod'\n | 'revoked'\n | 'subscribed';\n\nexport type ProductStatus = {\n state: SubscriptionStatus;\n};\n\nexport const transactionSk2Map = ({\n id,\n originalPurchaseDate,\n productID,\n purchaseDate,\n purchasedQuantity,\n originalID,\n}: TransactionSk2): Purchase => {\n const purchase: Purchase = {\n productId: productID,\n transactionId: String(id),\n transactionDate: purchaseDate, //??\n transactionReceipt: '', // Not available\n purchaseToken: '', //Not avaiable\n quantityIOS: purchasedQuantity,\n originalTransactionDateIOS:
|
|
1
|
+
{"version":3,"names":["SubscriptionPlatform","productSk2Map","id","description","displayName","price","displayPrice","prod","title","productId","String","type","localizedPrice","currency","subscriptionSk2Map","subscription","platform","ios","subscriptionPeriodNumberIOS","subscriptionPeriod","value","subscriptionPeriodUnitIOS","unit","toUpperCase","transactionSk2Map","originalPurchaseDate","productID","purchaseDate","purchasedQuantity","originalID","purchase","transactionId","transactionDate","transactionReceipt","purchaseToken","quantityIOS","originalTransactionDateIOS","originalTransactionIdentifierIOS","offerSk2Map","offer","undefined","offerID","identifier","keyID","keyIdentifier","nonce","signature","timestamp","toString"],"sources":["appleSk2.ts"],"sourcesContent":["import type {PurchaseError} from '../purchaseError';\n\nimport type {\n ProductIOS,\n Purchase,\n SubscriptionIOS,\n SubscriptionIosPeriod,\n} from '.';\nimport type * as Apple from './apple';\nimport {SubscriptionPlatform} from '.';\n\nexport type SubscriptionPeriod = {\n unit: 'day' | 'week' | 'month' | 'year';\n value: number;\n};\n\nexport type PaymentMode = 'freeTrial' | 'payAsYouGo' | 'payUpFront';\n\nexport type SubscriptionOffer = {\n displayPrice: string;\n id: string;\n paymentMode: PaymentMode;\n period: SubscriptionPeriod;\n periodCount: number;\n price: number;\n type: 'introductory' | 'promotional';\n};\n\nexport type SubscriptionInfo = {\n introductoryOffer?: SubscriptionOffer;\n promotionalOffers?: SubscriptionOffer[];\n subscriptionGroupID: string;\n subscriptionPeriod: SubscriptionPeriod;\n};\n\nexport type RefundRequestStatus = 'success' | 'userCancelled';\n\nexport type ProductSk2 = {\n description: string;\n displayName: string;\n displayPrice: string;\n id: number;\n isFamilyShareable: boolean;\n jsonRepresentation: string;\n price: number;\n subscription: SubscriptionInfo;\n type: 'autoRenewable' | 'consumable' | 'nonConsumable' | 'nonRenewable';\n};\nexport const productSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n}: ProductSk2): ProductIOS => {\n const prod: ProductIOS = {\n title: displayName,\n productId: String(id),\n description,\n type: 'iap',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', // Not avaiable on new API, use localizedPrice instead\n };\n return prod;\n};\n\nexport const subscriptionSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n subscription,\n}: ProductSk2): SubscriptionIOS => {\n const prod: SubscriptionIOS = {\n platform: SubscriptionPlatform.ios,\n title: displayName,\n productId: String(id),\n description,\n type: 'subs',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', // Not avaiable on new API, use localizedPrice instead\n subscriptionPeriodNumberIOS: `${subscription?.subscriptionPeriod?.value}`,\n subscriptionPeriodUnitIOS:\n subscription?.subscriptionPeriod?.unit.toUpperCase() as SubscriptionIosPeriod,\n };\n return prod;\n};\n\nexport type TransactionSk2 = {\n appAccountToken: string;\n appBundleID: string;\n debugDescription: string;\n deviceVerification: string;\n deviceVerificationNonce: string;\n expirationDate: number;\n id: number;\n isUpgraded: boolean;\n jsonRepresentation: string;\n offerID: string;\n offerType: string;\n originalID: string;\n originalPurchaseDate: number;\n ownershipType: string;\n productID: string;\n productType: string;\n purchaseDate: number;\n purchasedQuantity: number;\n revocationDate: number;\n revocationReason: string;\n signedDate: number;\n subscriptionGroupID: number;\n webOrderLineItemID: number;\n};\n\nexport type TransactionError = PurchaseError;\n\n/**\n * Only one of `transaction` and `error` is not undefined at the time\n */\nexport type TransactionEvent = {\n transaction?: TransactionSk2;\n error?: TransactionError;\n};\n\nexport type SubscriptionStatus =\n | 'expired'\n | 'inBillingRetryPeriod'\n | 'inGracePeriod'\n | 'revoked'\n | 'subscribed';\n\nexport type ProductStatus = {\n state: SubscriptionStatus;\n};\n\nexport const transactionSk2Map = ({\n id,\n originalPurchaseDate,\n productID,\n purchaseDate,\n purchasedQuantity,\n originalID,\n}: TransactionSk2): Purchase => {\n const purchase: Purchase = {\n productId: productID,\n transactionId: String(id),\n transactionDate: purchaseDate, //??\n transactionReceipt: '', // Not available\n purchaseToken: '', //Not avaiable\n quantityIOS: purchasedQuantity,\n originalTransactionDateIOS: originalPurchaseDate,\n originalTransactionIdentifierIOS: originalID,\n };\n return purchase;\n};\n\n/**\n * Payment discount interface @see https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc\n */\nexport interface PaymentDiscountSk2 {\n /**\n * A string used to uniquely identify a discount offer for a product.\n */\n offerID: string;\n\n /**\n * A string that identifies the key used to generate the signature.\n */\n keyID: string;\n\n /**\n * A universally unique ID (UUID) value that you define.\n */\n nonce: string;\n\n /**\n * A UTF-8 string representing the properties of a specific discount offer, cryptographically signed.\n */\n signature: string;\n\n /**\n * The date and time of the signature's creation in milliseconds, formatted in Unix epoch time.\n */\n timestamp: number;\n}\n\nexport const offerSk2Map = (\n offer: Apple.PaymentDiscount | undefined,\n): Record<keyof PaymentDiscountSk2, string> | undefined => {\n if (!offer) {\n return undefined;\n }\n return {\n offerID: offer.identifier,\n keyID: offer.keyIdentifier,\n nonce: offer.nonce,\n signature: offer.signature,\n timestamp: offer.timestamp.toString(),\n };\n};\n"],"mappings":"AASA,SAAQA,oBAAR,QAAmC,GAAnC;AAuCA,OAAO,MAAMC,aAAa,GAAG,QAMC;EAAA,IANA;IAC5BC,EAD4B;IAE5BC,WAF4B;IAG5BC,WAH4B;IAI5BC,KAJ4B;IAK5BC;EAL4B,CAMA;EAC5B,MAAMC,IAAgB,GAAG;IACvBC,KAAK,EAAEJ,WADgB;IAEvBK,SAAS,EAAEC,MAAM,CAACR,EAAD,CAFM;IAGvBC,WAHuB;IAIvBQ,IAAI,EAAE,KAJiB;IAKvBN,KAAK,EAAEK,MAAM,CAACL,KAAD,CALU;IAMvBO,cAAc,EAAEN,YANO;IAOvBO,QAAQ,EAAE,EAPa,CAOT;;EAPS,CAAzB;EASA,OAAON,IAAP;AACD,CAjBM;AAmBP,OAAO,MAAMO,kBAAkB,GAAG,SAOC;EAAA;;EAAA,IAPA;IACjCZ,EADiC;IAEjCC,WAFiC;IAGjCC,WAHiC;IAIjCC,KAJiC;IAKjCC,YALiC;IAMjCS;EANiC,CAOA;EACjC,MAAMR,IAAqB,GAAG;IAC5BS,QAAQ,EAAEhB,oBAAoB,CAACiB,GADH;IAE5BT,KAAK,EAAEJ,WAFqB;IAG5BK,SAAS,EAAEC,MAAM,CAACR,EAAD,CAHW;IAI5BC,WAJ4B;IAK5BQ,IAAI,EAAE,MALsB;IAM5BN,KAAK,EAAEK,MAAM,CAACL,KAAD,CANe;IAO5BO,cAAc,EAAEN,YAPY;IAQ5BO,QAAQ,EAAE,EARkB;IAQd;IACdK,2BAA2B,EAAG,GAAEH,YAAH,aAAGA,YAAH,gDAAGA,YAAY,CAAEI,kBAAjB,0DAAG,sBAAkCC,KAAM,EAT5C;IAU5BC,yBAAyB,EACvBN,YADuB,aACvBA,YADuB,iDACvBA,YAAY,CAAEI,kBADS,2DACvB,uBAAkCG,IAAlC,CAAuCC,WAAvC;EAX0B,CAA9B;EAaA,OAAOhB,IAAP;AACD,CAtBM;AAuEP,OAAO,MAAMiB,iBAAiB,GAAG,SAOD;EAAA,IAPE;IAChCtB,EADgC;IAEhCuB,oBAFgC;IAGhCC,SAHgC;IAIhCC,YAJgC;IAKhCC,iBALgC;IAMhCC;EANgC,CAOF;EAC9B,MAAMC,QAAkB,GAAG;IACzBrB,SAAS,EAAEiB,SADc;IAEzBK,aAAa,EAAErB,MAAM,CAACR,EAAD,CAFI;IAGzB8B,eAAe,EAAEL,YAHQ;IAGM;IAC/BM,kBAAkB,EAAE,EAJK;IAID;IACxBC,aAAa,EAAE,EALU;IAKN;IACnBC,WAAW,EAAEP,iBANY;IAOzBQ,0BAA0B,EAAEX,oBAPH;IAQzBY,gCAAgC,EAAER;EART,CAA3B;EAUA,OAAOC,QAAP;AACD,CAnBM;AAqBP;AACA;AACA;;AA4BA,OAAO,MAAMQ,WAAW,GACtBC,KADyB,IAEgC;EACzD,IAAI,CAACA,KAAL,EAAY;IACV,OAAOC,SAAP;EACD;;EACD,OAAO;IACLC,OAAO,EAAEF,KAAK,CAACG,UADV;IAELC,KAAK,EAAEJ,KAAK,CAACK,aAFR;IAGLC,KAAK,EAAEN,KAAK,CAACM,KAHR;IAILC,SAAS,EAAEP,KAAK,CAACO,SAJZ;IAKLC,SAAS,EAAER,KAAK,CAACQ,SAAN,CAAgBC,QAAhB;EALN,CAAP;AAOD,CAbM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid","ProductType","SubscriptionPlatform"],"sources":["index.ts"],"sourcesContent":["import type {\n AmazonModuleProps,\n AndroidModuleProps,\n IosModuleProps,\n} from '../modules';\nimport type {IosModulePropsSk2} from '../modules/iosSk2';\n\nimport type * as Apple from './apple';\n\nexport type Sku = string;\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n IMMEDIATE_AND_CHARGE_FULL_PRICE = 5,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport enum ProductType {\n /** Subscription */\n subs = 'subs',\n\n /** Subscription */\n sub = 'sub',\n\n /** Consumable */\n inapp = 'inapp',\n\n /** Consumable */\n iap = 'iap',\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string; //iOS\n productIds?: string[];\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?:
|
|
1
|
+
{"version":3,"names":["ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid","ProductType","SubscriptionPlatform"],"sources":["index.ts"],"sourcesContent":["import type {\n AmazonModuleProps,\n AndroidModuleProps,\n IosModuleProps,\n} from '../modules';\nimport type {IosModulePropsSk2} from '../modules/iosSk2';\n\nimport type * as Apple from './apple';\n\nexport type Sku = string;\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n IMMEDIATE_AND_CHARGE_FULL_PRICE = 5,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport enum ProductType {\n /** Subscription */\n subs = 'subs',\n\n /** Subscription */\n sub = 'sub',\n\n /** Consumable */\n inapp = 'inapp',\n\n /** Consumable */\n iap = 'iap',\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string; //iOS\n productIds?: string[];\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?: number;\n originalTransactionIdentifierIOS?: string;\n //Android\n productIds?: string[];\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n //Amazon\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n isCanceledAmazon?: boolean;\n}\n\nexport interface PurchaseResult {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n purchaseToken?: string;\n}\n\nexport interface SubscriptionPurchase extends ProductPurchase {\n autoRenewingAndroid?: boolean;\n originalTransactionDateIOS?: number;\n originalTransactionIdentifierIOS?: string;\n}\n\nexport type Purchase = ProductPurchase | SubscriptionPurchase;\n\nexport interface Discount {\n identifier: string;\n type: string;\n numberOfPeriods: string;\n price: string;\n localizedPrice: string;\n paymentMode: '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';\n subscriptionPeriod: string;\n}\n\nexport interface ProductAndroid extends ProductCommon {\n type: 'inapp' | 'iap';\n oneTimePurchaseOfferDetails?: {\n priceCurrencyCode: string;\n formattedPrice: string;\n priceAmountMicros: string;\n };\n}\nexport interface ProductIOS extends ProductCommon {\n type: 'inapp' | 'iap';\n}\n\nexport type Product = ProductAndroid & ProductIOS;\n\n/**\n * Can be used to distinguish the different platforms' subscription information\n */\nexport enum SubscriptionPlatform {\n android = 'android',\n amazon = 'amazon',\n ios = 'ios',\n}\n\n/** Android Billing v5 type */\nexport interface SubscriptionAndroid {\n platform: SubscriptionPlatform.android;\n productType: 'subs';\n name: string;\n title: string;\n description: string;\n productId: string;\n subscriptionOfferDetails: SubscriptionOfferAndroid[];\n}\n\nexport interface SubscriptionOfferAndroid {\n offerToken: string;\n pricingPhases: {\n pricingPhaseList: PricingPhaseAndroid[];\n };\n offerTags: string[];\n}\n\nexport interface PricingPhaseAndroid {\n formattedPrice: string;\n priceCurrencyCode: string;\n /**\n * P1W, P1M, P1Y\n */\n billingPeriod: string;\n billingCycleCount: number;\n priceAmountMicros: string;\n recurrenceMode: number;\n}\n\n/**\n * TODO: As of 2022-10-10, this typing is not verified against the real\n * Amazon API. Please update this if you have a more accurate type.\n */\nexport interface SubscriptionAmazon extends ProductCommon {\n platform: SubscriptionPlatform.amazon;\n type: 'subs';\n\n productType?: string;\n name?: string;\n}\n\nexport type SubscriptionIosPeriod = 'DAY' | 'WEEK' | 'MONTH' | 'YEAR' | '';\nexport interface SubscriptionIOS extends ProductCommon {\n platform: SubscriptionPlatform.ios;\n type: 'subs';\n discounts?: Discount[];\n introductoryPrice?: string;\n introductoryPriceAsAmountIOS?: string;\n introductoryPricePaymentModeIOS?:\n | ''\n | 'FREETRIAL'\n | 'PAYASYOUGO'\n | 'PAYUPFRONT';\n introductoryPriceNumberOfPeriodsIOS?: string;\n introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;\n\n subscriptionPeriodNumberIOS?: string;\n subscriptionPeriodUnitIOS?: SubscriptionIosPeriod;\n}\n\nexport type Subscription =\n | SubscriptionAndroid\n | SubscriptionAmazon\n | SubscriptionIOS;\n\nexport interface RequestPurchaseBaseAndroid {\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price\n}\n\nexport interface RequestPurchaseAndroid extends RequestPurchaseBaseAndroid {\n skus: Sku[];\n}\n\nexport interface RequestPurchaseIOS {\n sku: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n /**\n * UUID representing user account\n */\n appAccountToken?: string;\n quantity?: number;\n withOffer?: Apple.PaymentDiscount;\n}\n\n/** As of 2022-10-12, we only use the `sku` field for Amazon purchases */\nexport type RequestPurchaseAmazon = RequestPurchaseIOS;\n\nexport type RequestPurchase =\n | RequestPurchaseAndroid\n | RequestPurchaseAmazon\n | RequestPurchaseIOS;\n\n/**\n * In order to purchase a new subscription, every sku must have a selected offerToken\n * @see SubscriptionAndroid.subscriptionOfferDetails.offerToken\n */\nexport interface SubscriptionOffer {\n sku: Sku;\n offerToken: string;\n}\n\nexport interface RequestSubscriptionAndroid extends RequestPurchaseBaseAndroid {\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n subscriptionOffers: SubscriptionOffer[];\n}\n\nexport type RequestSubscriptionIOS = RequestPurchaseIOS;\n\n/** As of 2022-10-12, we only use the `sku` field for Amazon subscriptions */\nexport type RequestSubscriptionAmazon = RequestSubscriptionIOS;\n\nexport type RequestSubscription =\n | RequestSubscriptionAndroid\n | RequestSubscriptionAmazon\n | RequestSubscriptionIOS;\n\ndeclare module 'react-native' {\n interface NativeModulesStatic {\n RNIapIos: IosModuleProps;\n RNIapIosSk2: IosModulePropsSk2;\n RNIapModule: AndroidModuleProps;\n RNIapAmazonModule: AmazonModuleProps;\n }\n}\n"],"mappings":"AAWA,WAAYA,qBAAZ;;WAAYA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,KAAAA,qB;;AASZ,WAAYC,oBAAZ;;WAAYA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,KAAAA,oB;;AAMZ,OAAO,MAAMC,gBAAgB,GAAG,sBAAzB;AAEP,WAAYC,oBAAZ;;WAAYA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,KAAAA,oB;;AAMZ,WAAYC,WAAZ;;WAAYA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,KAAAA,W;;AA8FZ;AACA;AACA;AACA,WAAYC,oBAAZ;AAMA;;WANYA,oB;EAAAA,oB;EAAAA,oB;EAAAA,oB;GAAAA,oB,KAAAA,oB"}
|
|
@@ -49,7 +49,7 @@ export interface ProductPurchase {
|
|
|
49
49
|
transactionReceipt: string;
|
|
50
50
|
purchaseToken?: string;
|
|
51
51
|
quantityIOS?: number;
|
|
52
|
-
originalTransactionDateIOS?:
|
|
52
|
+
originalTransactionDateIOS?: number;
|
|
53
53
|
originalTransactionIdentifierIOS?: string;
|
|
54
54
|
productIds?: string[];
|
|
55
55
|
dataAndroid?: string;
|
|
@@ -75,7 +75,7 @@ export interface PurchaseResult {
|
|
|
75
75
|
}
|
|
76
76
|
export interface SubscriptionPurchase extends ProductPurchase {
|
|
77
77
|
autoRenewingAndroid?: boolean;
|
|
78
|
-
originalTransactionDateIOS?:
|
|
78
|
+
originalTransactionDateIOS?: number;
|
|
79
79
|
originalTransactionIdentifierIOS?: string;
|
|
80
80
|
}
|
|
81
81
|
export declare type Purchase = ProductPurchase | SubscriptionPurchase;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-iap",
|
|
3
|
-
"version": "12.4.
|
|
3
|
+
"version": "12.4.5",
|
|
4
4
|
"description": "React Native In App Purchase Module.",
|
|
5
5
|
"repository": "https://github.com/dooboolab/react-native-iap",
|
|
6
6
|
"author": "dooboolab <support@dooboolab.com> (https://github.com/dooboolab)",
|
package/src/types/appleSk2.ts
CHANGED
|
@@ -151,7 +151,7 @@ export const transactionSk2Map = ({
|
|
|
151
151
|
transactionReceipt: '', // Not available
|
|
152
152
|
purchaseToken: '', //Not avaiable
|
|
153
153
|
quantityIOS: purchasedQuantity,
|
|
154
|
-
originalTransactionDateIOS:
|
|
154
|
+
originalTransactionDateIOS: originalPurchaseDate,
|
|
155
155
|
originalTransactionIdentifierIOS: originalID,
|
|
156
156
|
};
|
|
157
157
|
return purchase;
|
package/src/types/index.ts
CHANGED
|
@@ -66,7 +66,7 @@ export interface ProductPurchase {
|
|
|
66
66
|
purchaseToken?: string;
|
|
67
67
|
//iOS
|
|
68
68
|
quantityIOS?: number;
|
|
69
|
-
originalTransactionDateIOS?:
|
|
69
|
+
originalTransactionDateIOS?: number;
|
|
70
70
|
originalTransactionIdentifierIOS?: string;
|
|
71
71
|
//Android
|
|
72
72
|
productIds?: string[];
|
|
@@ -96,7 +96,7 @@ export interface PurchaseResult {
|
|
|
96
96
|
|
|
97
97
|
export interface SubscriptionPurchase extends ProductPurchase {
|
|
98
98
|
autoRenewingAndroid?: boolean;
|
|
99
|
-
originalTransactionDateIOS?:
|
|
99
|
+
originalTransactionDateIOS?: number;
|
|
100
100
|
originalTransactionIdentifierIOS?: string;
|
|
101
101
|
}
|
|
102
102
|
|