|
@@ -92,9 +92,9 @@ internal class InAppReceipt {
|
|
|
) -> VerifyPurchaseResult {
|
|
|
|
|
|
// Get receipts info for the product
|
|
|
- let receipts = receipt["receipt"]?["in_app"] as? [ReceiptInfo]
|
|
|
- let receiptsInfo = filterReceiptsInfo(receipts: receipts, withProductId: productId)
|
|
|
- let nonCancelledReceiptsInfo = receiptsInfo.filter { receipt in receipt["cancellation_date"] == nil }
|
|
|
+ let receipts = getInAppReceipts(receipt: receipt)
|
|
|
+ let filteredReceiptsInfo = filterReceiptsInfo(receipts: receipts, withProductId: productId)
|
|
|
+ let nonCancelledReceiptsInfo = filteredReceiptsInfo.filter { receipt in receipt["cancellation_date"] == nil }
|
|
|
|
|
|
let receiptItems = nonCancelledReceiptsInfo.flatMap { ReceiptItem(receiptInfo: $0) }
|
|
|
// Verify that at least one receipt has the right product id
|
|
@@ -174,7 +174,7 @@ internal class InAppReceipt {
|
|
|
case .autoRenewable:
|
|
|
return (receipt["latest_receipt_info"] as? [ReceiptInfo], nil)
|
|
|
case .nonRenewing(let duration):
|
|
|
- return (receipt["receipt"]?["in_app"] as? [ReceiptInfo], duration)
|
|
|
+ return (getInAppReceipts(receipt: receipt), duration)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -186,6 +186,12 @@ internal class InAppReceipt {
|
|
|
}
|
|
|
return Date(millisecondsSince1970: requestDateString)
|
|
|
}
|
|
|
+
|
|
|
+ private class func getInAppReceipts(receipt: ReceiptInfo) -> [ReceiptInfo]? {
|
|
|
+
|
|
|
+ let appReceipt = receipt["receipt"] as? ReceiptInfo
|
|
|
+ return appReceipt?["in_app"] as? [ReceiptInfo]
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Get all the receipts info for a specific product
|