expo-iap 2.3.4-rc.5 → 2.3.5-rc.1

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.
@@ -71,7 +71,10 @@ func serializeTransaction(_ transaction: Transaction, jwsRepresentationIos: Stri
71
71
  ]
72
72
 
73
73
  if (jwsRepresentationIos != nil) {
74
+ print("DEBUG - serializeTransaction adding jwsRepresentationIos with length: \(jwsRepresentationIos!.count)")
74
75
  purchaseMap["jwsRepresentationIos"] = jwsRepresentationIos
76
+ } else {
77
+ print("DEBUG - serializeTransaction jwsRepresentationIos is nil")
75
78
  }
76
79
 
77
80
  if #available(iOS 16.0, *) {
@@ -237,15 +240,20 @@ public class ExpoIapModule: Module {
237
240
  var purchasedItemsSerialized: [[String: Any?]] = []
238
241
 
239
242
  func addTransaction(transaction: Transaction, jwsRepresentationIos: String? = nil) {
240
- purchasedItemsSerialized.append(serializeTransaction(transaction, jwsRepresentationIos: jwsRepresentationIos))
241
- if alsoPublishToEventListener {
242
- self.sendEvent(IapEvent.PurchaseUpdated, serializeTransaction(transaction, jwsRepresentationIos: jwsRepresentationIos))
243
+ // Debug: Log JWS representation
244
+ print("DEBUG - getAvailableItems JWS: \(jwsRepresentationIos != nil ? "exists" : "nil")")
245
+ if let jws = jwsRepresentationIos {
246
+ print("DEBUG - getAvailableItems JWS length: \(jws.count)")
243
247
  }
244
- }
245
-
246
- func addError(error: Error, errorDict: [String: String]) {
248
+
249
+ let serialized = serializeTransaction(transaction, jwsRepresentationIos: jwsRepresentationIos)
250
+ purchasedItemsSerialized.append(serialized)
251
+
252
+ // Debug: Check if jwsRepresentationIos is included in serialized result
253
+ print("DEBUG - getAvailableItems serialized includes JWS: \(serialized["jwsRepresentationIos"] != nil)")
254
+
247
255
  if alsoPublishToEventListener {
248
- self.sendEvent(IapEvent.PurchaseError, errorDict)
256
+ self.sendEvent(IapEvent.PurchaseUpdated, serialized)
249
257
  }
250
258
  }
251
259
 
@@ -287,7 +295,9 @@ public class ExpoIapModule: Module {
287
295
  "message": StoreError.failedVerification.localizedDescription,
288
296
  "productId": "unknown",
289
297
  ]
290
- addError(error: StoreError.failedVerification, errorDict: err)
298
+ if alsoPublishToEventListener {
299
+ self.sendEvent(IapEvent.PurchaseError, err)
300
+ }
291
301
  } catch {
292
302
  let err = [
293
303
  "responseCode": IapErrors.E_UNKNOWN.rawValue,
@@ -296,10 +306,11 @@ public class ExpoIapModule: Module {
296
306
  "message": error.localizedDescription,
297
307
  "productId": "unknown",
298
308
  ]
299
- addError(error: error, errorDict: err)
309
+ if alsoPublishToEventListener {
310
+ self.sendEvent(IapEvent.PurchaseError, err)
311
+ }
300
312
  }
301
313
  }
302
-
303
314
  return purchasedItemsSerialized
304
315
  }
305
316
 
@@ -362,12 +373,21 @@ public class ExpoIapModule: Module {
362
373
  switch result {
363
374
  case .success(let verification):
364
375
  let transaction = try self.checkVerified(verification)
376
+
377
+ // Debug: Log JWS representation
378
+ print("DEBUG - buyProduct JWS: exists")
379
+ print("DEBUG - buyProduct JWS length: \(verification.jwsRepresentation.count)")
380
+
365
381
  if andDangerouslyFinishTransactionAutomatically {
366
382
  await transaction.finish()
367
383
  return nil
368
384
  } else {
369
385
  self.transactions[String(transaction.id)] = transaction
370
386
  let serialized = serializeTransaction(transaction, jwsRepresentationIos: verification.jwsRepresentation)
387
+
388
+ // Debug: Check if jwsRepresentationIos is included in serialized result
389
+ print("DEBUG - buyProduct serialized includes JWS: \(serialized["jwsRepresentationIos"] != nil)")
390
+
371
391
  self.sendEvent(IapEvent.PurchaseUpdated, serialized)
372
392
  return serialized
373
393
  }
@@ -458,9 +478,7 @@ public class ExpoIapModule: Module {
458
478
  } else {
459
479
  throw NSError(
460
480
  domain: "ExpoIapModule", code: 4,
461
- userInfo: [
462
- NSLocalizedDescriptionKey: "Can't find entitlement for sku \(sku)"
463
- ])
481
+ userInfo: [NSLocalizedDescriptionKey: "Can't find entitlement for sku \(sku)"])
464
482
  }
465
483
  } else {
466
484
  throw NSError(
@@ -499,10 +517,7 @@ public class ExpoIapModule: Module {
499
517
  } else {
500
518
  throw NSError(
501
519
  domain: "ExpoIapModule", code: 4,
502
- userInfo: [
503
- NSLocalizedDescriptionKey:
504
- "Can't find latest transaction for sku \(sku)"
505
- ])
520
+ userInfo: [NSLocalizedDescriptionKey: "Can't find latest transaction for sku \(sku)"])
506
521
  }
507
522
  } else {
508
523
  throw NSError(
@@ -562,17 +577,13 @@ public class ExpoIapModule: Module {
562
577
  "Cannot find window scene or not available on macOS"
563
578
  ])
564
579
  }
