             
             print("Got user record ID.")
             
-            
+            // Get the current user.
             self.publicDatabase.fetchRecordWithID(userRecordID, completionHandler: { (userRecord : CKRecord?, error : NSError?) -> Void in
                 
                 if let user = userRecord {
                     
-                    // Create a purchase
-                    let purchase : CKRecord = CKRecord(recordType: "Purchase", zoneID: self.defaultRecordZone.zoneID)
-                    purchase[self.keyUserWhoMadePurchase] =  user.recordID.recordName
-                    purchase[self.keyPurchaseDate] = NSDate()
-                    purchase[self.keyProductIdentifier] = payment.productIdentifier
-                    
-                    // Add it to iCloud.
-                    let addPurchaseOperation : CKModifyRecordsOperation = CKModifyRecordsOperation(recordsToSave: [purchase], recordIDsToDelete: nil);
-                    
-                    addPurchaseOperation.modifyRecordsCompletionBlock = { (savedRecords: [CKRecord]?, deletedRecordIDs : [CKRecordID]?, operationError : NSError?) -> Void in
-                        
-                        completion(recorded: true)
-                        
-                    }
-                    
-                    self.publicDatabase.addOperation(addPurchaseOperation)
+                    // Get the previous expiration, in case the user is extending support.
+                    self.fetchPatronageExpiration(withCompletionHandler: { (expirationDate : NSDate?) -> Void in
+                        
+                        var purchaseDate = NSDate()
+                        
+                        // If there's an expiration date that's in the future, use that date as the purchase date.
+                        if let fetchedExpirationDate = expirationDate {
+                            if fetchedExpirationDate.timeIntervalSinceDate(purchaseDate) > 0 {
+                                purchaseDate = fetchedExpirationDate
+                            }
+                        }
+                        
+                        // Create a purchase
+                        let purchase : CKRecord = CKRecord(recordType: "Purchase", zoneID: self.defaultRecordZone.zoneID)
+                        purchase[self.keyUserWhoMadePurchase] =  user.recordID.recordName
+                        purchase[self.keyPurchaseDate] = purchaseDate
+                        purchase[self.keyProductIdentifier] = payment.productIdentifier
+                        purchase[self.keyExpirationDate] = self.expirationDateForPayment(payment: payment, withPurchaseDate: purchaseDate)
+                        
+                        // Add it to iCloud.
+                        let addPurchaseOperation : CKModifyRecordsOperation = CKModifyRecordsOperation(recordsToSave: [purchase], recordIDsToDelete: nil);
+                        
+                        addPurchaseOperation.modifyRecordsCompletionBlock = { (savedRecords: [CKRecord]?, deletedRecordIDs : [CKRecordID]?, operationError : NSError?) -> Void in
+                            
+                            completion(recorded: true)
+                            
+                        }
+                        
+                        self.publicDatabase.addOperation(addPurchaseOperation)
+                    })
                 }
                 else
                 {
+                    completion(recorded: false)
                     print("Got user record ID but failed to get user record.")
                 }
             })
+
         }
     }
 

    private var purchasePatronageCompletionHandler : PurchaseCompletionHandler? = nil
    private var restorePurchaseCompletionHandler : RestorePurchasesCompletionHandler? = nil
    
    // MARK: - Designated Initializer
    
    private override init() {

    
    func fetchPatronCountWithCompletion(completionHandler completionHandler: (count : NSInteger, error : NSError?) -> Void) {
        
        let predicate : NSPredicate = NSPredicate(format: "TRUEFORMAT") // The documentation says to use this for "all of the given type."
        let query : CKQuery = CKQuery(recordType: "User", predicate: predicate)
        
        self.publicDatabase.performQuery(query, inZoneWithID: self.defaultRecordZone.zoneID) { (records : [CKRecord]?, error : NSError?) -> Void in
