|
@@ -96,7 +96,12 @@ internal class InAppReceipt {
|
|
|
let filteredReceiptsInfo = filterReceiptsInfo(receipts: receipts, withProductIds: [productId])
|
|
|
let nonCancelledReceiptsInfo = filteredReceiptsInfo.filter { receipt in receipt["cancellation_date"] == nil }
|
|
|
|
|
|
- let receiptItems = nonCancelledReceiptsInfo.compactMap { ReceiptItem(receiptInfo: $0) }
|
|
|
+ #if swift(>=4.1)
|
|
|
+ let receiptItems = nonCancelledReceiptsInfo.compactMap { ReceiptItem(receiptInfo: $0) }
|
|
|
+ #else
|
|
|
+ let receiptItems = nonCancelledReceiptsInfo.flatMap { ReceiptItem(receiptInfo: $0) }
|
|
|
+ #endif
|
|
|
+
|
|
|
// Verify that at least one receipt has the right product id
|
|
|
if let firstItem = receiptItems.first {
|
|
|
return .purchased(item: firstItem)
|
|
@@ -133,7 +138,11 @@ internal class InAppReceipt {
|
|
|
|
|
|
let receiptDate = getReceiptRequestDate(inReceipt: receipt) ?? date
|
|
|
|
|
|
- let receiptItems = nonCancelledReceiptsInfo.compactMap { ReceiptItem(receiptInfo: $0) }
|
|
|
+ #if swift(>=4.1)
|
|
|
+ let receiptItems = nonCancelledReceiptsInfo.compactMap { ReceiptItem(receiptInfo: $0) }
|
|
|
+ #else
|
|
|
+ let receiptItems = nonCancelledReceiptsInfo.flatMap { ReceiptItem(receiptInfo: $0) }
|
|
|
+ #endif
|
|
|
|
|
|
if nonCancelledReceiptsInfo.count > receiptItems.count {
|
|
|
print("receipt has \(nonCancelledReceiptsInfo.count) items, but only \(receiptItems.count) were parsed")
|
|
@@ -163,12 +172,21 @@ internal class InAppReceipt {
|
|
|
return (expirationDate, $0)
|
|
|
}
|
|
|
} else {
|
|
|
- return receiptItems.compactMap {
|
|
|
- if let expirationDate = $0.subscriptionExpirationDate {
|
|
|
- return (expirationDate, $0)
|
|
|
+ #if swift(>=4.1)
|
|
|
+ return receiptItems.compactMap {
|
|
|
+ if let expirationDate = $0.subscriptionExpirationDate {
|
|
|
+ return (expirationDate, $0)
|
|
|
+ }
|
|
|
+ return nil
|
|
|
}
|
|
|
- return nil
|
|
|
- }
|
|
|
+ #else
|
|
|
+ return receiptItems.compactMap {
|
|
|
+ if let expirationDate = $0.subscriptionExpirationDate {
|
|
|
+ return (expirationDate, $0)
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ #endif
|
|
|
}
|
|
|
}
|
|
|
|