react-native-iap 16.2.4 → 16.3.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 (29) hide show
  1. package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +4 -0
  2. package/ios/HybridRnIap.swift +4 -0
  3. package/lib/module/index.js +6 -1
  4. package/lib/module/index.js.map +1 -1
  5. package/lib/module/types.js.map +1 -1
  6. package/lib/module/vega-adapter.js +10 -0
  7. package/lib/module/vega-adapter.js.map +1 -1
  8. package/lib/typescript/src/index.d.ts +3 -1
  9. package/lib/typescript/src/index.d.ts.map +1 -1
  10. package/lib/typescript/src/specs/RnIap.nitro.d.ts +4 -0
  11. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
  12. package/lib/typescript/src/types.d.ts +11 -0
  13. package/lib/typescript/src/types.d.ts.map +1 -1
  14. package/lib/typescript/src/vega-adapter.d.ts.map +1 -1
  15. package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitAmazonProps.hpp +5 -1
  16. package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitResult.hpp +5 -1
  17. package/nitrogen/generated/android/c++/JVariant_NullType_NitroVerifyPurchaseWithIapkitAmazonProps.hpp +1 -1
  18. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitAmazonProps.kt +8 -3
  19. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitResult.kt +7 -2
  20. package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitAmazonProps.swift +39 -2
  21. package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitResult.swift +38 -1
  22. package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitAmazonProps.hpp +6 -2
  23. package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitResult.hpp +5 -1
  24. package/openiap-versions.json +3 -3
  25. package/package.json +1 -1
  26. package/src/index.ts +6 -1
  27. package/src/specs/RnIap.nitro.ts +4 -0
  28. package/src/types.ts +11 -0
  29. package/src/vega-adapter.ts +15 -0
package/src/types.ts CHANGED
@@ -1791,6 +1791,11 @@ export interface RequestSubscriptionPropsByPlatforms {
1791
1791
  }
1792
1792
 
1793
1793
  export interface RequestVerifyPurchaseWithIapkitAmazonProps {
1794
+ /**
1795
+ * Available in OpenIAP Spec 3.2.0 / openiap-apple 3.2.0 / openiap-google 3.3.0.
1796
+ * Optional Amazon product id that must match the product id verified by RVS.
1797
+ */
1798
+ expectedProductId?: (string | null);
1794
1799
  /** Amazon Appstore receipt id returned by PurchaseResponse.getReceipt().getReceiptId(). */
1795
1800
  receiptId: string;
1796
1801
  /** Use Amazon RVS Cloud Sandbox for App Tester receipts. */
@@ -1848,6 +1853,12 @@ export interface RequestVerifyPurchaseWithIapkitResult {
1848
1853
  * Apple or Google receipt is valid, and a payload exists for that product.
1849
1854
  */
1850
1855
  clientPayload?: (IapkitProductClientPayload | null);
1856
+ /**
1857
+ * Available in OpenIAP Spec 3.2.0 / openiap-apple 3.2.0 / openiap-google 3.3.0.
1858
+ * Amazon RVS environment selected by IAPKit. Present as `Sandbox` or
1859
+ * `Production` on handled Amazon verification results.
1860
+ */
1861
+ environment?: (string | null);
1851
1862
  /**
1852
1863
  * True when the purchase is valid and actionable.
1853
1864
  * Only entitled, pending-acknowledgment, or ready-to-consume return true.
@@ -1271,8 +1271,20 @@ export function createVegaIapModule(service: VegaPurchasingService): RnIap {
1271
1271
  `IAPKit returned malformed response (HTTP ${status}).`,
1272
1272
  );
1273
1273
  }
1274
+ const environment = json.environment;
1275
+ if (
1276
+ environment != null &&
1277
+ (typeof environment !== 'string' ||
1278
+ (environment !== 'Sandbox' && environment !== 'Production'))
1279
+ ) {
1280
+ throw createVegaError(
1281
+ ErrorCode.PurchaseVerificationFailed,
1282
+ `IAPKit returned malformed response (HTTP ${status}).`,
1283
+ );
1284
+ }
1274
1285
 
1275
1286
  return {
1287
+ ...(environment == null ? {} : {environment}),
1276
1288
  isValid: json.isValid,
1277
1289
  ...(productId == null ? {} : {productId}),
1278
1290
  state: normalizeIapkitState(json.state),
@@ -1341,6 +1353,9 @@ export function createVegaIapModule(service: VegaPurchasingService): RnIap {
1341
1353
  store: 'amazon',
1342
1354
  userId,
1343
1355
  receiptId,
1356
+ ...(amazon.expectedProductId == null
1357
+ ? {}
1358
+ : {expectedProductId: amazon.expectedProductId}),
1344
1359
  ...(amazon.sandbox == null ? {} : {sandbox: amazon.sandbox}),
1345
1360
  }),
1346
1361
  signal: controller.signal,