Skip to content

Commit

Permalink
Filter out all receipts with "cancellation_date" != nil (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
bizz84 committed Mar 12, 2017
1 parent 255a965 commit caf6e45
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions SwiftyStoreKit/InAppReceipt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,15 @@ internal class InAppReceipt {
// The values of the latest_receipt and latest_receipt_info keys are useful when checking whether an auto-renewable subscription is currently active. By providing any transaction receipt for the subscription and checking these values, you can get information about the currently-active subscription period. If the receipt being validated is for the latest renewal, the value for latest_receipt is the same as receipt-data (in the request) and the value for latest_receipt_info is the same as receipt.
let (receipts, duration) = getReceiptsAndDuration(for: type, inReceipt: receipt)
let receiptsInfo = filterReceiptsInfo(receipts: receipts, withProductId: productId)
if receiptsInfo.count == 0 {
let nonCancelledReceiptsInfo = receiptsInfo.filter { receipt in receipt["cancellation_date"] == nil }
if nonCancelledReceiptsInfo.count == 0 {
return .notPurchased
}

let receiptDate = getReceiptRequestDate(inReceipt: receipt) ?? date

// Return the expires dates sorted desc
let expiryDateValues = receiptsInfo
let expiryDateValues = nonCancelledReceiptsInfo
.flatMap { (receipt) -> String? in
let key: String = duration != nil ? "original_purchase_date_ms" : "expires_date_ms"
return receipt[key] as? String
Expand Down

0 comments on commit caf6e45

Please sign in to comment.