565
-
566
580
  // Get all subscription products before showing the management UI
567
581
  let subscriptionSkus = await self.getAllSubscriptionProductIds()
568
582
  self.pollingSkus = Set(subscriptionSkus)
569
-
570
583
  // Show the management UI
571
584
  try await AppStore.showManageSubscriptions(in: windowScene)
572
-
573
585
  // Start polling for status changes
574
586
  self.pollForSubscriptionStatusChanges()
575
-
576
587
  return true
577
588
  #else
578
589
  throw NSError(
@@ -649,7 +660,7 @@ public class ExpoIapModule: Module {
649
660
  AsyncFunction("getReceiptData") { () -> String? in
650
661
  return try self.getReceiptDataInternal()
651
662
  }
652
-
663
+
653
664
  AsyncFunction("isTransactionVerified") { (sku: String) -> Bool in
654
665
  guard let productStore = self.productStore else {
655
666
  throw NSError(
@@ -669,7 +680,7 @@ public class ExpoIapModule: Module {
669
680
  }
670
681
  return false
671
682
  }
672
-
683
+
673
684
  AsyncFunction("getTransactionJws") { (sku: String) -> String? in
674
685
  guard let productStore = self.productStore else {
675
686
  throw NSError(
@@ -686,7 +697,7 @@ public class ExpoIapModule: Module {
686
697
  userInfo: [NSLocalizedDescriptionKey: "Can't find transaction for sku \(sku)"])
687
698
  }
688
699
  }
689
-
700
+
690
701
  AsyncFunction("validateReceiptIos") { (sku: String) -> [String: Any] in
691
702
  guard let productStore = self.productStore else {
692
703
  throw NSError(
@@ -721,7 +732,7 @@ public class ExpoIapModule: Module {
721
732
  isValid = false
722
733
  }
723
734
  }
724
-
735
+
725
736
  return [
726
737
  "isValid": isValid,
727
738
  "receiptData": receiptData,
@@ -808,7 +819,6 @@ public class ExpoIapModule: Module {
808
819
 
809
820
  private func pollForSubscriptionStatusChanges() {
810
821
  subscriptionPollingTask?.cancel()
811
-
812
822
  subscriptionPollingTask = Task {
813
823
  try? await Task.sleep(nanoseconds: 1_500_000_000) // 1.5 seconds
814
824
 
@@ -828,7 +838,6 @@ public class ExpoIapModule: Module {
828
838
 
829
839
  for _ in 1...5 {
830
840
  try? await Task.sleep(nanoseconds: 2_000_000_000) // 2 seconds
831
-
832
841
  if Task.isCancelled {
833
842
  return
834
843
  }
@@ -837,7 +846,6 @@ public class ExpoIapModule: Module {
837
846
  guard let product = await self.productStore?.getProduct(productID: sku),
838
847
  let status = try? await product.subscription?.status.first,
839
848
  let result = await product.latestTransaction else { continue }
840
-
841
849
  // Try to verify the transaction
842
850
  let transaction: Transaction
843
851
  do {
@@ -866,12 +874,10 @@ public class ExpoIapModule: Module {
866
874
 
867
875
  self.sendEvent(IapEvent.PurchaseUpdated, purchaseMap)
868
876
  self.sendEvent(IapEvent.TransactionIapUpdated, ["transaction": purchaseMap])
869
-
870
877
  previousStatuses[sku] = currentWillAutoRenew
871
878
  }
872
879
  }
873
880
  }
874
-
875
881
  self.pollingSkus.removeAll()
876
882
  }
877
883
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-iap",
3
- "version": "2.3.4-rc.5",
3
+ "version": "2.3.5-rc.1",
4
4
  "description": "In App Purchase module in Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",