react-native-iap 14.3.8 → 14.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/NitroIap.podspec +11 -1
  2. package/README.md +2 -3
  3. package/android/build.gradle +24 -1
  4. package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +374 -119
  5. package/android/src/main/java/com/margelo/nitro/iap/RnIapLog.kt +64 -0
  6. package/ios/HybridRnIap.swift +525 -362
  7. package/ios/RnIapHelper.swift +224 -0
  8. package/ios/RnIapLog.swift +127 -0
  9. package/lib/module/hooks/useIAP.js +2 -34
  10. package/lib/module/hooks/useIAP.js.map +1 -1
  11. package/lib/module/index.js +52 -2
  12. package/lib/module/index.js.map +1 -1
  13. package/lib/module/types.js.map +1 -1
  14. package/lib/typescript/plugin/src/withIAP.d.ts.map +1 -1
  15. package/lib/typescript/src/hooks/useIAP.d.ts +0 -12
  16. package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
  17. package/lib/typescript/src/index.d.ts +3 -0
  18. package/lib/typescript/src/index.d.ts.map +1 -1
  19. package/lib/typescript/src/specs/RnIap.nitro.d.ts +24 -0
  20. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
  21. package/lib/typescript/src/types.d.ts +8 -6
  22. package/lib/typescript/src/types.d.ts.map +1 -1
  23. package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +64 -0
  24. package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +4 -0
  25. package/nitrogen/generated/android/c++/JIapPlatform.hpp +3 -3
  26. package/nitrogen/generated/android/c++/JPurchaseAndroid.hpp +6 -2
  27. package/nitrogen/generated/android/c++/JPurchaseIOS.hpp +4 -0
  28. package/nitrogen/generated/android/c++/JPurchaseState.hpp +6 -6
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +16 -0
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/IapPlatform.kt +2 -2
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseAndroid.kt +4 -1
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseIOS.kt +3 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseState.kt +5 -5
  34. package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +32 -0
  35. package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +4 -0
  36. package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +82 -0
  37. package/nitrogen/generated/ios/swift/IapPlatform.swift +4 -4
  38. package/nitrogen/generated/ios/swift/PurchaseAndroid.swift +32 -2
  39. package/nitrogen/generated/ios/swift/PurchaseIOS.swift +13 -2
  40. package/nitrogen/generated/ios/swift/PurchaseState.swift +8 -8
  41. package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +4 -0
  42. package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +4 -0
  43. package/nitrogen/generated/shared/c++/IapPlatform.hpp +5 -5
  44. package/nitrogen/generated/shared/c++/PurchaseAndroid.hpp +6 -2
  45. package/nitrogen/generated/shared/c++/PurchaseIOS.hpp +5 -1
  46. package/nitrogen/generated/shared/c++/PurchaseState.hpp +11 -11
  47. package/openiap-versions.json +5 -0
  48. package/package.json +3 -2
  49. package/plugin/build/withIAP.js +35 -3
  50. package/plugin/src/withIAP.ts +44 -3
  51. package/src/hooks/useIAP.ts +3 -71
  52. package/src/index.ts +61 -2
  53. package/src/specs/RnIap.nitro.ts +28 -0
  54. package/src/types.ts +8 -6
@@ -71,6 +71,8 @@ namespace margelo::nitro::iap {
71
71
  jni::local_ref<jni::JString> signatureAndroid = this->getFieldValue(fieldSignatureAndroid);
72
72
  static const auto fieldTransactionDate = clazz->getField<double>("transactionDate");
73
73
  double transactionDate = this->getFieldValue(fieldTransactionDate);
74
+ static const auto fieldTransactionId = clazz->getField<jni::JString>("transactionId");
75
+ jni::local_ref<jni::JString> transactionId = this->getFieldValue(fieldTransactionId);
74
76
  return PurchaseAndroid(
75
77
  autoRenewingAndroid != nullptr ? std::make_optional(static_cast<bool>(autoRenewingAndroid->value())) : std::nullopt,
76
78
  dataAndroid != nullptr ? std::make_optional(dataAndroid->toStdString()) : std::nullopt,
@@ -97,7 +99,8 @@ namespace margelo::nitro::iap {
97
99
  purchaseToken != nullptr ? std::make_optional(purchaseToken->toStdString()) : std::nullopt,
98
100
  quantity,
99
101
  signatureAndroid != nullptr ? std::make_optional(signatureAndroid->toStdString()) : std::nullopt,
100
- transactionDate
102
+ transactionDate,
103
+ transactionId != nullptr ? std::make_optional(transactionId->toStdString()) : std::nullopt
101
104
  );
102
105
  }
103
106
 
@@ -132,7 +135,8 @@ namespace margelo::nitro::iap {
132
135
  value.purchaseToken.has_value() ? jni::make_jstring(value.purchaseToken.value()) : nullptr,
133
136
  value.quantity,
134
137
  value.signatureAndroid.has_value() ? jni::make_jstring(value.signatureAndroid.value()) : nullptr,
135
- value.transactionDate
138
+ value.transactionDate,
139
+ value.transactionId.has_value() ? jni::make_jstring(value.transactionId.value()) : nullptr
136
140
  );
137
141
  }
138
142
  };
