react-native-iap 14.4.16 → 14.4.18
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/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +55 -0
- package/ios/HybridRnIap.swift +17 -0
- package/ios/RnIapHelper.swift +45 -0
- package/lib/module/index.js +123 -33
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +5 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/index.d.ts +9 -6
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +41 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +47 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +45 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +1 -0
- package/nitrogen/generated/android/c++/JNitroActiveSubscription.hpp +108 -0
- package/nitrogen/generated/android/c++/JNitroRenewalInfoIOS.hpp +90 -0
- package/nitrogen/generated/android/c++/JPurchase.hpp +2 -0
- package/nitrogen/generated/android/c++/JPurchaseIOS.hpp +6 -0
- package/nitrogen/generated/android/c++/JRenewalInfoIOS.hpp +94 -0
- package/nitrogen/generated/android/c++/JRequestPurchaseResult.hpp +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroActiveSubscription.kt +68 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroRenewalInfoIOS.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseIOS.kt +3 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/RenewalInfoIOS.kt +59 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +93 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +9 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +17 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_NitroActiveSubscription_.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +32 -0
- package/nitrogen/generated/ios/swift/NitroActiveSubscription.swift +340 -0
- package/nitrogen/generated/ios/swift/NitroRenewalInfoIOS.swift +296 -0
- package/nitrogen/generated/ios/swift/PurchaseIOS.swift +31 -1
- package/nitrogen/generated/ios/swift/RenewalInfoIOS.swift +314 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/NitroActiveSubscription.hpp +122 -0
- package/nitrogen/generated/shared/c++/NitroRenewalInfoIOS.hpp +104 -0
- package/nitrogen/generated/shared/c++/PurchaseIOS.hpp +8 -1
- package/nitrogen/generated/shared/c++/RenewalInfoIOS.hpp +108 -0
- package/openiap-versions.json +3 -3
- package/package.json +1 -1
- package/src/index.ts +87 -4
- package/src/specs/RnIap.nitro.ts +48 -0
- package/src/types.ts +47 -0
|
@@ -24,6 +24,8 @@ namespace margelo::nitro::iap { struct PurchaseOfferIOS; }
|
|
|
24
24
|
namespace margelo::nitro::iap { enum class IapPlatform; }
|
|
25
25
|
// Forward declaration of `PurchaseState` to properly resolve imports.
|
|
26
26
|
namespace margelo::nitro::iap { enum class PurchaseState; }
|
|
27
|
+
// Forward declaration of `RenewalInfoIOS` to properly resolve imports.
|
|
28
|
+
namespace margelo::nitro::iap { struct RenewalInfoIOS; }
|
|
27
29
|
|
|
28
30
|
#include <string>
|
|
29
31
|
#include <optional>
|
|
@@ -31,6 +33,7 @@ namespace margelo::nitro::iap { enum class PurchaseState; }
|
|
|
31
33
|
#include "PurchaseOfferIOS.hpp"
|
|
32
34
|
#include "IapPlatform.hpp"
|
|
33
35
|
#include "PurchaseState.hpp"
|
|
36
|
+
#include "RenewalInfoIOS.hpp"
|
|
34
37
|
|
|
35
38
|
namespace margelo::nitro::iap {
|
|
36
39
|
|
|
@@ -63,6 +66,7 @@ namespace margelo::nitro::iap {
|
|
|
63
66
|
std::optional<double> quantityIOS SWIFT_PRIVATE;
|
|
64
67
|
std::optional<std::string> reasonIOS SWIFT_PRIVATE;
|
|
65
68
|
std::optional<std::string> reasonStringRepresentationIOS SWIFT_PRIVATE;
|
|
69
|
+
std::optional<RenewalInfoIOS> renewalInfoIOS SWIFT_PRIVATE;
|
|
66
70
|
std::optional<double> revocationDateIOS SWIFT_PRIVATE;
|
|
67
71
|
std::optional<std::string> revocationReasonIOS SWIFT_PRIVATE;
|
|
68
72
|
std::optional<std::string> storefrontCountryCodeIOS SWIFT_PRIVATE;
|
|
@@ -74,7 +78,7 @@ namespace margelo::nitro::iap {
|
|
|
74
78
|
|
|
75
79
|
public:
|
|
76
80
|
PurchaseIOS() = default;
|
|
77
|
-
explicit PurchaseIOS(std::optional<std::string> appAccountToken, std::optional<std::string> appBundleIdIOS, std::optional<std::string> countryCodeIOS, std::optional<std::string> currencyCodeIOS, std::optional<std::string> currencySymbolIOS, std::optional<std::string> currentPlanId, std::optional<std::string> environmentIOS, std::optional<double> expirationDateIOS, std::string id, std::optional<std::vector<std::string>> ids, bool isAutoRenewing, std::optional<bool> isUpgradedIOS, std::optional<PurchaseOfferIOS> offerIOS, std::optional<double> originalTransactionDateIOS, std::optional<std::string> originalTransactionIdentifierIOS, std::optional<std::string> ownershipTypeIOS, IapPlatform platform, std::string productId, PurchaseState purchaseState, std::optional<std::string> purchaseToken, double quantity, std::optional<double> quantityIOS, std::optional<std::string> reasonIOS, std::optional<std::string> reasonStringRepresentationIOS, std::optional<double> revocationDateIOS, std::optional<std::string> revocationReasonIOS, std::optional<std::string> storefrontCountryCodeIOS, std::optional<std::string> subscriptionGroupIdIOS, double transactionDate, std::string transactionId, std::optional<std::string> transactionReasonIOS, std::optional<std::string> webOrderLineItemIdIOS): appAccountToken(appAccountToken), appBundleIdIOS(appBundleIdIOS), countryCodeIOS(countryCodeIOS), currencyCodeIOS(currencyCodeIOS), currencySymbolIOS(currencySymbolIOS), currentPlanId(currentPlanId), environmentIOS(environmentIOS), expirationDateIOS(expirationDateIOS), id(id), ids(ids), isAutoRenewing(isAutoRenewing), isUpgradedIOS(isUpgradedIOS), offerIOS(offerIOS), originalTransactionDateIOS(originalTransactionDateIOS), originalTransactionIdentifierIOS(originalTransactionIdentifierIOS), ownershipTypeIOS(ownershipTypeIOS), platform(platform), productId(productId), purchaseState(purchaseState), purchaseToken(purchaseToken), quantity(quantity), quantityIOS(quantityIOS), reasonIOS(reasonIOS), reasonStringRepresentationIOS(reasonStringRepresentationIOS), revocationDateIOS(revocationDateIOS), revocationReasonIOS(revocationReasonIOS), storefrontCountryCodeIOS(storefrontCountryCodeIOS), subscriptionGroupIdIOS(subscriptionGroupIdIOS), transactionDate(transactionDate), transactionId(transactionId), transactionReasonIOS(transactionReasonIOS), webOrderLineItemIdIOS(webOrderLineItemIdIOS) {}
|
|
81
|
+
explicit PurchaseIOS(std::optional<std::string> appAccountToken, std::optional<std::string> appBundleIdIOS, std::optional<std::string> countryCodeIOS, std::optional<std::string> currencyCodeIOS, std::optional<std::string> currencySymbolIOS, std::optional<std::string> currentPlanId, std::optional<std::string> environmentIOS, std::optional<double> expirationDateIOS, std::string id, std::optional<std::vector<std::string>> ids, bool isAutoRenewing, std::optional<bool> isUpgradedIOS, std::optional<PurchaseOfferIOS> offerIOS, std::optional<double> originalTransactionDateIOS, std::optional<std::string> originalTransactionIdentifierIOS, std::optional<std::string> ownershipTypeIOS, IapPlatform platform, std::string productId, PurchaseState purchaseState, std::optional<std::string> purchaseToken, double quantity, std::optional<double> quantityIOS, std::optional<std::string> reasonIOS, std::optional<std::string> reasonStringRepresentationIOS, std::optional<RenewalInfoIOS> renewalInfoIOS, std::optional<double> revocationDateIOS, std::optional<std::string> revocationReasonIOS, std::optional<std::string> storefrontCountryCodeIOS, std::optional<std::string> subscriptionGroupIdIOS, double transactionDate, std::string transactionId, std::optional<std::string> transactionReasonIOS, std::optional<std::string> webOrderLineItemIdIOS): appAccountToken(appAccountToken), appBundleIdIOS(appBundleIdIOS), countryCodeIOS(countryCodeIOS), currencyCodeIOS(currencyCodeIOS), currencySymbolIOS(currencySymbolIOS), currentPlanId(currentPlanId), environmentIOS(environmentIOS), expirationDateIOS(expirationDateIOS), id(id), ids(ids), isAutoRenewing(isAutoRenewing), isUpgradedIOS(isUpgradedIOS), offerIOS(offerIOS), originalTransactionDateIOS(originalTransactionDateIOS), originalTransactionIdentifierIOS(originalTransactionIdentifierIOS), ownershipTypeIOS(ownershipTypeIOS), platform(platform), productId(productId), purchaseState(purchaseState), purchaseToken(purchaseToken), quantity(quantity), quantityIOS(quantityIOS), reasonIOS(reasonIOS), reasonStringRepresentationIOS(reasonStringRepresentationIOS), renewalInfoIOS(renewalInfoIOS), revocationDateIOS(revocationDateIOS), revocationReasonIOS(revocationReasonIOS), storefrontCountryCodeIOS(storefrontCountryCodeIOS), subscriptionGroupIdIOS(subscriptionGroupIdIOS), transactionDate(transactionDate), transactionId(transactionId), transactionReasonIOS(transactionReasonIOS), webOrderLineItemIdIOS(webOrderLineItemIdIOS) {}
|
|
78
82
|
};
|
|
79
83
|
|
|
80
84
|
} // namespace margelo::nitro::iap
|
|
@@ -111,6 +115,7 @@ namespace margelo::nitro {
|
|
|
111
115
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "quantityIOS")),
|
|
112
116
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "reasonIOS")),
|
|
113
117
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "reasonStringRepresentationIOS")),
|
|
118
|
+
JSIConverter<std::optional<margelo::nitro::iap::RenewalInfoIOS>>::fromJSI(runtime, obj.getProperty(runtime, "renewalInfoIOS")),
|
|
114
119
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "revocationDateIOS")),
|
|
115
120
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "revocationReasonIOS")),
|
|
116
121
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "storefrontCountryCodeIOS")),
|
|
@@ -147,6 +152,7 @@ namespace margelo::nitro {
|
|
|
147
152
|
obj.setProperty(runtime, "quantityIOS", JSIConverter<std::optional<double>>::toJSI(runtime, arg.quantityIOS));
|
|
148
153
|
obj.setProperty(runtime, "reasonIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.reasonIOS));
|
|
149
154
|
obj.setProperty(runtime, "reasonStringRepresentationIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.reasonStringRepresentationIOS));
|
|
155
|
+
obj.setProperty(runtime, "renewalInfoIOS", JSIConverter<std::optional<margelo::nitro::iap::RenewalInfoIOS>>::toJSI(runtime, arg.renewalInfoIOS));
|
|
150
156
|
obj.setProperty(runtime, "revocationDateIOS", JSIConverter<std::optional<double>>::toJSI(runtime, arg.revocationDateIOS));
|
|
151
157
|
obj.setProperty(runtime, "revocationReasonIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.revocationReasonIOS));
|
|
152
158
|
obj.setProperty(runtime, "storefrontCountryCodeIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.storefrontCountryCodeIOS));
|
|
@@ -186,6 +192,7 @@ namespace margelo::nitro {
|
|
|
186
192
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "quantityIOS"))) return false;
|
|
187
193
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "reasonIOS"))) return false;
|
|
188
194
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "reasonStringRepresentationIOS"))) return false;
|
|
195
|
+
if (!JSIConverter<std::optional<margelo::nitro::iap::RenewalInfoIOS>>::canConvert(runtime, obj.getProperty(runtime, "renewalInfoIOS"))) return false;
|
|
189
196
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "revocationDateIOS"))) return false;
|
|
190
197
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "revocationReasonIOS"))) return false;
|
|
191
198
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "storefrontCountryCodeIOS"))) return false;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// RenewalInfoIOS.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#include <string>
|
|
24
|
+
#include <optional>
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::iap {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A struct which can be represented as a JavaScript object (RenewalInfoIOS).
|
|
30
|
+
*/
|
|
31
|
+
struct RenewalInfoIOS {
|
|
32
|
+
public:
|
|
33
|
+
std::optional<std::string> autoRenewPreference SWIFT_PRIVATE;
|
|
34
|
+
std::optional<std::string> expirationReason SWIFT_PRIVATE;
|
|
35
|
+
std::optional<double> gracePeriodExpirationDate SWIFT_PRIVATE;
|
|
36
|
+
std::optional<bool> isInBillingRetry SWIFT_PRIVATE;
|
|
37
|
+
std::optional<std::string> jsonRepresentation SWIFT_PRIVATE;
|
|
38
|
+
std::optional<std::string> pendingUpgradeProductId SWIFT_PRIVATE;
|
|
39
|
+
std::optional<std::string> priceIncreaseStatus SWIFT_PRIVATE;
|
|
40
|
+
std::optional<double> renewalDate SWIFT_PRIVATE;
|
|
41
|
+
std::optional<std::string> renewalOfferId SWIFT_PRIVATE;
|
|
42
|
+
std::optional<std::string> renewalOfferType SWIFT_PRIVATE;
|
|
43
|
+
bool willAutoRenew SWIFT_PRIVATE;
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
RenewalInfoIOS() = default;
|
|
47
|
+
explicit RenewalInfoIOS(std::optional<std::string> autoRenewPreference, std::optional<std::string> expirationReason, std::optional<double> gracePeriodExpirationDate, std::optional<bool> isInBillingRetry, std::optional<std::string> jsonRepresentation, std::optional<std::string> pendingUpgradeProductId, std::optional<std::string> priceIncreaseStatus, std::optional<double> renewalDate, std::optional<std::string> renewalOfferId, std::optional<std::string> renewalOfferType, bool willAutoRenew): autoRenewPreference(autoRenewPreference), expirationReason(expirationReason), gracePeriodExpirationDate(gracePeriodExpirationDate), isInBillingRetry(isInBillingRetry), jsonRepresentation(jsonRepresentation), pendingUpgradeProductId(pendingUpgradeProductId), priceIncreaseStatus(priceIncreaseStatus), renewalDate(renewalDate), renewalOfferId(renewalOfferId), renewalOfferType(renewalOfferType), willAutoRenew(willAutoRenew) {}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
} // namespace margelo::nitro::iap
|
|
51
|
+
|
|
52
|
+
namespace margelo::nitro {
|
|
53
|
+
|
|
54
|
+
// C++ RenewalInfoIOS <> JS RenewalInfoIOS (object)
|
|
55
|
+
template <>
|
|
56
|
+
struct JSIConverter<margelo::nitro::iap::RenewalInfoIOS> final {
|
|
57
|
+
static inline margelo::nitro::iap::RenewalInfoIOS fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
58
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
59
|
+
return margelo::nitro::iap::RenewalInfoIOS(
|
|
60
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "autoRenewPreference")),
|
|
61
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "expirationReason")),
|
|
62
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "gracePeriodExpirationDate")),
|
|
63
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "isInBillingRetry")),
|
|
64
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "jsonRepresentation")),
|
|
65
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "pendingUpgradeProductId")),
|
|
66
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "priceIncreaseStatus")),
|
|
67
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "renewalDate")),
|
|
68
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "renewalOfferId")),
|
|
69
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "renewalOfferType")),
|
|
70
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "willAutoRenew"))
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::RenewalInfoIOS& arg) {
|
|
74
|
+
jsi::Object obj(runtime);
|
|
75
|
+
obj.setProperty(runtime, "autoRenewPreference", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.autoRenewPreference));
|
|
76
|
+
obj.setProperty(runtime, "expirationReason", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.expirationReason));
|
|
77
|
+
obj.setProperty(runtime, "gracePeriodExpirationDate", JSIConverter<std::optional<double>>::toJSI(runtime, arg.gracePeriodExpirationDate));
|
|
78
|
+
obj.setProperty(runtime, "isInBillingRetry", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isInBillingRetry));
|
|
79
|
+
obj.setProperty(runtime, "jsonRepresentation", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.jsonRepresentation));
|
|
80
|
+
obj.setProperty(runtime, "pendingUpgradeProductId", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.pendingUpgradeProductId));
|
|
81
|
+
obj.setProperty(runtime, "priceIncreaseStatus", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.priceIncreaseStatus));
|
|
82
|
+
obj.setProperty(runtime, "renewalDate", JSIConverter<std::optional<double>>::toJSI(runtime, arg.renewalDate));
|
|
83
|
+
obj.setProperty(runtime, "renewalOfferId", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.renewalOfferId));
|
|
84
|
+
obj.setProperty(runtime, "renewalOfferType", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.renewalOfferType));
|
|
85
|
+
obj.setProperty(runtime, "willAutoRenew", JSIConverter<bool>::toJSI(runtime, arg.willAutoRenew));
|
|
86
|
+
return obj;
|
|
87
|
+
}
|
|
88
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
89
|
+
if (!value.isObject()) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
jsi::Object obj = value.getObject(runtime);
|
|
93
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "autoRenewPreference"))) return false;
|
|
94
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "expirationReason"))) return false;
|
|
95
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "gracePeriodExpirationDate"))) return false;
|
|
96
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "isInBillingRetry"))) return false;
|
|
97
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "jsonRepresentation"))) return false;
|
|
98
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "pendingUpgradeProductId"))) return false;
|
|
99
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "priceIncreaseStatus"))) return false;
|
|
100
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "renewalDate"))) return false;
|
|
101
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "renewalOfferId"))) return false;
|
|
102
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "renewalOfferType"))) return false;
|
|
103
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "willAutoRenew"))) return false;
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
} // namespace margelo::nitro
|
package/openiap-versions.json
CHANGED
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {NitroModules} from 'react-native-nitro-modules';
|
|
|
6
6
|
|
|
7
7
|
// Internal modules
|
|
8
8
|
import type {
|
|
9
|
+
NitroActiveSubscription,
|
|
9
10
|
NitroReceiptValidationParams,
|
|
10
11
|
NitroReceiptValidationResultIOS,
|
|
11
12
|
NitroReceiptValidationResultAndroid,
|
|
@@ -34,7 +35,6 @@ import type {
|
|
|
34
35
|
RequestSubscriptionIosProps,
|
|
35
36
|
RequestSubscriptionPropsByPlatforms,
|
|
36
37
|
ActiveSubscription,
|
|
37
|
-
PurchaseAndroid,
|
|
38
38
|
ProductAndroid,
|
|
39
39
|
ProductSubscriptionAndroid,
|
|
40
40
|
} from './types';
|
|
@@ -1561,12 +1561,84 @@ export const deepLinkToSubscriptionsIOS = async (): Promise<boolean> => {
|
|
|
1561
1561
|
* ```
|
|
1562
1562
|
*/
|
|
1563
1563
|
/**
|
|
1564
|
-
* Get active subscriptions
|
|
1564
|
+
* Get all active subscriptions with detailed information (OpenIAP compliant)
|
|
1565
|
+
* Returns an array of active subscriptions. If subscriptionIds is not provided,
|
|
1566
|
+
* returns all active subscriptions. Platform-specific fields are populated based
|
|
1567
|
+
* on the current platform.
|
|
1568
|
+
*
|
|
1569
|
+
* On iOS, this uses the native getActiveSubscriptions method which includes
|
|
1570
|
+
* renewalInfoIOS with details about subscription renewal status, pending
|
|
1571
|
+
* upgrades/downgrades, and auto-renewal preferences.
|
|
1572
|
+
*
|
|
1565
1573
|
* @param subscriptionIds - Optional array of subscription IDs to filter by
|
|
1566
1574
|
* @returns Promise<ActiveSubscription[]> - Array of active subscriptions
|
|
1567
1575
|
*/
|
|
1568
1576
|
export const getActiveSubscriptions: QueryField<
|
|
1569
1577
|
'getActiveSubscriptions'
|
|
1578
|
+
> = async (subscriptionIds) => {
|
|
1579
|
+
try {
|
|
1580
|
+
// Use native getActiveSubscriptions on both platforms
|
|
1581
|
+
// iOS: includes renewalInfoIOS with subscription lifecycle info
|
|
1582
|
+
// Android: uses OpenIAP which calls Google Play Billing's getActiveSubscriptions
|
|
1583
|
+
const activeSubscriptions = await IAP.instance.getActiveSubscriptions(
|
|
1584
|
+
subscriptionIds ?? undefined,
|
|
1585
|
+
);
|
|
1586
|
+
|
|
1587
|
+
// Convert NitroActiveSubscription to ActiveSubscription
|
|
1588
|
+
return activeSubscriptions.map(
|
|
1589
|
+
(sub: NitroActiveSubscription): ActiveSubscription => ({
|
|
1590
|
+
productId: sub.productId,
|
|
1591
|
+
isActive: sub.isActive,
|
|
1592
|
+
transactionId: sub.transactionId,
|
|
1593
|
+
purchaseToken: sub.purchaseToken ?? null,
|
|
1594
|
+
transactionDate: sub.transactionDate,
|
|
1595
|
+
// iOS specific fields
|
|
1596
|
+
expirationDateIOS: sub.expirationDateIOS ?? null,
|
|
1597
|
+
environmentIOS: sub.environmentIOS ?? null,
|
|
1598
|
+
willExpireSoon: sub.willExpireSoon ?? null,
|
|
1599
|
+
daysUntilExpirationIOS: sub.daysUntilExpirationIOS ?? null,
|
|
1600
|
+
// 🆕 renewalInfoIOS - subscription lifecycle information (iOS only)
|
|
1601
|
+
renewalInfoIOS: sub.renewalInfoIOS
|
|
1602
|
+
? {
|
|
1603
|
+
willAutoRenew: sub.renewalInfoIOS.willAutoRenew ?? false,
|
|
1604
|
+
autoRenewPreference:
|
|
1605
|
+
sub.renewalInfoIOS.autoRenewPreference ?? null,
|
|
1606
|
+
pendingUpgradeProductId:
|
|
1607
|
+
sub.renewalInfoIOS.pendingUpgradeProductId ?? null,
|
|
1608
|
+
renewalDate: sub.renewalInfoIOS.renewalDate ?? null,
|
|
1609
|
+
expirationReason: sub.renewalInfoIOS.expirationReason ?? null,
|
|
1610
|
+
isInBillingRetry: sub.renewalInfoIOS.isInBillingRetry ?? null,
|
|
1611
|
+
gracePeriodExpirationDate:
|
|
1612
|
+
sub.renewalInfoIOS.gracePeriodExpirationDate ?? null,
|
|
1613
|
+
priceIncreaseStatus:
|
|
1614
|
+
sub.renewalInfoIOS.priceIncreaseStatus ?? null,
|
|
1615
|
+
renewalOfferType: sub.renewalInfoIOS.offerType ?? null,
|
|
1616
|
+
renewalOfferId: sub.renewalInfoIOS.offerIdentifier ?? null,
|
|
1617
|
+
}
|
|
1618
|
+
: null,
|
|
1619
|
+
// Android specific fields
|
|
1620
|
+
autoRenewingAndroid: sub.autoRenewingAndroid ?? null,
|
|
1621
|
+
basePlanIdAndroid: sub.basePlanIdAndroid ?? null,
|
|
1622
|
+
currentPlanId:
|
|
1623
|
+
sub.currentPlanId ?? (Platform.OS === 'ios' ? sub.productId : null),
|
|
1624
|
+
purchaseTokenAndroid: sub.purchaseTokenAndroid ?? null,
|
|
1625
|
+
}),
|
|
1626
|
+
);
|
|
1627
|
+
} catch (error) {
|
|
1628
|
+
if (error instanceof Error && error.message.includes('NotPrepared')) {
|
|
1629
|
+
RnIapConsole.error('IAP connection not initialized:', error);
|
|
1630
|
+
throw error;
|
|
1631
|
+
}
|
|
1632
|
+
RnIapConsole.error('Failed to get active subscriptions:', error);
|
|
1633
|
+
const errorJson = parseErrorStringToJsonObj(error);
|
|
1634
|
+
throw new Error(errorJson.message);
|
|
1635
|
+
}
|
|
1636
|
+
};
|
|
1637
|
+
|
|
1638
|
+
// OLD IMPLEMENTATION - REPLACED WITH NATIVE CALL
|
|
1639
|
+
/*
|
|
1640
|
+
export const getActiveSubscriptions_OLD: QueryField<
|
|
1641
|
+
'getActiveSubscriptions'
|
|
1570
1642
|
> = async (subscriptionIds) => {
|
|
1571
1643
|
try {
|
|
1572
1644
|
// Get all available purchases first
|
|
@@ -1610,6 +1682,12 @@ export const getActiveSubscriptions: QueryField<
|
|
|
1610
1682
|
(purchase as PurchaseAndroid).isAutoRenewing) // deprecated - use isAutoRenewing instead
|
|
1611
1683
|
: null;
|
|
1612
1684
|
|
|
1685
|
+
// 🆕 Extract renewalInfoIOS if available
|
|
1686
|
+
const renewalInfoIOS =
|
|
1687
|
+
'renewalInfoIOS' in purchase
|
|
1688
|
+
? ((purchase as PurchaseIOS).renewalInfoIOS ?? null)
|
|
1689
|
+
: null;
|
|
1690
|
+
|
|
1613
1691
|
return {
|
|
1614
1692
|
productId: purchase.productId,
|
|
1615
1693
|
isActive: true, // If it's in availablePurchases, it's active
|
|
@@ -1621,6 +1699,7 @@ export const getActiveSubscriptions: QueryField<
|
|
|
1621
1699
|
expirationDateIOS,
|
|
1622
1700
|
autoRenewingAndroid,
|
|
1623
1701
|
environmentIOS,
|
|
1702
|
+
renewalInfoIOS,
|
|
1624
1703
|
// Convenience fields
|
|
1625
1704
|
willExpireSoon: false, // Would need to calculate based on expiration date
|
|
1626
1705
|
daysUntilExpirationIOS:
|
|
@@ -1641,7 +1720,10 @@ export const getActiveSubscriptions: QueryField<
|
|
|
1641
1720
|
};
|
|
1642
1721
|
|
|
1643
1722
|
/**
|
|
1644
|
-
* Check if
|
|
1723
|
+
* Check if the user has any active subscriptions (OpenIAP compliant)
|
|
1724
|
+
* Returns true if the user has at least one active subscription, false otherwise.
|
|
1725
|
+
* If subscriptionIds is provided, only checks for those specific subscriptions.
|
|
1726
|
+
*
|
|
1645
1727
|
* @param subscriptionIds - Optional array of subscription IDs to check
|
|
1646
1728
|
* @returns Promise<boolean> - True if there are active subscriptions
|
|
1647
1729
|
*/
|
|
@@ -1652,7 +1734,8 @@ export const hasActiveSubscriptions: QueryField<
|
|
|
1652
1734
|
const activeSubscriptions = await getActiveSubscriptions(subscriptionIds);
|
|
1653
1735
|
return activeSubscriptions.length > 0;
|
|
1654
1736
|
} catch (error) {
|
|
1655
|
-
|
|
1737
|
+
// If there's an error getting subscriptions, return false
|
|
1738
|
+
RnIapConsole.warn('Error checking active subscriptions:', error);
|
|
1656
1739
|
return false;
|
|
1657
1740
|
}
|
|
1658
1741
|
};
|
package/src/specs/RnIap.nitro.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {HybridObject} from 'react-native-nitro-modules';
|
|
|
4
4
|
// canonical `Nitro*` names defined here, so we keep the aliases rather than
|
|
5
5
|
// removing the types entirely.
|
|
6
6
|
import type {
|
|
7
|
+
ActiveSubscription,
|
|
7
8
|
AndroidSubscriptionOfferInput,
|
|
8
9
|
DeepLinkOptions,
|
|
9
10
|
InitConnectionConfig,
|
|
@@ -236,6 +237,44 @@ export interface NitroPurchase {
|
|
|
236
237
|
developerPayloadAndroid?: string | null;
|
|
237
238
|
}
|
|
238
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Active subscription with renewalInfoIOS included
|
|
242
|
+
*/
|
|
243
|
+
export interface NitroActiveSubscription {
|
|
244
|
+
productId: ActiveSubscription['productId'];
|
|
245
|
+
isActive: ActiveSubscription['isActive'];
|
|
246
|
+
transactionId: ActiveSubscription['transactionId'];
|
|
247
|
+
purchaseToken?: ActiveSubscription['purchaseToken'];
|
|
248
|
+
transactionDate: ActiveSubscription['transactionDate'];
|
|
249
|
+
// iOS specific fields
|
|
250
|
+
expirationDateIOS?: ActiveSubscription['expirationDateIOS'];
|
|
251
|
+
environmentIOS?: ActiveSubscription['environmentIOS'];
|
|
252
|
+
willExpireSoon?: ActiveSubscription['willExpireSoon'];
|
|
253
|
+
daysUntilExpirationIOS?: ActiveSubscription['daysUntilExpirationIOS'];
|
|
254
|
+
renewalInfoIOS?: NitroRenewalInfoIOS | null; // 🆕 Key field for upgrade/downgrade detection
|
|
255
|
+
// Android specific fields
|
|
256
|
+
autoRenewingAndroid?: ActiveSubscription['autoRenewingAndroid'];
|
|
257
|
+
basePlanIdAndroid?: ActiveSubscription['basePlanIdAndroid'];
|
|
258
|
+
currentPlanId?: ActiveSubscription['currentPlanId'];
|
|
259
|
+
purchaseTokenAndroid?: ActiveSubscription['purchaseTokenAndroid'];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Renewal information from StoreKit 2 (iOS only)
|
|
264
|
+
*/
|
|
265
|
+
export interface NitroRenewalInfoIOS {
|
|
266
|
+
willAutoRenew?: boolean | null;
|
|
267
|
+
autoRenewPreference?: string | null;
|
|
268
|
+
pendingUpgradeProductId?: string | null;
|
|
269
|
+
renewalDate?: number | null;
|
|
270
|
+
expirationReason?: string | null;
|
|
271
|
+
isInBillingRetry?: boolean | null;
|
|
272
|
+
gracePeriodExpirationDate?: number | null;
|
|
273
|
+
priceIncreaseStatus?: string | null;
|
|
274
|
+
offerType?: string | null;
|
|
275
|
+
offerIdentifier?: string | null;
|
|
276
|
+
}
|
|
277
|
+
|
|
239
278
|
export interface NitroProduct {
|
|
240
279
|
id: ProductCommon['id'];
|
|
241
280
|
title: ProductCommon['title'];
|
|
@@ -326,6 +365,15 @@ export interface RnIap extends HybridObject<{ios: 'swift'; android: 'kotlin'}> {
|
|
|
326
365
|
options?: NitroAvailablePurchasesOptions,
|
|
327
366
|
): Promise<NitroPurchase[]>;
|
|
328
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Get active subscriptions with renewalInfoIOS included
|
|
370
|
+
* @param subscriptionIds - Optional array of subscription IDs to filter
|
|
371
|
+
* @returns Promise<NitroActiveSubscription[]> - Array of active subscriptions with renewalInfoIOS
|
|
372
|
+
*/
|
|
373
|
+
getActiveSubscriptions(
|
|
374
|
+
subscriptionIds?: string[],
|
|
375
|
+
): Promise<NitroActiveSubscription[]>;
|
|
376
|
+
|
|
329
377
|
/**
|
|
330
378
|
* Finish a transaction (unified method for both platforms)
|
|
331
379
|
* @param params - Platform-specific transaction finish parameters
|
package/src/types.ts
CHANGED
|
@@ -21,6 +21,11 @@ export interface ActiveSubscription {
|
|
|
21
21
|
purchaseToken?: (string | null);
|
|
22
22
|
/** Required for subscription upgrade/downgrade on Android */
|
|
23
23
|
purchaseTokenAndroid?: (string | null);
|
|
24
|
+
/**
|
|
25
|
+
* Renewal information from StoreKit 2 (iOS only). Contains details about subscription renewal status,
|
|
26
|
+
* pending upgrades/downgrades, and auto-renewal preferences.
|
|
27
|
+
*/
|
|
28
|
+
renewalInfoIOS?: (RenewalInfoIOS | null);
|
|
24
29
|
transactionDate: number;
|
|
25
30
|
transactionId: string;
|
|
26
31
|
willExpireSoon?: (boolean | null);
|
|
@@ -487,6 +492,7 @@ export interface PurchaseIOS extends PurchaseCommon {
|
|
|
487
492
|
quantityIOS?: (number | null);
|
|
488
493
|
reasonIOS?: (string | null);
|
|
489
494
|
reasonStringRepresentationIOS?: (string | null);
|
|
495
|
+
renewalInfoIOS?: (RenewalInfoIOS | null);
|
|
490
496
|
revocationDateIOS?: (number | null);
|
|
491
497
|
revocationReasonIOS?: (string | null);
|
|
492
498
|
storefrontCountryCodeIOS?: (string | null);
|
|
@@ -633,9 +639,50 @@ export interface RefundResultIOS {
|
|
|
633
639
|
status: string;
|
|
634
640
|
}
|
|
635
641
|
|
|
642
|
+
/**
|
|
643
|
+
* Subscription renewal information from Product.SubscriptionInfo.RenewalInfo
|
|
644
|
+
* https://developer.apple.com/documentation/storekit/product/subscriptioninfo/renewalinfo
|
|
645
|
+
*/
|
|
636
646
|
export interface RenewalInfoIOS {
|
|
637
647
|
autoRenewPreference?: (string | null);
|
|
648
|
+
/**
|
|
649
|
+
* When subscription expires due to cancellation/billing issue
|
|
650
|
+
* Possible values: "VOLUNTARY", "BILLING_ERROR", "DID_NOT_AGREE_TO_PRICE_INCREASE", "PRODUCT_NOT_AVAILABLE", "UNKNOWN"
|
|
651
|
+
*/
|
|
652
|
+
expirationReason?: (string | null);
|
|
653
|
+
/**
|
|
654
|
+
* Grace period expiration date (milliseconds since epoch)
|
|
655
|
+
* When set, subscription is in grace period (billing issue but still has access)
|
|
656
|
+
*/
|
|
657
|
+
gracePeriodExpirationDate?: (number | null);
|
|
658
|
+
/**
|
|
659
|
+
* True if subscription failed to renew due to billing issue and is retrying
|
|
660
|
+
* Note: Not directly available in RenewalInfo, available in Status
|
|
661
|
+
*/
|
|
662
|
+
isInBillingRetry?: (boolean | null);
|
|
638
663
|
jsonRepresentation?: (string | null);
|
|
664
|
+
/**
|
|
665
|
+
* Product ID that will be used on next renewal (when user upgrades/downgrades)
|
|
666
|
+
* If set and different from current productId, subscription will change on expiration
|
|
667
|
+
*/
|
|
668
|
+
pendingUpgradeProductId?: (string | null);
|
|
669
|
+
/**
|
|
670
|
+
* User's response to subscription price increase
|
|
671
|
+
* Possible values: "AGREED", "PENDING", null (no price increase)
|
|
672
|
+
*/
|
|
673
|
+
priceIncreaseStatus?: (string | null);
|
|
674
|
+
/**
|
|
675
|
+
* Expected renewal date (milliseconds since epoch)
|
|
676
|
+
* For active subscriptions, when the next renewal/charge will occur
|
|
677
|
+
*/
|
|
678
|
+
renewalDate?: (number | null);
|
|
679
|
+
/** Offer ID applied to next renewal (promotional offer, subscription offer code, etc.) */
|
|
680
|
+
renewalOfferId?: (string | null);
|
|
681
|
+
/**
|
|
682
|
+
* Type of offer applied to next renewal
|
|
683
|
+
* Possible values: "PROMOTIONAL", "SUBSCRIPTION_OFFER_CODE", "WIN_BACK", etc.
|
|
684
|
+
*/
|
|
685
|
+
renewalOfferType?: (string | null);
|
|
639
686
|
willAutoRenew: boolean;
|
|
640
687
|
}
|
|
641
688
|
|