react-native-iap 8.4.0 → 9.0.0-beta
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/.yarn/install-state.gz +0 -0
- package/android/build.gradle +3 -3
- package/android/src/amazon/java/com/dooboolab/RNIap/RNIapAmazonListener.kt +16 -4
- package/android/src/play/java/com/dooboolab/RNIap/RNIapModule.kt +142 -97
- package/android/src/play/java/com/dooboolab/RNIap/RNIapModuleInterface.kt +44 -0
- package/android/src/play/java/com/dooboolab/RNIap/RNIapModuleV4.kt +656 -0
- package/android/src/play/java/com/dooboolab/RNIap/RNIapPackage.kt +1 -0
- package/android/src/testPlay/java/com/dooboolab/RNIap/{RNIapModuleTest.kt → RNIapModuleTestV4.kt} +5 -5
- package/package.json +1 -1
- package/src/iap.d.ts +1 -1
- package/src/iap.js +24 -10
- package/src/types/index.d.ts +22 -0
package/android/src/testPlay/java/com/dooboolab/RNIap/{RNIapModuleTest.kt → RNIapModuleTestV4.kt}
RENAMED
|
@@ -30,7 +30,7 @@ import org.junit.Assert.assertTrue
|
|
|
30
30
|
import org.junit.Before
|
|
31
31
|
import org.junit.Test
|
|
32
32
|
|
|
33
|
-
class
|
|
33
|
+
class RNIapModuleTestV4 {
|
|
34
34
|
|
|
35
35
|
@MockK
|
|
36
36
|
lateinit var context: ReactApplicationContext
|
|
@@ -44,14 +44,14 @@ class RNIapModuleTest {
|
|
|
44
44
|
@MockK
|
|
45
45
|
lateinit var availability: GoogleApiAvailability
|
|
46
46
|
|
|
47
|
-
private lateinit var module:
|
|
47
|
+
private lateinit var module: RNIapModuleV4
|
|
48
48
|
|
|
49
49
|
@Before
|
|
50
50
|
fun setUp() {
|
|
51
51
|
MockKAnnotations.init(this, relaxUnitFun = true)
|
|
52
52
|
every { builder.setListener(any()) } returns builder
|
|
53
53
|
every { builder.build() } returns billingClient
|
|
54
|
-
module =
|
|
54
|
+
module = RNIapModuleV4(context, builder, availability)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
@Test
|
|
@@ -134,7 +134,7 @@ class RNIapModuleTest {
|
|
|
134
134
|
every { billingClient.isReady } returns true
|
|
135
135
|
val promise = mockk<Promise>(relaxed = true)
|
|
136
136
|
val listener = slot<PurchasesResponseListener>()
|
|
137
|
-
every { billingClient.queryPurchasesAsync(any(), capture(listener)) } answers {
|
|
137
|
+
every { billingClient.queryPurchasesAsync(any<String>(), capture(listener)) } answers {
|
|
138
138
|
listener.captured.onQueryPurchasesResponse(BillingResult.newBuilder().build(), listOf())
|
|
139
139
|
}
|
|
140
140
|
module.initConnection(mockk())
|
|
@@ -150,7 +150,7 @@ class RNIapModuleTest {
|
|
|
150
150
|
every { billingClient.isReady } returns true
|
|
151
151
|
val promise = mockk<Promise>(relaxed = true)
|
|
152
152
|
val listener = slot<PurchasesResponseListener>()
|
|
153
|
-
every { billingClient.queryPurchasesAsync(any(), capture(listener)) } answers {
|
|
153
|
+
every { billingClient.queryPurchasesAsync(any<String>(), capture(listener)) } answers {
|
|
154
154
|
listener.captured.onQueryPurchasesResponse(
|
|
155
155
|
BillingResult.newBuilder().build(),
|
|
156
156
|
listOf(
|
package/package.json
CHANGED
package/src/iap.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export declare const getAvailablePurchases: () => Promise<(InAppPurchase | Subsc
|
|
|
50
50
|
* @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
|
|
51
51
|
* @returns {Promise<InAppPurchase>}
|
|
52
52
|
*/
|
|
53
|
-
export declare const requestPurchase: (sku: string, appAccountToken: string, andDangerouslyFinishTransactionAutomaticallyIOS?: boolean, obfuscatedAccountIdAndroid?: string | undefined, obfuscatedProfileIdAndroid?: string | undefined) => Promise<InAppPurchase>;
|
|
53
|
+
export declare const requestPurchase: (sku: string, appAccountToken: string, andDangerouslyFinishTransactionAutomaticallyIOS?: boolean, obfuscatedAccountIdAndroid?: string | undefined, obfuscatedProfileIdAndroid?: string | undefined, selectedOfferIndex?: number | undefined) => Promise<InAppPurchase>;
|
|
54
54
|
/**
|
|
55
55
|
* Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
|
|
56
56
|
* @param {string} [sku] The product's sku/ID
|
package/src/iap.js
CHANGED
|
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
import * as Apple from './types/apple';
|
|
38
38
|
import { Linking, NativeEventEmitter, NativeModules, Platform, } from 'react-native';
|
|
39
39
|
import { IAPErrorCode, InstallSourceAndroid, PurchaseStateAndroid, } from './types';
|
|
40
|
-
var RNIapIos = NativeModules.RNIapIos, RNIapModule = NativeModules.RNIapModule, RNIapAmazonModule = NativeModules.RNIapAmazonModule;
|
|
40
|
+
var RNIapIos = NativeModules.RNIapIos, RNIapModule = NativeModules.RNIapModule, RNIapModuleV4 = NativeModules.RNIapModuleV4, RNIapAmazonModule = NativeModules.RNIapAmazonModule;
|
|
41
41
|
var ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';
|
|
42
42
|
var ANDROID_ITEM_TYPE_IAP = 'inapp';
|
|
43
43
|
export var getInstallSourceAndroid = function () {
|
|
@@ -45,14 +45,25 @@ export var getInstallSourceAndroid = function () {
|
|
|
45
45
|
? InstallSourceAndroid.GOOGLE_PLAY
|
|
46
46
|
: InstallSourceAndroid.AMAZON;
|
|
47
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Defaulting to V4 to minimize migration, it'll eventually be changed to default to V5
|
|
50
|
+
*/
|
|
51
|
+
var androidNativeModule = RNIapModuleV4;
|
|
52
|
+
var setAndroidNativeModule = function (nativeModule) {
|
|
53
|
+
androidNativeModule = nativeModule;
|
|
54
|
+
};
|
|
48
55
|
var checkNativeAndroidAvailable = function () {
|
|
49
|
-
if (!RNIapModule && !RNIapAmazonModule) {
|
|
56
|
+
if (!RNIapModule && !RNIapModuleV4 && !RNIapAmazonModule) {
|
|
50
57
|
throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);
|
|
51
58
|
}
|
|
52
59
|
};
|
|
53
60
|
var getAndroidModule = function () {
|
|
54
61
|
checkNativeAndroidAvailable();
|
|
55
|
-
return
|
|
62
|
+
return androidNativeModule
|
|
63
|
+
? androidNativeModule
|
|
64
|
+
: RNIapModule
|
|
65
|
+
? RNIapModule
|
|
66
|
+
: RNIapAmazonModule;
|
|
56
67
|
};
|
|
57
68
|
var checkNativeiOSAvailable = function () {
|
|
58
69
|
if (!RNIapIos) {
|
|
@@ -64,11 +75,13 @@ var getIosModule = function () {
|
|
|
64
75
|
return RNIapIos;
|
|
65
76
|
};
|
|
66
77
|
var getNativeModule = function () {
|
|
67
|
-
return
|
|
68
|
-
?
|
|
69
|
-
:
|
|
70
|
-
?
|
|
71
|
-
:
|
|
78
|
+
return androidNativeModule
|
|
79
|
+
? androidNativeModule
|
|
80
|
+
: RNIapModule
|
|
81
|
+
? RNIapModule
|
|
82
|
+
: RNIapAmazonModule
|
|
83
|
+
? RNIapAmazonModule
|
|
84
|
+
: RNIapIos;
|
|
72
85
|
};
|
|
73
86
|
/**
|
|
74
87
|
* Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.
|
|
@@ -260,10 +273,11 @@ export var getAvailablePurchases = function () {
|
|
|
260
273
|
* @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
|
|
261
274
|
* @returns {Promise<InAppPurchase>}
|
|
262
275
|
*/
|
|
263
|
-
export var requestPurchase = function (sku, appAccountToken, andDangerouslyFinishTransactionAutomaticallyIOS, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid) {
|
|
276
|
+
export var requestPurchase = function (sku, appAccountToken, andDangerouslyFinishTransactionAutomaticallyIOS, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, selectedOfferIndex) {
|
|
264
277
|
if (andDangerouslyFinishTransactionAutomaticallyIOS === void 0) { andDangerouslyFinishTransactionAutomaticallyIOS = false; }
|
|
265
278
|
if (obfuscatedAccountIdAndroid === void 0) { obfuscatedAccountIdAndroid = undefined; }
|
|
266
279
|
if (obfuscatedProfileIdAndroid === void 0) { obfuscatedProfileIdAndroid = undefined; }
|
|
280
|
+
if (selectedOfferIndex === void 0) { selectedOfferIndex = undefined; }
|
|
267
281
|
return (Platform.select({
|
|
268
282
|
ios: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
269
283
|
return __generator(this, function (_a) {
|
|
@@ -278,7 +292,7 @@ export var requestPurchase = function (sku, appAccountToken, andDangerouslyFinis
|
|
|
278
292
|
}); },
|
|
279
293
|
android: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
280
294
|
return __generator(this, function (_a) {
|
|
281
|
-
return [2 /*return*/, getAndroidModule().buyItemByType(ANDROID_ITEM_TYPE_IAP, sku, null, 0, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid)];
|
|
295
|
+
return [2 /*return*/, getAndroidModule().buyItemByType(ANDROID_ITEM_TYPE_IAP, sku, null, 0, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, selectedOfferIndex)];
|
|
282
296
|
});
|
|
283
297
|
}); },
|
|
284
298
|
}) || Promise.resolve)();
|
package/src/types/index.d.ts
CHANGED
|
@@ -62,6 +62,28 @@ export interface ProductPurchase {
|
|
|
62
62
|
developerPayloadAndroid?: string;
|
|
63
63
|
obfuscatedAccountIdAndroid?: string;
|
|
64
64
|
obfuscatedProfileIdAndroid?: string;
|
|
65
|
+
title?: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
productType?: string;
|
|
68
|
+
name?: string;
|
|
69
|
+
oneTimePurchaseOfferDetails?: {
|
|
70
|
+
priceCurrencyCode?: string;
|
|
71
|
+
formattedPrice?: string;
|
|
72
|
+
priceAmountMicros?: string;
|
|
73
|
+
}[];
|
|
74
|
+
subscriptionOfferDetails?: {
|
|
75
|
+
offerToken?: string[];
|
|
76
|
+
pricingPhases: {
|
|
77
|
+
pricingPhaseList: {
|
|
78
|
+
formattedPrice?: string;
|
|
79
|
+
priceCurrencyCode?: string;
|
|
80
|
+
billingPeriod?: string;
|
|
81
|
+
billingCycleCount?: number;
|
|
82
|
+
priceAmountMicros?: string;
|
|
83
|
+
recurrenceMode?: number;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
}[];
|
|
65
87
|
userIdAmazon?: string;
|
|
66
88
|
userMarketplaceAmazon?: string;
|
|
67
89
|
userJsonAmazon?: string;
|