@@ -95,6 +95,8 @@ namespace margelo::nitro::iap {
95
95
  jni::local_ref<jni::JString> subscriptionGroupIdIOS = this->getFieldValue(fieldSubscriptionGroupIdIOS);
96
96
  static const auto fieldTransactionDate = clazz->getField<double>("transactionDate");
97
97
  double transactionDate = this->getFieldValue(fieldTransactionDate);
98
+ static const auto fieldTransactionId = clazz->getField<jni::JString>("transactionId");
99
+ jni::local_ref<jni::JString> transactionId = this->getFieldValue(fieldTransactionId);
98
100
  static const auto fieldTransactionReasonIOS = clazz->getField<jni::JString>("transactionReasonIOS");
99
101
  jni::local_ref<jni::JString> transactionReasonIOS = this->getFieldValue(fieldTransactionReasonIOS);
100
102
  static const auto fieldWebOrderLineItemIdIOS = clazz->getField<jni::JString>("webOrderLineItemIdIOS");
@@ -137,6 +139,7 @@ namespace margelo::nitro::iap {
137
139
  storefrontCountryCodeIOS != nullptr ? std::make_optional(storefrontCountryCodeIOS->toStdString()) : std::nullopt,
138
140
  subscriptionGroupIdIOS != nullptr ? std::make_optional(subscriptionGroupIdIOS->toStdString()) : std::nullopt,
139
141
  transactionDate,
142
+ transactionId->toStdString(),
140
143
  transactionReasonIOS != nullptr ? std::make_optional(transactionReasonIOS->toStdString()) : std::nullopt,
141
144
  webOrderLineItemIdIOS != nullptr ? std::make_optional(webOrderLineItemIdIOS->toStdString()) : std::nullopt
142
145
  );
@@ -185,6 +188,7 @@ namespace margelo::nitro::iap {
185
188
  value.storefrontCountryCodeIOS.has_value() ? jni::make_jstring(value.storefrontCountryCodeIOS.value()) : nullptr,
186
189
  value.subscriptionGroupIdIOS.has_value() ? jni::make_jstring(value.subscriptionGroupIdIOS.value()) : nullptr,
187
190
  value.transactionDate,
191
+ jni::make_jstring(value.transactionId),
188
192
  value.transactionReasonIOS.has_value() ? jni::make_jstring(value.transactionReasonIOS.value()) : nullptr,
189
193
  value.webOrderLineItemIdIOS.has_value() ? jni::make_jstring(value.webOrderLineItemIdIOS.value()) : nullptr
190
194
  );
@@ -41,24 +41,24 @@ namespace margelo::nitro::iap {
41
41
  [[maybe_unused]]
42
42
  static jni::alias_ref<JPurchaseState> fromCpp(PurchaseState value) {
43
43
  static const auto clazz = javaClassStatic();
44
- static const auto fieldDEFERRED = clazz->getStaticField<JPurchaseState>("DEFERRED");
45
- static const auto fieldFAILED = clazz->getStaticField<JPurchaseState>("FAILED");
46
44
  static const auto fieldPENDING = clazz->getStaticField<JPurchaseState>("PENDING");
47
45
  static const auto fieldPURCHASED = clazz->getStaticField<JPurchaseState>("PURCHASED");
46
+ static const auto fieldFAILED = clazz->getStaticField<JPurchaseState>("FAILED");
48
47
  static const auto fieldRESTORED = clazz->getStaticField<JPurchaseState>("RESTORED");
48
+ static const auto fieldDEFERRED = clazz->getStaticField<JPurchaseState>("DEFERRED");
49
49
  static const auto fieldUNKNOWN = clazz->getStaticField<JPurchaseState>("UNKNOWN");
50
50
 
51
51
  switch (value) {
52
- case PurchaseState::DEFERRED:
53
- return clazz->getStaticFieldValue(fieldDEFERRED);
54
- case PurchaseState::FAILED:
55
- return clazz->getStaticFieldValue(fieldFAILED);
56
52
  case PurchaseState::PENDING:
57
53
  return clazz->getStaticFieldValue(fieldPENDING);
58
54
  case PurchaseState::PURCHASED:
59
55
  return clazz->getStaticFieldValue(fieldPURCHASED);
56
+ case PurchaseState::FAILED:
57
+ return clazz->getStaticFieldValue(fieldFAILED);
60
58
  case PurchaseState::RESTORED:
61
59
  return clazz->getStaticFieldValue(fieldRESTORED);
60
+ case PurchaseState::DEFERRED:
61
+ return clazz->getStaticFieldValue(fieldDEFERRED);
62
62
  case PurchaseState::UNKNOWN:
63
63
  return clazz->getStaticFieldValue(fieldUNKNOWN);
64
64
  default:
@@ -130,6 +130,10 @@ abstract class HybridRnIapSpec: HybridObject() {
130
130
  @Keep
131
131
  abstract fun requestPromotedProductIOS(): Promise<NitroProduct?>
132
132
 
133
+ @DoNotStrip
134
+ @Keep
135
+ abstract fun getPromotedProductIOS(): Promise<NitroProduct?>
136
+
133
137
  @DoNotStrip
134
138
  @Keep
135
139
  abstract fun buyPromotedProductIOS(): Promise<Unit>
@@ -170,6 +174,10 @@ abstract class HybridRnIapSpec: HybridObject() {
170
174
  @Keep
171
175
  abstract fun showManageSubscriptionsIOS(): Promise<Array<NitroPurchase>>
172
176
 
177
+ @DoNotStrip
178
+ @Keep
179
+ abstract fun deepLinkToSubscriptionsIOS(): Promise<Boolean>
180
+
173
181
  @DoNotStrip
174
182
  @Keep
175
183
  abstract fun isEligibleForIntroOfferIOS(groupID: String): Promise<Boolean>
@@ -178,6 +186,14 @@ abstract class HybridRnIapSpec: HybridObject() {
178
186
  @Keep
179
187
  abstract fun getReceiptDataIOS(): Promise<String>
180
188
 
189
+ @DoNotStrip
190
+ @Keep
191
+ abstract fun getReceiptIOS(): Promise<String>
192
+
193
+ @DoNotStrip
194
+ @Keep
195
+ abstract fun requestReceiptRefreshIOS(): Promise<String>
196
+
181
197
  @DoNotStrip
182
198
  @Keep
183
199
  abstract fun isTransactionVerifiedIOS(sku: String): Promise<Boolean>
@@ -16,6 +16,6 @@ import com.facebook.proguard.annotations.DoNotStrip
16
16
  @DoNotStrip
17
17
  @Keep
18
18
  enum class IapPlatform(@DoNotStrip @Keep val value: Int) {
19
- ANDROID(0),
20
- IOS(1);
19
+ IOS(0),
20
+ ANDROID(1);
21
21
  }
@@ -71,7 +71,10 @@ data class PurchaseAndroid
71
71
  val signatureAndroid: String?,
72
72
  @DoNotStrip
73
73
  @Keep
74
- val transactionDate: Double
74
+ val transactionDate: Double,
75
+ @DoNotStrip
76
+ @Keep
77
+ val transactionId: String?
75
78
  ) {
76
79
  /* main constructor */
77
80
  }
@@ -107,6 +107,9 @@ data class PurchaseIOS
107
107
  val transactionDate: Double,
108
108
  @DoNotStrip
109
109
  @Keep
110
+ val transactionId: String,
111
+ @DoNotStrip
112
+ @Keep
110
113
  val transactionReasonIOS: String?,
111
114
  @DoNotStrip
112
115
  @Keep
@@ -16,10 +16,10 @@ import com.facebook.proguard.annotations.DoNotStrip
16
16
  @DoNotStrip
17
17
  @Keep
18
18
  enum class PurchaseState(@DoNotStrip @Keep val value: Int) {
19
- DEFERRED(0),
20
- FAILED(1),
21
- PENDING(2),
22
- PURCHASED(3),
23
- RESTORED(4),
19
+ PENDING(0),
20
+ PURCHASED(1),
21
+ FAILED(2),
22
+ RESTORED(3),
23
+ DEFERRED(4),
24
24
  UNKNOWN(5);
25
25
  }
@@ -248,6 +248,14 @@ namespace margelo::nitro::iap {
248
248
  auto __value = std::move(__result.value());
249
249
  return __value;
250
250
  }
251
+ inline std::shared_ptr<Promise<std::optional<NitroProduct>>> getPromotedProductIOS() override {
252
+ auto __result = _swiftPart.getPromotedProductIOS();
253
+ if (__result.hasError()) [[unlikely]] {
254
+ std::rethrow_exception(__result.error());
255
+ }
256
+ auto __value = std::move(__result.value());
257
+ return __value;
258
+ }
251
259
  inline std::shared_ptr<Promise<void>> buyPromotedProductIOS() override {
252
260
  auto __result = _swiftPart.buyPromotedProductIOS();
253
261
  if (__result.hasError()) [[unlikely]] {
@@ -328,6 +336,14 @@ namespace margelo::nitro::iap {
328
336
  auto __value = std::move(__result.value());
329
337
  return __value;
330
338
  }
339
+ inline std::shared_ptr<Promise<bool>> deepLinkToSubscriptionsIOS() override {
340
+ auto __result = _swiftPart.deepLinkToSubscriptionsIOS();
341
+ if (__result.hasError()) [[unlikely]] {
342
+ std::rethrow_exception(__result.error());
343
+ }
344
+ auto __value = std::move(__result.value());
345
+ return __value;
346
+ }
331
347
  inline std::shared_ptr<Promise<bool>> isEligibleForIntroOfferIOS(const std::string& groupID) override {
332
348
  auto __result = _swiftPart.isEligibleForIntroOfferIOS(groupID);
333
349
  if (__result.hasError()) [[unlikely]] {
@@ -344,6 +360,22 @@ namespace margelo::nitro::iap {
344
360
  auto __value = std::move(__result.value());
345
361
  return __value;
346
362
  }
363
+ inline std::shared_ptr<Promise<std::string>> getReceiptIOS() override {
364
+ auto __result = _swiftPart.getReceiptIOS();
365
+ if (__result.hasError()) [[unlikely]] {
366
+ std::rethrow_exception(__result.error());
367
+ }
368
+ auto __value = std::move(__result.value());
369
+ return __value;
370
+ }
371
+ inline std::shared_ptr<Promise<std::string>> requestReceiptRefreshIOS() override {
372
+ auto __result = _swiftPart.requestReceiptRefreshIOS();
373
+ if (__result.hasError()) [[unlikely]] {
374
+ std::rethrow_exception(__result.error());
375
+ }
376
+ auto __value = std::move(__result.value());
377
+ return __value;
378
+ }
347
379
  inline std::shared_ptr<Promise<bool>> isTransactionVerifiedIOS(const std::string& sku) override {
348
380
  auto __result = _swiftPart.isTransactionVerifiedIOS(sku);
349
381
  if (__result.hasError()) [[unlikely]] {
@@ -29,6 +29,7 @@ public protocol HybridRnIapSpec_protocol: HybridObject {
29
29
  func getStorefrontIOS() throws -> Promise<String>
30
30
  func getAppTransactionIOS() throws -> Promise<String?>
31
31
  func requestPromotedProductIOS() throws -> Promise<NitroProduct?>
32
+ func getPromotedProductIOS() throws -> Promise<NitroProduct?>
32
33
  func buyPromotedProductIOS() throws -> Promise<Void>
33
34
  func presentCodeRedemptionSheetIOS() throws -> Promise<Bool>
34
35
  func clearTransactionIOS() throws -> Promise<Void>
@@ -39,8 +40,11 @@ public protocol HybridRnIapSpec_protocol: HybridObject {
39
40
  func getPendingTransactionsIOS() throws -> Promise<[NitroPurchase]>
40
41
  func syncIOS() throws -> Promise<Bool>
41
42
  func showManageSubscriptionsIOS() throws -> Promise<[NitroPurchase]>
43
+ func deepLinkToSubscriptionsIOS() throws -> Promise<Bool>
42
44
  func isEligibleForIntroOfferIOS(groupID: String) throws -> Promise<Bool>
43
45
  func getReceiptDataIOS() throws -> Promise<String>
46
+ func getReceiptIOS() throws -> Promise<String>
47
+ func requestReceiptRefreshIOS() throws -> Promise<String>
44
48
  func isTransactionVerifiedIOS(sku: String) throws -> Promise<Bool>
45
49
  func getTransactionJwsIOS(sku: String) throws -> Promise<String?>
46
50
  func validateReceipt(params: NitroReceiptValidationParams) throws -> Promise<Variant_NitroReceiptValidationResultIOS_NitroReceiptValidationResultAndroid>
@@ -442,6 +442,31 @@ open class HybridRnIapSpec_cxx {
442
442
  }
443
443
  }
444
444
 
445
+ @inline(__always)
446
+ public final func getPromotedProductIOS() -> bridge.Result_std__shared_ptr_Promise_std__optional_NitroProduct____ {
447
+ do {
448
+ let __result = try self.__implementation.getPromotedProductIOS()
449
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__optional_NitroProduct___ in
450
+ let __promise = bridge.create_std__shared_ptr_Promise_std__optional_NitroProduct___()
451
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__optional_NitroProduct___(__promise)
452
+ __result
453
+ .then({ __result in __promiseHolder.resolve({ () -> bridge.std__optional_NitroProduct_ in
454
+ if let __unwrappedValue = __result {
455
+ return bridge.create_std__optional_NitroProduct_(__unwrappedValue)
456
+ } else {
457
+ return .init()
458
+ }
459
+ }()) })
460
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
461
+ return __promise
462
+ }()
463
+ return bridge.create_Result_std__shared_ptr_Promise_std__optional_NitroProduct____(__resultCpp)
464
+ } catch (let __error) {
465
+ let __exceptionPtr = __error.toCpp()
466
+ return bridge.create_Result_std__shared_ptr_Promise_std__optional_NitroProduct____(__exceptionPtr)
467
+ }
468
+ }
469
+
445
470
  @inline(__always)
446
471
  public final func buyPromotedProductIOS() -> bridge.Result_std__shared_ptr_Promise_void___ {
447
472
  do {
@@ -674,6 +699,25 @@ open class HybridRnIapSpec_cxx {
674
699
  }
675
700
  }
676
701
 
702
+ @inline(__always)
703
+ public final func deepLinkToSubscriptionsIOS() -> bridge.Result_std__shared_ptr_Promise_bool___ {
704
+ do {
705
+ let __result = try self.__implementation.deepLinkToSubscriptionsIOS()
706
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
707
+ let __promise = bridge.create_std__shared_ptr_Promise_bool__()
708
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
709
+ __result
710
+ .then({ __result in __promiseHolder.resolve(__result) })
711
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
712
+ return __promise
713
+ }()
714
+ return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
715
+ } catch (let __error) {
716
+ let __exceptionPtr = __error.toCpp()
717
+ return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
718
+ }
719
+ }
720
+
677
721
  @inline(__always)
678
722
  public final func isEligibleForIntroOfferIOS(groupID: std.string) -> bridge.Result_std__shared_ptr_Promise_bool___ {
679
723
  do {
@@ -712,6 +756,44 @@ open class HybridRnIapSpec_cxx {
712
756
  }
713
757
  }
714
758
 
759
+ @inline(__always)
760
+ public final func getReceiptIOS() -> bridge.Result_std__shared_ptr_Promise_std__string___ {
761
+ do {
762
+ let __result = try self.__implementation.getReceiptIOS()
763
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
764
+ let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
765
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
766
+ __result
767
+ .then({ __result in __promiseHolder.resolve(std.string(__result)) })
768
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
769
+ return __promise
770
+ }()
771
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
772
+ } catch (let __error) {
773
+ let __exceptionPtr = __error.toCpp()
774
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
775
+ }
776
+ }
777
+
778
+ @inline(__always)
779
+ public final func requestReceiptRefreshIOS() -> bridge.Result_std__shared_ptr_Promise_std__string___ {
780
+ do {
781
+ let __result = try self.__implementation.requestReceiptRefreshIOS()
782
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__string__ in
783
+ let __promise = bridge.create_std__shared_ptr_Promise_std__string__()
784
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__string__(__promise)
785
+ __result
786
+ .then({ __result in __promiseHolder.resolve(std.string(__result)) })
787
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
788
+ return __promise
789
+ }()
790
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__resultCpp)
791
+ } catch (let __error) {
792
+ let __exceptionPtr = __error.toCpp()
793
+ return bridge.create_Result_std__shared_ptr_Promise_std__string___(__exceptionPtr)
794
+ }
795
+ }
796
+
715
797
  @inline(__always)
716
798
  public final func isTransactionVerifiedIOS(sku: std.string) -> bridge.Result_std__shared_ptr_Promise_bool___ {
717
799
  do {
@@ -17,10 +17,10 @@ public extension IapPlatform {
17
17
  */
18
18
  init?(fromString string: String) {
19
19
  switch string {
20
- case "android":
21
- self = .android
22
20
  case "ios":
23
21
  self = .ios
22
+ case "android":
23
+ self = .android
24
24
  default:
25
25
  return nil
26
26
  }
@@ -31,10 +31,10 @@ public extension IapPlatform {
31
31
  */
32
32
  var stringValue: String {
33
33
  switch self {
34
- case .android:
35
- return "android"
36
34
  case .ios:
37
35
  return "ios"
36
+ case .android:
37
+ return "android"
38
38
  }
39
39
  }
40
40
  }
@@ -18,7 +18,7 @@ public extension PurchaseAndroid {
18
18
  /**
19
19
  * Create a new instance of `PurchaseAndroid`.
20
20
  */
21
- init(autoRenewingAndroid: Bool?, dataAndroid: String?, developerPayloadAndroid: String?, id: String, ids: [String]?, isAcknowledgedAndroid: Bool?, isAutoRenewing: Bool, obfuscatedAccountIdAndroid: String?, obfuscatedProfileIdAndroid: String?, packageNameAndroid: String?, platform: IapPlatform, productId: String, purchaseState: PurchaseState, purchaseToken: String?, quantity: Double, signatureAndroid: String?, transactionDate: Double) {
21
+ init(autoRenewingAndroid: Bool?, dataAndroid: String?, developerPayloadAndroid: String?, id: String, ids: [String]?, isAcknowledgedAndroid: Bool?, isAutoRenewing: Bool, obfuscatedAccountIdAndroid: String?, obfuscatedProfileIdAndroid: String?, packageNameAndroid: String?, platform: IapPlatform, productId: String, purchaseState: PurchaseState, purchaseToken: String?, quantity: Double, signatureAndroid: String?, transactionDate: Double, transactionId: String?) {
22
22
  self.init({ () -> bridge.std__optional_bool_ in
23
23
  if let __unwrappedValue = autoRenewingAndroid {
24
24
  return bridge.create_std__optional_bool_(__unwrappedValue)
@@ -85,7 +85,13 @@ public extension PurchaseAndroid {
85
85
  } else {
86
86
  return .init()
87
87
  }
88
- }(), transactionDate)
88
+ }(), transactionDate, { () -> bridge.std__optional_std__string_ in
89
+ if let __unwrappedValue = transactionId {
90
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
91
+ } else {
92
+ return .init()
93
+ }
94
+ }())
89
95
  }
90
96
 
91
97
  var autoRenewingAndroid: Bool? {
@@ -396,4 +402,28 @@ public extension PurchaseAndroid {
396
402
  self.__transactionDate = newValue
397
403
  }
398
404
  }
405
+
406
+ var transactionId: String? {
407
+ @inline(__always)
408
+ get {
409
+ return { () -> String? in
410
+ if bridge.has_value_std__optional_std__string_(self.__transactionId) {
411
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__transactionId)
412
+ return String(__unwrapped)
413
+ } else {
414
+ return nil
415
+ }
416
+ }()
417
+ }
418
+ @inline(__always)
419
+ set {
420
+ self.__transactionId = { () -> bridge.std__optional_std__string_ in
421
+ if let __unwrappedValue = newValue {
422
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
423
+ } else {
424
+ return .init()
425
+ }
426
+ }()
427
+ }
428
+ }
399
429
  }
@@ -18,7 +18,7 @@ public extension PurchaseIOS {
18
18
  /**
19
19
  * Create a new instance of `PurchaseIOS`.
20
20
  */
21
- init(appAccountToken: String?, appBundleIdIOS: String?, countryCodeIOS: String?, currencyCodeIOS: String?, currencySymbolIOS: String?, environmentIOS: String?, expirationDateIOS: Double?, id: String, ids: [String]?, isAutoRenewing: Bool, isUpgradedIOS: Bool?, offerIOS: PurchaseOfferIOS?, originalTransactionDateIOS: Double?, originalTransactionIdentifierIOS: String?, ownershipTypeIOS: String?, platform: IapPlatform, productId: String, purchaseState: PurchaseState, purchaseToken: String?, quantity: Double, quantityIOS: Double?, reasonIOS: String?, reasonStringRepresentationIOS: String?, revocationDateIOS: Double?, revocationReasonIOS: String?, storefrontCountryCodeIOS: String?, subscriptionGroupIdIOS: String?, transactionDate: Double, transactionReasonIOS: String?, webOrderLineItemIdIOS: String?) {
21
+ init(appAccountToken: String?, appBundleIdIOS: String?, countryCodeIOS: String?, currencyCodeIOS: String?, currencySymbolIOS: String?, environmentIOS: String?, expirationDateIOS: Double?, id: String, ids: [String]?, isAutoRenewing: Bool, isUpgradedIOS: Bool?, offerIOS: PurchaseOfferIOS?, originalTransactionDateIOS: Double?, originalTransactionIdentifierIOS: String?, ownershipTypeIOS: String?, platform: IapPlatform, productId: String, purchaseState: PurchaseState, purchaseToken: String?, quantity: Double, quantityIOS: Double?, reasonIOS: String?, reasonStringRepresentationIOS: String?, revocationDateIOS: Double?, revocationReasonIOS: String?, storefrontCountryCodeIOS: String?, subscriptionGroupIdIOS: String?, transactionDate: Double, transactionId: String, transactionReasonIOS: String?, webOrderLineItemIdIOS: String?) {
22
22
  self.init({ () -> bridge.std__optional_std__string_ in
23
23
  if let __unwrappedValue = appAccountToken {
24
24
  return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
@@ -151,7 +151,7 @@ public extension PurchaseIOS {
151
151
  } else {
152
152
  return .init()
153
153
  }
154
- }(), transactionDate, { () -> bridge.std__optional_std__string_ in
154
+ }(), transactionDate, std.string(transactionId), { () -> bridge.std__optional_std__string_ in
155
155
  if let __unwrappedValue = transactionReasonIOS {
156
156
  return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
157
157
  } else {
@@ -718,6 +718,17 @@ public extension PurchaseIOS {
718
718
  }
719
719
  }
720
720
 
721
+ var transactionId: String {
722
+ @inline(__always)
723
+ get {
724
+ return String(self.__transactionId)
725
+ }
726
+ @inline(__always)
727
+ set {
728
+ self.__transactionId = std.string(newValue)
729
+ }
730
+ }
731
+
721
732
  var transactionReasonIOS: String? {
722
733
  @inline(__always)
723
734
  get {
@@ -17,16 +17,16 @@ public extension PurchaseState {
17
17
  */
18
18
  init?(fromString string: String) {
19
19
  switch string {
20
- case "deferred":
21
- self = .deferred
22
- case "failed":
23
- self = .failed
24
20
  case "pending":
25
21
  self = .pending
26
22
  case "purchased":
27
23
  self = .purchased
24
+ case "failed":
25
+ self = .failed
28
26
  case "restored":
29
27
  self = .restored
28
+ case "deferred":
29
+ self = .deferred
30
30
  case "unknown":
31
31
  self = .unknown
32
32
  default:
@@ -39,16 +39,16 @@ public extension PurchaseState {
39
39
  */
40
40
  var stringValue: String {
41
41
  switch self {
42
- case .deferred:
43
- return "deferred"
44
- case .failed:
45
- return "failed"
46
42
  case .pending:
47
43
  return "pending"
48
44
  case .purchased:
49
45
  return "purchased"
46
+ case .failed:
47
+ return "failed"
50
48
  case .restored:
51
49
  return "restored"
50
+ case .deferred:
51
+ return "deferred"
52
52
  case .unknown:
53
53
  return "unknown"
54
54
  }
@@ -29,6 +29,7 @@ namespace margelo::nitro::iap {
29
29
  prototype.registerHybridMethod("getStorefrontIOS", &HybridRnIapSpec::getStorefrontIOS);
30
30
  prototype.registerHybridMethod("getAppTransactionIOS", &HybridRnIapSpec::getAppTransactionIOS);
31
31
  prototype.registerHybridMethod("requestPromotedProductIOS", &HybridRnIapSpec::requestPromotedProductIOS);
32
+ prototype.registerHybridMethod("getPromotedProductIOS", &HybridRnIapSpec::getPromotedProductIOS);
32
33
  prototype.registerHybridMethod("buyPromotedProductIOS", &HybridRnIapSpec::buyPromotedProductIOS);
33
34
  prototype.registerHybridMethod("presentCodeRedemptionSheetIOS", &HybridRnIapSpec::presentCodeRedemptionSheetIOS);
34
35
  prototype.registerHybridMethod("clearTransactionIOS", &HybridRnIapSpec::clearTransactionIOS);
@@ -39,8 +40,11 @@ namespace margelo::nitro::iap {
39
40
  prototype.registerHybridMethod("getPendingTransactionsIOS", &HybridRnIapSpec::getPendingTransactionsIOS);
40
41
  prototype.registerHybridMethod("syncIOS", &HybridRnIapSpec::syncIOS);
41
42
  prototype.registerHybridMethod("showManageSubscriptionsIOS", &HybridRnIapSpec::showManageSubscriptionsIOS);
43
+ prototype.registerHybridMethod("deepLinkToSubscriptionsIOS", &HybridRnIapSpec::deepLinkToSubscriptionsIOS);
42
44
  prototype.registerHybridMethod("isEligibleForIntroOfferIOS", &HybridRnIapSpec::isEligibleForIntroOfferIOS);
43
45
  prototype.registerHybridMethod("getReceiptDataIOS", &HybridRnIapSpec::getReceiptDataIOS);
46
+ prototype.registerHybridMethod("getReceiptIOS", &HybridRnIapSpec::getReceiptIOS);
47
+ prototype.registerHybridMethod("requestReceiptRefreshIOS", &HybridRnIapSpec::requestReceiptRefreshIOS);
44
48
  prototype.registerHybridMethod("isTransactionVerifiedIOS", &HybridRnIapSpec::isTransactionVerifiedIOS);
45
49
  prototype.registerHybridMethod("getTransactionJwsIOS", &HybridRnIapSpec::getTransactionJwsIOS);
46
50
  prototype.registerHybridMethod("validateReceipt", &HybridRnIapSpec::validateReceipt);
@@ -106,6 +106,7 @@ namespace margelo::nitro::iap {
106
106
  virtual std::shared_ptr<Promise<std::string>> getStorefrontIOS() = 0;
107
107
  virtual std::shared_ptr<Promise<std::optional<std::string>>> getAppTransactionIOS() = 0;
108
108
  virtual std::shared_ptr<Promise<std::optional<NitroProduct>>> requestPromotedProductIOS() = 0;
109
+ virtual std::shared_ptr<Promise<std::optional<NitroProduct>>> getPromotedProductIOS() = 0;
109
110
  virtual std::shared_ptr<Promise<void>> buyPromotedProductIOS() = 0;
110
111
  virtual std::shared_ptr<Promise<bool>> presentCodeRedemptionSheetIOS() = 0;
111
112
  virtual std::shared_ptr<Promise<void>> clearTransactionIOS() = 0;
@@ -116,8 +117,11 @@ namespace margelo::nitro::iap {
116
117
  virtual std::shared_ptr<Promise<std::vector<NitroPurchase>>> getPendingTransactionsIOS() = 0;
117
118
  virtual std::shared_ptr<Promise<bool>> syncIOS() = 0;
118
119
  virtual std::shared_ptr<Promise<std::vector<NitroPurchase>>> showManageSubscriptionsIOS() = 0;
120
+ virtual std::shared_ptr<Promise<bool>> deepLinkToSubscriptionsIOS() = 0;
119
121
  virtual std::shared_ptr<Promise<bool>> isEligibleForIntroOfferIOS(const std::string& groupID) = 0;
120
122
  virtual std::shared_ptr<Promise<std::string>> getReceiptDataIOS() = 0;
123
+ virtual std::shared_ptr<Promise<std::string>> getReceiptIOS() = 0;
124
+ virtual std::shared_ptr<Promise<std::string>> requestReceiptRefreshIOS() = 0;
121
125
  virtual std::shared_ptr<Promise<bool>> isTransactionVerifiedIOS(const std::string& sku) = 0;
122
126
  virtual std::shared_ptr<Promise<std::optional<std::string>>> getTransactionJwsIOS(const std::string& sku) = 0;
123
127
  virtual std::shared_ptr<Promise<std::variant<NitroReceiptValidationResultIOS, NitroReceiptValidationResultAndroid>>> validateReceipt(const NitroReceiptValidationParams& params) = 0;
@@ -29,8 +29,8 @@ namespace margelo::nitro::iap {
29
29
  * An enum which can be represented as a JavaScript union (IapPlatform).
30
30
  */
31
31
  enum class IapPlatform {
32
- ANDROID SWIFT_NAME(android) = 0,
33
- IOS SWIFT_NAME(ios) = 1,
32
+ IOS SWIFT_NAME(ios) = 0,
33
+ ANDROID SWIFT_NAME(android) = 1,
34
34
  } CLOSED_ENUM;
35
35
 
36
36
  } // namespace margelo::nitro::iap
@@ -43,16 +43,16 @@ namespace margelo::nitro {
43
43
  static inline margelo::nitro::iap::IapPlatform fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
44
44
  std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
45
45
  switch (hashString(unionValue.c_str(), unionValue.size())) {
46
- case hashString("android"): return margelo::nitro::iap::IapPlatform::ANDROID;
47
46
  case hashString("ios"): return margelo::nitro::iap::IapPlatform::IOS;
47
+ case hashString("android"): return margelo::nitro::iap::IapPlatform::ANDROID;
48
48
  default: [[unlikely]]
49
49
  throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum IapPlatform - invalid value!");
50
50
  }
51
51
  }
52
52
  static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::IapPlatform arg) {
53
53
  switch (arg) {
54
- case margelo::nitro::iap::IapPlatform::ANDROID: return JSIConverter<std::string>::toJSI(runtime, "android");
55
54
  case margelo::nitro::iap::IapPlatform::IOS: return JSIConverter<std::string>::toJSI(runtime, "ios");
55
+ case margelo::nitro::iap::IapPlatform::ANDROID: return JSIConverter<std::string>::toJSI(runtime, "android");
56
56
  default: [[unlikely]]
57
57
  throw std::invalid_argument("Cannot convert IapPlatform to JS - invalid value: "
58
58
  + std::to_string(static_cast<int>(arg)) + "!");
@@ -64,8 +64,8 @@ namespace margelo::nitro {
64
64
  }
65
65
  std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
66
66
  switch (hashString(unionValue.c_str(), unionValue.size())) {
67
- case hashString("android"):
68
67
  case hashString("ios"):
68
+ case hashString("android"):
69
69
  return true;
70
70
  default:
71
71
  return false;
@@ -53,10 +53,11 @@ namespace margelo::nitro::iap {
53
53
  double quantity SWIFT_PRIVATE;
54
54
  std::optional<std::string> signatureAndroid SWIFT_PRIVATE;
55
55
  double transactionDate SWIFT_PRIVATE;
56
+ std::optional<std::string> transactionId SWIFT_PRIVATE;
56
57
 
57
58
  public:
58
59
  PurchaseAndroid() = default;
59
- explicit PurchaseAndroid(std::optional<bool> autoRenewingAndroid, std::optional<std::string> dataAndroid, std::optional<std::string> developerPayloadAndroid, std::string id, std::optional<std::vector<std::string>> ids, std::optional<bool> isAcknowledgedAndroid, bool isAutoRenewing, std::optional<std::string> obfuscatedAccountIdAndroid, std::optional<std::string> obfuscatedProfileIdAndroid, std::optional<std::string> packageNameAndroid, IapPlatform platform, std::string productId, PurchaseState purchaseState, std::optional<std::string> purchaseToken, double quantity, std::optional<std::string> signatureAndroid, double transactionDate): autoRenewingAndroid(autoRenewingAndroid), dataAndroid(dataAndroid), developerPayloadAndroid(developerPayloadAndroid), id(id), ids(ids), isAcknowledgedAndroid(isAcknowledgedAndroid), isAutoRenewing(isAutoRenewing), obfuscatedAccountIdAndroid(obfuscatedAccountIdAndroid), obfuscatedProfileIdAndroid(obfuscatedProfileIdAndroid), packageNameAndroid(packageNameAndroid), platform(platform), productId(productId), purchaseState(purchaseState), purchaseToken(purchaseToken), quantity(quantity), signatureAndroid(signatureAndroid), transactionDate(transactionDate) {}
60
+ explicit PurchaseAndroid(std::optional<bool> autoRenewingAndroid, std::optional<std::string> dataAndroid, std::optional<std::string> developerPayloadAndroid, std::string id, std::optional<std::vector<std::string>> ids, std::optional<bool> isAcknowledgedAndroid, bool isAutoRenewing, std::optional<std::string> obfuscatedAccountIdAndroid, std::optional<std::string> obfuscatedProfileIdAndroid, std::optional<std::string> packageNameAndroid, IapPlatform platform, std::string productId, PurchaseState purchaseState, std::optional<std::string> purchaseToken, double quantity, std::optional<std::string> signatureAndroid, double transactionDate, std::optional<std::string> transactionId): autoRenewingAndroid(autoRenewingAndroid), dataAndroid(dataAndroid), developerPayloadAndroid(developerPayloadAndroid), id(id), ids(ids), isAcknowledgedAndroid(isAcknowledgedAndroid), isAutoRenewing(isAutoRenewing), obfuscatedAccountIdAndroid(obfuscatedAccountIdAndroid), obfuscatedProfileIdAndroid(obfuscatedProfileIdAndroid), packageNameAndroid(packageNameAndroid), platform(platform), productId(productId), purchaseState(purchaseState), purchaseToken(purchaseToken), quantity(quantity), signatureAndroid(signatureAndroid), transactionDate(transactionDate), transactionId(transactionId) {}
60
61
  };
61
62
 
62
63
  } // namespace margelo::nitro::iap
@@ -85,7 +86,8 @@ namespace margelo::nitro {
85
86
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "purchaseToken")),
86
87
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "quantity")),
87
88
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "signatureAndroid")),
88
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "transactionDate"))
89
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "transactionDate")),
90
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "transactionId"))
89
91
  );
90
92
  }
91
93
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::PurchaseAndroid& arg) {
@@ -107,6 +109,7 @@ namespace margelo::nitro {
107
109
  obj.setProperty(runtime, "quantity", JSIConverter<double>::toJSI(runtime, arg.quantity));
108
110
  obj.setProperty(runtime, "signatureAndroid", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.signatureAndroid));
109
111
  obj.setProperty(runtime, "transactionDate", JSIConverter<double>::toJSI(runtime, arg.transactionDate));
112
+ obj.setProperty(runtime, "transactionId", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.transactionId));
110
113
  return obj;
111
114
  }
112
115
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -131,6 +134,7 @@ namespace margelo::nitro {
131
134
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "quantity"))) return false;
132
135
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "signatureAndroid"))) return false;
133
136
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "transactionDate"))) return false;
137
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "transactionId"))) return false;
134
138
  return true;
135
139
  }
136
140
  };