react-native-iap 14.3.7 → 14.3.8
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/README.md +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +61 -11
- package/ios/HybridRnIap.swift +47 -12
- package/lib/module/hooks/useIAP.js +31 -21
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/index.js +580 -695
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +12 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/purchase.js +22 -0
- package/lib/module/utils/purchase.js.map +1 -0
- package/lib/module/utils.js +43 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/plugin/src/withIAP.d.ts +1 -0
- package/lib/typescript/plugin/src/withIAP.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts +4 -5
- package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +57 -176
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +113 -154
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +99 -76
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/purchase.d.ts +4 -0
- package/lib/typescript/src/utils/purchase.d.ts.map +1 -0
- package/lib/typescript/src/utils.d.ts +8 -0
- package/lib/typescript/src/utils.d.ts.map +1 -0
- package/nitrogen/generated/android/NitroIap+autolinking.cmake +1 -1
- package/nitrogen/generated/android/c++/{JNitroSubscriptionOffer.hpp → JAndroidSubscriptionOfferInput.hpp} +15 -15
- package/nitrogen/generated/android/c++/JFunc_void_NitroProduct.hpp +2 -0
- package/nitrogen/generated/android/c++/JFunc_void_NitroPurchase.hpp +4 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +16 -16
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroAvailablePurchasesAndroidOptions.hpp +6 -5
- package/nitrogen/generated/android/c++/JNitroAvailablePurchasesAndroidType.hpp +59 -0
- package/nitrogen/generated/android/c++/JNitroAvailablePurchasesOptions.hpp +2 -1
- package/nitrogen/generated/android/c++/JNitroProduct.hpp +22 -20
- package/nitrogen/generated/android/c++/JNitroPurchase.hpp +12 -8
- package/nitrogen/generated/android/c++/JNitroPurchaseRequest.hpp +2 -2
- package/nitrogen/generated/android/c++/JNitroReceiptValidationAndroidOptions.hpp +10 -10
- package/nitrogen/generated/android/c++/JNitroReceiptValidationResultAndroid.hpp +6 -6
- package/nitrogen/generated/android/c++/JNitroReceiptValidationResultIOS.hpp +4 -0
- package/nitrogen/generated/android/c++/JNitroRequestPurchaseAndroid.hpp +7 -7
- package/nitrogen/generated/android/c++/JRequestPurchaseResult.cpp +39 -0
- package/nitrogen/generated/android/c++/JRequestPurchaseResult.hpp +68 -53
- package/nitrogen/generated/android/c++/JVariant_NitroReceiptValidationResultIOS_NitroReceiptValidationResultAndroid.hpp +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/{NitroSubscriptionOffer.kt → AndroidSubscriptionOfferInput.kt} +5 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroAvailablePurchasesAndroidOptions.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroAvailablePurchasesAndroidType.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroProduct.kt +11 -11
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchase.kt +2 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroReceiptValidationAndroidOptions.kt +4 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroReceiptValidationResultAndroid.kt +2 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroRequestPurchaseAndroid.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/RequestPurchaseResult.kt +31 -13
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +4 -4
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +99 -64
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +6 -6
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +10 -10
- package/nitrogen/generated/ios/swift/{NitroSubscriptionOffer.swift → AndroidSubscriptionOfferInput.swift} +13 -13
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__variant_PurchaseAndroid__PurchaseIOS__std__vector_std__variant_PurchaseAndroid__PurchaseIOS____.swift +81 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +35 -7
- package/nitrogen/generated/ios/swift/NitroAvailablePurchasesAndroidOptions.swift +7 -14
- package/nitrogen/generated/ios/swift/NitroAvailablePurchasesAndroidType.swift +40 -0
- package/nitrogen/generated/ios/swift/NitroProduct.swift +72 -72
- package/nitrogen/generated/ios/swift/NitroPurchase.swift +8 -8
- package/nitrogen/generated/ios/swift/NitroReceiptValidationAndroidOptions.swift +21 -21
- package/nitrogen/generated/ios/swift/NitroReceiptValidationResultAndroid.swift +37 -11
- package/nitrogen/generated/ios/swift/NitroRequestPurchaseAndroid.swift +11 -11
- package/nitrogen/generated/ios/swift/RequestPurchaseResult.swift +8 -137
- package/nitrogen/generated/shared/c++/{NitroSubscriptionOffer.hpp → AndroidSubscriptionOfferInput.hpp} +15 -15
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +9 -6
- package/nitrogen/generated/shared/c++/NitroAvailablePurchasesAndroidOptions.hpp +8 -7
- package/nitrogen/generated/shared/c++/NitroAvailablePurchasesAndroidType.hpp +76 -0
- package/nitrogen/generated/shared/c++/NitroProduct.hpp +24 -22
- package/nitrogen/generated/shared/c++/NitroPurchase.hpp +15 -10
- package/nitrogen/generated/shared/c++/NitroReceiptValidationAndroidOptions.hpp +10 -10
- package/nitrogen/generated/shared/c++/NitroReceiptValidationResultAndroid.hpp +9 -9
- package/nitrogen/generated/shared/c++/NitroRequestPurchaseAndroid.hpp +8 -8
- package/package.json +2 -2
- package/plugin/build/withIAP.d.ts +1 -0
- package/plugin/build/withIAP.js +8 -2
- package/plugin/src/withIAP.ts +13 -3
- package/src/hooks/useIAP.ts +63 -32
- package/src/index.ts +716 -790
- package/src/specs/RnIap.nitro.ts +131 -163
- package/src/types.ts +131 -85
- package/src/utils/purchase.ts +32 -0
- package/src/utils.ts +68 -0
- package/nitrogen/generated/android/c++/JVariant_PurchaseAndroid_PurchaseIOS.cpp +0 -26
- package/nitrogen/generated/android/c++/JVariant_PurchaseAndroid_PurchaseIOS.hpp +0 -80
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_PurchaseAndroid_PurchaseIOS.kt +0 -42
- package/nitrogen/generated/ios/swift/Func_void_RequestPurchaseResult.swift +0 -47
- package/nitrogen/generated/ios/swift/Variant_PurchaseAndroid_PurchaseIOS.swift +0 -18
- package/nitrogen/generated/shared/c++/RequestPurchaseResult.hpp +0 -78
|
@@ -18,10 +18,15 @@
|
|
|
18
18
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
19
|
#endif
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
// Forward declaration of `IapPlatform` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::iap { enum class IapPlatform; }
|
|
23
|
+
// Forward declaration of `PurchaseState` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::iap { enum class PurchaseState; }
|
|
22
25
|
|
|
23
26
|
#include <string>
|
|
24
27
|
#include <optional>
|
|
28
|
+
#include "IapPlatform.hpp"
|
|
29
|
+
#include "PurchaseState.hpp"
|
|
25
30
|
|
|
26
31
|
namespace margelo::nitro::iap {
|
|
27
32
|
|
|
@@ -34,9 +39,9 @@ namespace margelo::nitro::iap {
|
|
|
34
39
|
std::string productId SWIFT_PRIVATE;
|
|
35
40
|
double transactionDate SWIFT_PRIVATE;
|
|
36
41
|
std::optional<std::string> purchaseToken SWIFT_PRIVATE;
|
|
37
|
-
|
|
42
|
+
IapPlatform platform SWIFT_PRIVATE;
|
|
38
43
|
double quantity SWIFT_PRIVATE;
|
|
39
|
-
|
|
44
|
+
PurchaseState purchaseState SWIFT_PRIVATE;
|
|
40
45
|
bool isAutoRenewing SWIFT_PRIVATE;
|
|
41
46
|
std::optional<double> quantityIOS SWIFT_PRIVATE;
|
|
42
47
|
std::optional<double> originalTransactionDateIOS SWIFT_PRIVATE;
|
|
@@ -54,7 +59,7 @@ namespace margelo::nitro::iap {
|
|
|
54
59
|
|
|
55
60
|
public:
|
|
56
61
|
NitroPurchase() = default;
|
|
57
|
-
explicit NitroPurchase(std::string id, std::string productId, double transactionDate, std::optional<std::string> purchaseToken,
|
|
62
|
+
explicit NitroPurchase(std::string id, std::string productId, double transactionDate, std::optional<std::string> purchaseToken, IapPlatform platform, double quantity, PurchaseState purchaseState, bool isAutoRenewing, std::optional<double> quantityIOS, std::optional<double> originalTransactionDateIOS, std::optional<std::string> originalTransactionIdentifierIOS, std::optional<std::string> appAccountToken, std::optional<std::string> purchaseTokenAndroid, std::optional<std::string> dataAndroid, std::optional<std::string> signatureAndroid, std::optional<bool> autoRenewingAndroid, std::optional<double> purchaseStateAndroid, std::optional<bool> isAcknowledgedAndroid, std::optional<std::string> packageNameAndroid, std::optional<std::string> obfuscatedAccountIdAndroid, std::optional<std::string> obfuscatedProfileIdAndroid): id(id), productId(productId), transactionDate(transactionDate), purchaseToken(purchaseToken), platform(platform), quantity(quantity), purchaseState(purchaseState), isAutoRenewing(isAutoRenewing), quantityIOS(quantityIOS), originalTransactionDateIOS(originalTransactionDateIOS), originalTransactionIdentifierIOS(originalTransactionIdentifierIOS), appAccountToken(appAccountToken), purchaseTokenAndroid(purchaseTokenAndroid), dataAndroid(dataAndroid), signatureAndroid(signatureAndroid), autoRenewingAndroid(autoRenewingAndroid), purchaseStateAndroid(purchaseStateAndroid), isAcknowledgedAndroid(isAcknowledgedAndroid), packageNameAndroid(packageNameAndroid), obfuscatedAccountIdAndroid(obfuscatedAccountIdAndroid), obfuscatedProfileIdAndroid(obfuscatedProfileIdAndroid) {}
|
|
58
63
|
};
|
|
59
64
|
|
|
60
65
|
} // namespace margelo::nitro::iap
|
|
@@ -71,9 +76,9 @@ namespace margelo::nitro {
|
|
|
71
76
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "productId")),
|
|
72
77
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "transactionDate")),
|
|
73
78
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "purchaseToken")),
|
|
74
|
-
JSIConverter<
|
|
79
|
+
JSIConverter<margelo::nitro::iap::IapPlatform>::fromJSI(runtime, obj.getProperty(runtime, "platform")),
|
|
75
80
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "quantity")),
|
|
76
|
-
JSIConverter<
|
|
81
|
+
JSIConverter<margelo::nitro::iap::PurchaseState>::fromJSI(runtime, obj.getProperty(runtime, "purchaseState")),
|
|
77
82
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isAutoRenewing")),
|
|
78
83
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "quantityIOS")),
|
|
79
84
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "originalTransactionDateIOS")),
|
|
@@ -96,9 +101,9 @@ namespace margelo::nitro {
|
|
|
96
101
|
obj.setProperty(runtime, "productId", JSIConverter<std::string>::toJSI(runtime, arg.productId));
|
|
97
102
|
obj.setProperty(runtime, "transactionDate", JSIConverter<double>::toJSI(runtime, arg.transactionDate));
|
|
98
103
|
obj.setProperty(runtime, "purchaseToken", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.purchaseToken));
|
|
99
|
-
obj.setProperty(runtime, "platform", JSIConverter<
|
|
104
|
+
obj.setProperty(runtime, "platform", JSIConverter<margelo::nitro::iap::IapPlatform>::toJSI(runtime, arg.platform));
|
|
100
105
|
obj.setProperty(runtime, "quantity", JSIConverter<double>::toJSI(runtime, arg.quantity));
|
|
101
|
-
obj.setProperty(runtime, "purchaseState", JSIConverter<
|
|
106
|
+
obj.setProperty(runtime, "purchaseState", JSIConverter<margelo::nitro::iap::PurchaseState>::toJSI(runtime, arg.purchaseState));
|
|
102
107
|
obj.setProperty(runtime, "isAutoRenewing", JSIConverter<bool>::toJSI(runtime, arg.isAutoRenewing));
|
|
103
108
|
obj.setProperty(runtime, "quantityIOS", JSIConverter<std::optional<double>>::toJSI(runtime, arg.quantityIOS));
|
|
104
109
|
obj.setProperty(runtime, "originalTransactionDateIOS", JSIConverter<std::optional<double>>::toJSI(runtime, arg.originalTransactionDateIOS));
|
|
@@ -124,9 +129,9 @@ namespace margelo::nitro {
|
|
|
124
129
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "productId"))) return false;
|
|
125
130
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "transactionDate"))) return false;
|
|
126
131
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "purchaseToken"))) return false;
|
|
127
|
-
if (!JSIConverter<
|
|
132
|
+
if (!JSIConverter<margelo::nitro::iap::IapPlatform>::canConvert(runtime, obj.getProperty(runtime, "platform"))) return false;
|
|
128
133
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "quantity"))) return false;
|
|
129
|
-
if (!JSIConverter<
|
|
134
|
+
if (!JSIConverter<margelo::nitro::iap::PurchaseState>::canConvert(runtime, obj.getProperty(runtime, "purchaseState"))) return false;
|
|
130
135
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isAutoRenewing"))) return false;
|
|
131
136
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "quantityIOS"))) return false;
|
|
132
137
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "originalTransactionDateIOS"))) return false;
|
|
@@ -30,14 +30,14 @@ namespace margelo::nitro::iap {
|
|
|
30
30
|
*/
|
|
31
31
|
struct NitroReceiptValidationAndroidOptions {
|
|
32
32
|
public:
|
|
33
|
-
std::string packageName SWIFT_PRIVATE;
|
|
34
|
-
std::string productToken SWIFT_PRIVATE;
|
|
35
33
|
std::string accessToken SWIFT_PRIVATE;
|
|
36
34
|
std::optional<bool> isSub SWIFT_PRIVATE;
|
|
35
|
+
std::string packageName SWIFT_PRIVATE;
|
|
36
|
+
std::string productToken SWIFT_PRIVATE;
|
|
37
37
|
|
|
38
38
|
public:
|
|
39
39
|
NitroReceiptValidationAndroidOptions() = default;
|
|
40
|
-
explicit NitroReceiptValidationAndroidOptions(std::string
|
|
40
|
+
explicit NitroReceiptValidationAndroidOptions(std::string accessToken, std::optional<bool> isSub, std::string packageName, std::string productToken): accessToken(accessToken), isSub(isSub), packageName(packageName), productToken(productToken) {}
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
} // namespace margelo::nitro::iap
|
|
@@ -50,18 +50,18 @@ namespace margelo::nitro {
|
|
|
50
50
|
static inline margelo::nitro::iap::NitroReceiptValidationAndroidOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
51
51
|
jsi::Object obj = arg.asObject(runtime);
|
|
52
52
|
return margelo::nitro::iap::NitroReceiptValidationAndroidOptions(
|
|
53
|
-
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "packageName")),
|
|
54
|
-
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "productToken")),
|
|
55
53
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "accessToken")),
|
|
56
|
-
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "isSub"))
|
|
54
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "isSub")),
|
|
55
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "packageName")),
|
|
56
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "productToken"))
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroReceiptValidationAndroidOptions& arg) {
|
|
60
60
|
jsi::Object obj(runtime);
|
|
61
|
-
obj.setProperty(runtime, "packageName", JSIConverter<std::string>::toJSI(runtime, arg.packageName));
|
|
62
|
-
obj.setProperty(runtime, "productToken", JSIConverter<std::string>::toJSI(runtime, arg.productToken));
|
|
63
61
|
obj.setProperty(runtime, "accessToken", JSIConverter<std::string>::toJSI(runtime, arg.accessToken));
|
|
64
62
|
obj.setProperty(runtime, "isSub", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isSub));
|
|
63
|
+
obj.setProperty(runtime, "packageName", JSIConverter<std::string>::toJSI(runtime, arg.packageName));
|
|
64
|
+
obj.setProperty(runtime, "productToken", JSIConverter<std::string>::toJSI(runtime, arg.productToken));
|
|
65
65
|
return obj;
|
|
66
66
|
}
|
|
67
67
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -69,10 +69,10 @@ namespace margelo::nitro {
|
|
|
69
69
|
return false;
|
|
70
70
|
}
|
|
71
71
|
jsi::Object obj = value.getObject(runtime);
|
|
72
|
-
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "packageName"))) return false;
|
|
73
|
-
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "productToken"))) return false;
|
|
74
72
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "accessToken"))) return false;
|
|
75
73
|
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "isSub"))) return false;
|
|
74
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "packageName"))) return false;
|
|
75
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "productToken"))) return false;
|
|
76
76
|
return true;
|
|
77
77
|
}
|
|
78
78
|
};
|
|
@@ -33,9 +33,9 @@ namespace margelo::nitro::iap {
|
|
|
33
33
|
bool autoRenewing SWIFT_PRIVATE;
|
|
34
34
|
bool betaProduct SWIFT_PRIVATE;
|
|
35
35
|
std::optional<double> cancelDate SWIFT_PRIVATE;
|
|
36
|
-
std::string cancelReason SWIFT_PRIVATE;
|
|
36
|
+
std::optional<std::string> cancelReason SWIFT_PRIVATE;
|
|
37
37
|
std::optional<double> deferredDate SWIFT_PRIVATE;
|
|
38
|
-
std::optional<
|
|
38
|
+
std::optional<std::string> deferredSku SWIFT_PRIVATE;
|
|
39
39
|
double freeTrialEndDate SWIFT_PRIVATE;
|
|
40
40
|
double gracePeriodEndDate SWIFT_PRIVATE;
|
|
41
41
|
std::string parentProductId SWIFT_PRIVATE;
|
|
@@ -51,7 +51,7 @@ namespace margelo::nitro::iap {
|
|
|
51
51
|
|
|
52
52
|
public:
|
|
53
53
|
NitroReceiptValidationResultAndroid() = default;
|
|
54
|
-
explicit NitroReceiptValidationResultAndroid(bool autoRenewing, bool betaProduct, std::optional<double> cancelDate, std::string cancelReason, std::optional<double> deferredDate, std::optional<
|
|
54
|
+
explicit NitroReceiptValidationResultAndroid(bool autoRenewing, bool betaProduct, std::optional<double> cancelDate, std::optional<std::string> cancelReason, std::optional<double> deferredDate, std::optional<std::string> deferredSku, double freeTrialEndDate, double gracePeriodEndDate, std::string parentProductId, std::string productId, std::string productType, double purchaseDate, double quantity, std::string receiptId, double renewalDate, std::string term, std::string termSku, bool testTransaction): autoRenewing(autoRenewing), betaProduct(betaProduct), cancelDate(cancelDate), cancelReason(cancelReason), deferredDate(deferredDate), deferredSku(deferredSku), freeTrialEndDate(freeTrialEndDate), gracePeriodEndDate(gracePeriodEndDate), parentProductId(parentProductId), productId(productId), productType(productType), purchaseDate(purchaseDate), quantity(quantity), receiptId(receiptId), renewalDate(renewalDate), term(term), termSku(termSku), testTransaction(testTransaction) {}
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
} // namespace margelo::nitro::iap
|
|
@@ -67,9 +67,9 @@ namespace margelo::nitro {
|
|
|
67
67
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "autoRenewing")),
|
|
68
68
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "betaProduct")),
|
|
69
69
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "cancelDate")),
|
|
70
|
-
JSIConverter<std::string
|
|
70
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "cancelReason")),
|
|
71
71
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "deferredDate")),
|
|
72
|
-
JSIConverter<std::optional<
|
|
72
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "deferredSku")),
|
|
73
73
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "freeTrialEndDate")),
|
|
74
74
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "gracePeriodEndDate")),
|
|
75
75
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "parentProductId")),
|
|
@@ -89,9 +89,9 @@ namespace margelo::nitro {
|
|
|
89
89
|
obj.setProperty(runtime, "autoRenewing", JSIConverter<bool>::toJSI(runtime, arg.autoRenewing));
|
|
90
90
|
obj.setProperty(runtime, "betaProduct", JSIConverter<bool>::toJSI(runtime, arg.betaProduct));
|
|
91
91
|
obj.setProperty(runtime, "cancelDate", JSIConverter<std::optional<double>>::toJSI(runtime, arg.cancelDate));
|
|
92
|
-
obj.setProperty(runtime, "cancelReason", JSIConverter<std::string
|
|
92
|
+
obj.setProperty(runtime, "cancelReason", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.cancelReason));
|
|
93
93
|
obj.setProperty(runtime, "deferredDate", JSIConverter<std::optional<double>>::toJSI(runtime, arg.deferredDate));
|
|
94
|
-
obj.setProperty(runtime, "deferredSku", JSIConverter<std::optional<
|
|
94
|
+
obj.setProperty(runtime, "deferredSku", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.deferredSku));
|
|
95
95
|
obj.setProperty(runtime, "freeTrialEndDate", JSIConverter<double>::toJSI(runtime, arg.freeTrialEndDate));
|
|
96
96
|
obj.setProperty(runtime, "gracePeriodEndDate", JSIConverter<double>::toJSI(runtime, arg.gracePeriodEndDate));
|
|
97
97
|
obj.setProperty(runtime, "parentProductId", JSIConverter<std::string>::toJSI(runtime, arg.parentProductId));
|
|
@@ -114,9 +114,9 @@ namespace margelo::nitro {
|
|
|
114
114
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "autoRenewing"))) return false;
|
|
115
115
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "betaProduct"))) return false;
|
|
116
116
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "cancelDate"))) return false;
|
|
117
|
-
if (!JSIConverter<std::string
|
|
117
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "cancelReason"))) return false;
|
|
118
118
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "deferredDate"))) return false;
|
|
119
|
-
if (!JSIConverter<std::optional<
|
|
119
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "deferredSku"))) return false;
|
|
120
120
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "freeTrialEndDate"))) return false;
|
|
121
121
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "gracePeriodEndDate"))) return false;
|
|
122
122
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "parentProductId"))) return false;
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
19
|
#endif
|
|
20
20
|
|
|
21
|
-
// Forward declaration of `
|
|
22
|
-
namespace margelo::nitro::iap { struct
|
|
21
|
+
// Forward declaration of `AndroidSubscriptionOfferInput` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::iap { struct AndroidSubscriptionOfferInput; }
|
|
23
23
|
|
|
24
24
|
#include <string>
|
|
25
25
|
#include <vector>
|
|
26
26
|
#include <optional>
|
|
27
|
-
#include "
|
|
27
|
+
#include "AndroidSubscriptionOfferInput.hpp"
|
|
28
28
|
|
|
29
29
|
namespace margelo::nitro::iap {
|
|
30
30
|
|
|
@@ -37,13 +37,13 @@ namespace margelo::nitro::iap {
|
|
|
37
37
|
std::optional<std::string> obfuscatedAccountIdAndroid SWIFT_PRIVATE;
|
|
38
38
|
std::optional<std::string> obfuscatedProfileIdAndroid SWIFT_PRIVATE;
|
|
39
39
|
std::optional<bool> isOfferPersonalized SWIFT_PRIVATE;
|
|
40
|
-
std::optional<std::vector<
|
|
40
|
+
std::optional<std::vector<AndroidSubscriptionOfferInput>> subscriptionOffers SWIFT_PRIVATE;
|
|
41
41
|
std::optional<double> replacementModeAndroid SWIFT_PRIVATE;
|
|
42
42
|
std::optional<std::string> purchaseTokenAndroid SWIFT_PRIVATE;
|
|
43
43
|
|
|
44
44
|
public:
|
|
45
45
|
NitroRequestPurchaseAndroid() = default;
|
|
46
|
-
explicit NitroRequestPurchaseAndroid(std::vector<std::string> skus, std::optional<std::string> obfuscatedAccountIdAndroid, std::optional<std::string> obfuscatedProfileIdAndroid, std::optional<bool> isOfferPersonalized, std::optional<std::vector<
|
|
46
|
+
explicit NitroRequestPurchaseAndroid(std::vector<std::string> skus, std::optional<std::string> obfuscatedAccountIdAndroid, std::optional<std::string> obfuscatedProfileIdAndroid, std::optional<bool> isOfferPersonalized, std::optional<std::vector<AndroidSubscriptionOfferInput>> subscriptionOffers, std::optional<double> replacementModeAndroid, std::optional<std::string> purchaseTokenAndroid): skus(skus), obfuscatedAccountIdAndroid(obfuscatedAccountIdAndroid), obfuscatedProfileIdAndroid(obfuscatedProfileIdAndroid), isOfferPersonalized(isOfferPersonalized), subscriptionOffers(subscriptionOffers), replacementModeAndroid(replacementModeAndroid), purchaseTokenAndroid(purchaseTokenAndroid) {}
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
} // namespace margelo::nitro::iap
|
|
@@ -60,7 +60,7 @@ namespace margelo::nitro {
|
|
|
60
60
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "obfuscatedAccountIdAndroid")),
|
|
61
61
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "obfuscatedProfileIdAndroid")),
|
|
62
62
|
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "isOfferPersonalized")),
|
|
63
|
-
JSIConverter<std::optional<std::vector<margelo::nitro::iap::
|
|
63
|
+
JSIConverter<std::optional<std::vector<margelo::nitro::iap::AndroidSubscriptionOfferInput>>>::fromJSI(runtime, obj.getProperty(runtime, "subscriptionOffers")),
|
|
64
64
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "replacementModeAndroid")),
|
|
65
65
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "purchaseTokenAndroid"))
|
|
66
66
|
);
|
|
@@ -71,7 +71,7 @@ namespace margelo::nitro {
|
|
|
71
71
|
obj.setProperty(runtime, "obfuscatedAccountIdAndroid", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.obfuscatedAccountIdAndroid));
|
|
72
72
|
obj.setProperty(runtime, "obfuscatedProfileIdAndroid", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.obfuscatedProfileIdAndroid));
|
|
73
73
|
obj.setProperty(runtime, "isOfferPersonalized", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isOfferPersonalized));
|
|
74
|
-
obj.setProperty(runtime, "subscriptionOffers", JSIConverter<std::optional<std::vector<margelo::nitro::iap::
|
|
74
|
+
obj.setProperty(runtime, "subscriptionOffers", JSIConverter<std::optional<std::vector<margelo::nitro::iap::AndroidSubscriptionOfferInput>>>::toJSI(runtime, arg.subscriptionOffers));
|
|
75
75
|
obj.setProperty(runtime, "replacementModeAndroid", JSIConverter<std::optional<double>>::toJSI(runtime, arg.replacementModeAndroid));
|
|
76
76
|
obj.setProperty(runtime, "purchaseTokenAndroid", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.purchaseTokenAndroid));
|
|
77
77
|
return obj;
|
|
@@ -85,7 +85,7 @@ namespace margelo::nitro {
|
|
|
85
85
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "obfuscatedAccountIdAndroid"))) return false;
|
|
86
86
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "obfuscatedProfileIdAndroid"))) return false;
|
|
87
87
|
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "isOfferPersonalized"))) return false;
|
|
88
|
-
if (!JSIConverter<std::optional<std::vector<margelo::nitro::iap::
|
|
88
|
+
if (!JSIConverter<std::optional<std::vector<margelo::nitro::iap::AndroidSubscriptionOfferInput>>>::canConvert(runtime, obj.getProperty(runtime, "subscriptionOffers"))) return false;
|
|
89
89
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "replacementModeAndroid"))) return false;
|
|
90
90
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "purchaseTokenAndroid"))) return false;
|
|
91
91
|
return true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-iap",
|
|
3
|
-
"version": "14.3.
|
|
3
|
+
"version": "14.3.8",
|
|
4
4
|
"description": "React Native In-App Purchases module for iOS and Android using Nitro",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"prepare:husky": "husky install",
|
|
68
68
|
"precommit": "lint-staged",
|
|
69
69
|
"ci:check": "./scripts/ci-check.sh",
|
|
70
|
-
"generate:types": "node scripts/update-types.mjs --tag 1.0.
|
|
70
|
+
"generate:types": "node scripts/update-types.mjs --tag 1.0.6",
|
|
71
71
|
"generate:icon": "cd docs/static/img && npx sharp-cli resize 32 32 --input icon.png --output favicon-32x32.png && npx sharp-cli resize 16 16 --input icon.png --output favicon-16x16.png && npx sharp-cli resize 192 192 --input icon.png --output android-chrome-192x192.png && npx sharp-cli resize 512 512 --input icon.png --output android-chrome-512x512.png && npx sharp-cli resize 180 180 --input icon.png --output apple-touch-icon.png && npx sharp-cli resize 1200 630 --input icon.png --output og-image.png && npx sharp-cli resize 150 150 --input icon.png --output favicon.png && npx sharp-cli --input favicon-32x32.png --output favicon.ico",
|
|
72
72
|
"commitlint": "commitlint"
|
|
73
73
|
},
|
package/plugin/build/withIAP.js
CHANGED
|
@@ -31,7 +31,7 @@ const modifyProjectBuildGradle = (gradle) => {
|
|
|
31
31
|
};
|
|
32
32
|
exports.modifyProjectBuildGradle = modifyProjectBuildGradle;
|
|
33
33
|
const OPENIAP_COORD = 'io.github.hyochan.openiap:openiap-google';
|
|
34
|
-
const OPENIAP_VERSION = '1.1.
|
|
34
|
+
const OPENIAP_VERSION = '1.1.12';
|
|
35
35
|
const modifyAppBuildGradle = (gradle) => {
|
|
36
36
|
let modified = gradle;
|
|
37
37
|
// Replace legacy Billing/GMS instructions with OpenIAP Google library
|
|
@@ -84,7 +84,13 @@ const withIapAndroid = (config) => {
|
|
|
84
84
|
return config;
|
|
85
85
|
};
|
|
86
86
|
const withIapIosFollyWorkaround = (config, props) => {
|
|
87
|
-
const
|
|
87
|
+
const newKey = props?.ios?.['with-folly-no-coroutines'];
|
|
88
|
+
const oldKey = props?.ios?.['with-folly-no-couroutines'];
|
|
89
|
+
if (oldKey && !hasLoggedPluginExecution) {
|
|
90
|
+
// Temporary deprecation notice; remove when old key is dropped
|
|
91
|
+
config_plugins_1.WarningAggregator.addWarningIOS('react-native-iap', "react-native-iap: 'ios.with-folly-no-couroutines' is deprecated; use 'ios.with-folly-no-coroutines'.");
|
|
92
|
+
}
|
|
93
|
+
const enabled = !!(newKey ?? oldKey);
|
|
88
94
|
if (!enabled)
|
|
89
95
|
return config;
|
|
90
96
|
return (0, config_plugins_1.withPodfile)(config, (config) => {
|
package/plugin/src/withIAP.ts
CHANGED
|
@@ -46,7 +46,7 @@ export const modifyProjectBuildGradle = (gradle: string): string => {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
const OPENIAP_COORD = 'io.github.hyochan.openiap:openiap-google';
|
|
49
|
-
const OPENIAP_VERSION = '1.1.
|
|
49
|
+
const OPENIAP_VERSION = '1.1.12';
|
|
50
50
|
|
|
51
51
|
const modifyAppBuildGradle = (gradle: string): string => {
|
|
52
52
|
let modified = gradle;
|
|
@@ -126,8 +126,9 @@ const withIapAndroid: ConfigPlugin = (config) => {
|
|
|
126
126
|
|
|
127
127
|
type IapPluginProps = {
|
|
128
128
|
ios?: {
|
|
129
|
-
// Intentionally following user-provided key spelling
|
|
130
129
|
// Enable to inject Folly coroutine-disabling macros into Podfile during prebuild
|
|
130
|
+
'with-folly-no-coroutines'?: boolean;
|
|
131
|
+
// @deprecated Use 'with-folly-no-coroutines'. Kept for backward compatibility.
|
|
131
132
|
'with-folly-no-couroutines'?: boolean;
|
|
132
133
|
};
|
|
133
134
|
};
|
|
@@ -136,7 +137,16 @@ const withIapIosFollyWorkaround: ConfigPlugin<IapPluginProps | undefined> = (
|
|
|
136
137
|
config,
|
|
137
138
|
props,
|
|
138
139
|
) => {
|
|
139
|
-
const
|
|
140
|
+
const newKey = props?.ios?.['with-folly-no-coroutines'];
|
|
141
|
+
const oldKey = props?.ios?.['with-folly-no-couroutines'];
|
|
142
|
+
if (oldKey && !hasLoggedPluginExecution) {
|
|
143
|
+
// Temporary deprecation notice; remove when old key is dropped
|
|
144
|
+
WarningAggregator.addWarningIOS(
|
|
145
|
+
'react-native-iap',
|
|
146
|
+
"react-native-iap: 'ios.with-folly-no-couroutines' is deprecated; use 'ios.with-folly-no-coroutines'.",
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
const enabled = !!(newKey ?? oldKey);
|
|
140
150
|
if (!enabled) return config;
|
|
141
151
|
|
|
142
152
|
return withPodfile(config, (config) => {
|
package/src/hooks/useIAP.ts
CHANGED
|
@@ -34,8 +34,7 @@ import type {
|
|
|
34
34
|
PurchaseError,
|
|
35
35
|
ProductSubscription,
|
|
36
36
|
} from '../types';
|
|
37
|
-
import type {
|
|
38
|
-
import type {NitroPurchaseResult} from '../specs/RnIap.nitro';
|
|
37
|
+
import type {MutationFinishTransactionArgs} from '../types';
|
|
39
38
|
import {normalizeErrorCodeFromNative} from '../utils/errorMapping';
|
|
40
39
|
|
|
41
40
|
// Types for event subscriptions
|
|
@@ -52,10 +51,7 @@ type UseIap = {
|
|
|
52
51
|
availablePurchases: Purchase[];
|
|
53
52
|
promotedProductIOS?: Product;
|
|
54
53
|
activeSubscriptions: ActiveSubscription[];
|
|
55
|
-
finishTransaction: (
|
|
56
|
-
purchase,
|
|
57
|
-
isConsumable,
|
|
58
|
-
}: FinishTransactionParams) => Promise<NitroPurchaseResult | boolean>;
|
|
54
|
+
finishTransaction: (args: MutationFinishTransactionArgs) => Promise<void>;
|
|
59
55
|
getAvailablePurchases: (skus?: string[]) => Promise<void>;
|
|
60
56
|
fetchProducts: (params: {
|
|
61
57
|
skus: string[];
|
|
@@ -73,7 +69,7 @@ type UseIap = {
|
|
|
73
69
|
getSubscriptions: (skus: string[]) => Promise<void>;
|
|
74
70
|
requestPurchase: (
|
|
75
71
|
params: RequestPurchaseProps,
|
|
76
|
-
) => Promise<RequestPurchaseResult>;
|
|
72
|
+
) => Promise<RequestPurchaseResult | null>;
|
|
77
73
|
validateReceipt: (
|
|
78
74
|
sku: string,
|
|
79
75
|
androidOptions?: {
|
|
@@ -85,7 +81,7 @@ type UseIap = {
|
|
|
85
81
|
) => Promise<any>;
|
|
86
82
|
restorePurchases: () => Promise<void>;
|
|
87
83
|
getPromotedProductIOS: () => Promise<Product | null>;
|
|
88
|
-
requestPurchaseOnPromotedProductIOS: () => Promise<
|
|
84
|
+
requestPurchaseOnPromotedProductIOS: () => Promise<boolean>;
|
|
89
85
|
getActiveSubscriptions: (
|
|
90
86
|
subscriptionIds?: string[],
|
|
91
87
|
) => Promise<ActiveSubscription[]>;
|
|
@@ -168,10 +164,13 @@ export function useIAP(options?: UseIapOptions): UseIap {
|
|
|
168
164
|
skus,
|
|
169
165
|
type: 'in-app',
|
|
170
166
|
});
|
|
167
|
+
const newProducts = (result ?? []).filter(
|
|
168
|
+
(item): item is Product => item.type === 'in-app',
|
|
169
|
+
);
|
|
171
170
|
setProducts((prevProducts: Product[]) =>
|
|
172
171
|
mergeWithDuplicateCheck(
|
|
173
172
|
prevProducts,
|
|
174
|
-
|
|
173
|
+
newProducts,
|
|
175
174
|
(product: Product) => product.id,
|
|
176
175
|
),
|
|
177
176
|
);
|
|
@@ -189,10 +188,13 @@ export function useIAP(options?: UseIapOptions): UseIap {
|
|
|
189
188
|
skus,
|
|
190
189
|
type: 'subs',
|
|
191
190
|
});
|
|
191
|
+
const newSubscriptions = (result ?? []).filter(
|
|
192
|
+
(item): item is ProductSubscription => item.type === 'subs',
|
|
193
|
+
);
|
|
192
194
|
setSubscriptions((prevSubscriptions: ProductSubscription[]) =>
|
|
193
195
|
mergeWithDuplicateCheck(
|
|
194
196
|
prevSubscriptions,
|
|
195
|
-
|
|
197
|
+
newSubscriptions,
|
|
196
198
|
(subscription: ProductSubscription) => subscription.id,
|
|
197
199
|
),
|
|
198
200
|
);
|
|
@@ -215,24 +217,62 @@ export function useIAP(options?: UseIapOptions): UseIap {
|
|
|
215
217
|
return;
|
|
216
218
|
}
|
|
217
219
|
try {
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
+
const requestType = params.type ?? 'in-app';
|
|
221
|
+
const result = await fetchProducts({
|
|
222
|
+
skus: params.skus,
|
|
223
|
+
type: requestType,
|
|
224
|
+
});
|
|
225
|
+
const items = (result ?? []) as (Product | ProductSubscription)[];
|
|
226
|
+
|
|
227
|
+
if (requestType === 'subs') {
|
|
228
|
+
const newSubscriptions = items.filter(
|
|
229
|
+
(item): item is ProductSubscription => item.type === 'subs',
|
|
230
|
+
);
|
|
220
231
|
setSubscriptions((prevSubscriptions: ProductSubscription[]) =>
|
|
221
232
|
mergeWithDuplicateCheck(
|
|
222
233
|
prevSubscriptions,
|
|
223
|
-
|
|
234
|
+
newSubscriptions,
|
|
224
235
|
(subscription: ProductSubscription) => subscription.id,
|
|
225
236
|
),
|
|
226
237
|
);
|
|
227
|
-
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (requestType === 'all') {
|
|
242
|
+
const newProducts = items.filter(
|
|
243
|
+
(item): item is Product => item.type === 'in-app',
|
|
244
|
+
);
|
|
245
|
+
const newSubscriptions = items.filter(
|
|
246
|
+
(item): item is ProductSubscription => item.type === 'subs',
|
|
247
|
+
);
|
|
248
|
+
|
|
228
249
|
setProducts((prevProducts: Product[]) =>
|
|
229
250
|
mergeWithDuplicateCheck(
|
|
230
251
|
prevProducts,
|
|
231
|
-
|
|
252
|
+
newProducts,
|
|
232
253
|
(product: Product) => product.id,
|
|
233
254
|
),
|
|
234
255
|
);
|
|
256
|
+
setSubscriptions((prevSubscriptions: ProductSubscription[]) =>
|
|
257
|
+
mergeWithDuplicateCheck(
|
|
258
|
+
prevSubscriptions,
|
|
259
|
+
newSubscriptions,
|
|
260
|
+
(subscription: ProductSubscription) => subscription.id,
|
|
261
|
+
),
|
|
262
|
+
);
|
|
263
|
+
return;
|
|
235
264
|
}
|
|
265
|
+
|
|
266
|
+
const newProducts = items.filter(
|
|
267
|
+
(item): item is Product => item.type === 'in-app',
|
|
268
|
+
);
|
|
269
|
+
setProducts((prevProducts: Product[]) =>
|
|
270
|
+
mergeWithDuplicateCheck(
|
|
271
|
+
prevProducts,
|
|
272
|
+
newProducts,
|
|
273
|
+
(product: Product) => product.id,
|
|
274
|
+
),
|
|
275
|
+
);
|
|
236
276
|
} catch (error) {
|
|
237
277
|
console.error('Error fetching products:', error);
|
|
238
278
|
}
|
|
@@ -284,18 +324,9 @@ export function useIAP(options?: UseIapOptions): UseIap {
|
|
|
284
324
|
);
|
|
285
325
|
|
|
286
326
|
const finishTransaction = useCallback(
|
|
287
|
-
async ({
|
|
288
|
-
purchase,
|
|
289
|
-
isConsumable,
|
|
290
|
-
}: {
|
|
291
|
-
purchase: Purchase;
|
|
292
|
-
isConsumable?: boolean;
|
|
293
|
-
}): Promise<NitroPurchaseResult | boolean> => {
|
|
327
|
+
async (args: MutationFinishTransactionArgs): Promise<void> => {
|
|
294
328
|
try {
|
|
295
|
-
|
|
296
|
-
purchase,
|
|
297
|
-
isConsumable,
|
|
298
|
-
});
|
|
329
|
+
await finishTransactionInternal(args);
|
|
299
330
|
} catch (err) {
|
|
300
331
|
throw err;
|
|
301
332
|
}
|
|
@@ -320,7 +351,10 @@ export function useIAP(options?: UseIapOptions): UseIap {
|
|
|
320
351
|
isSub?: boolean;
|
|
321
352
|
},
|
|
322
353
|
) => {
|
|
323
|
-
return validateReceiptInternal(
|
|
354
|
+
return validateReceiptInternal({
|
|
355
|
+
sku,
|
|
356
|
+
androidOptions,
|
|
357
|
+
});
|
|
324
358
|
},
|
|
325
359
|
[],
|
|
326
360
|
);
|
|
@@ -413,11 +447,8 @@ export function useIAP(options?: UseIapOptions): UseIap {
|
|
|
413
447
|
validateReceipt,
|
|
414
448
|
restorePurchases: async () => {
|
|
415
449
|
try {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
onlyIncludeActiveItemsIOS: true,
|
|
419
|
-
});
|
|
420
|
-
setAvailablePurchases(purchases);
|
|
450
|
+
await restorePurchasesTopLevel();
|
|
451
|
+
await getAvailablePurchasesInternal();
|
|
421
452
|
} catch (e) {
|
|
422
453
|
console.warn('Failed to restore purchases:', e);
|
|
423
454
|
}
|