File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -305,6 +305,8 @@ internal class InAppReceipt {
305305 return . notPurchased
306306 }
307307
308+ let receiptDate = getReceiptRequestDate ( inReceipt: receipt) ?? date
309+
308310 // Return the expires dates sorted desc
309311 let expiryDateValues = receiptsInfo
310312 . flatMap { ( receipt) -> String ? in
@@ -328,7 +330,7 @@ internal class InAppReceipt {
328330 }
329331
330332 // Check if at least 1 receipt is valid
331- if firstExpiryDate. compare ( date ) == . orderedDescending {
333+ if firstExpiryDate. compare ( receiptDate ) == . orderedDescending {
332334
333335 // The subscription is valid
334336 return . purchased( expiryDate: firstExpiryDate)
@@ -339,6 +341,16 @@ internal class InAppReceipt {
339341 }
340342 }
341343
344+ private class func getReceiptRequestDate( inReceipt receipt: ReceiptInfo ) -> Date ? {
345+
346+ guard let receiptInfo = receipt [ " receipt " ] as? ReceiptInfo ,
347+ let requestDateString = receiptInfo [ " request_date_ms " ] as? String ,
348+ let requestDateMs = Double ( requestDateString) else {
349+ return nil
350+ }
351+ return Date ( timeIntervalSince1970: requestDateMs / 1000 )
352+ }
353+
342354 /**
343355 * Get all the receipts info for a specific product
344356 * - Parameter productId: the product id
You can’t perform that action at this time.
0 commit comments