     }
     
     
+    // MARK: Payment Transaction Observer Delegate Method
+    
+    func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
+        print("Purchase Made.")
+    }
+    
+    
     // MARK: Core Data Function
     
     func createArt(title: String, imageName: String, productIdentifier: String, purchased: Bool) {

import StoreKit


class ViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, SKProductsRequestDelegate {

    @IBOutlet weak var collectionView: UICollectionView!
    

    }
    
    
    // When the user taps an item in the collection view that hasn't been purchased - add the product to the payment queue
    
    func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
        let art = gallery[indexPath.row]
        if !art.purchased!.boolValue {
            for product in products {
                if product.productIdentifier == art.productIdentifier {
                    SKPaymentQueue.defaultQueue().addTransactionObserver(self)
                    let payment = SKPayment(product: product)
                    SKPaymentQueue.defaultQueue().addPayment(payment)
                }
            }
        }
    }
    
    
    // MARK: Collection View Layout Delegate Methods
    
    func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
