title: When I buy an in app purchase for one level the other level unlocks too...Why does this happen?
body: <p>I have these two different in app purchases and when I buy one level the other level gets unlocked also. Why does this happen? Here is the code I have it is kind of long so sorry for that. I want to make sure you can see if there is anything wrong with the code. Thanks!</p>
  
  <pre><code>// IAP functions
  
  func unlockLevel() {
      if SKPaymentQueue.canMakePayments() {
          var productID:NSSet = NSSet(object: "unlockLevelTwo")
          var productsRequest:SKProductsRequest = SKProductsRequest(productIdentifiers: productID as Set&lt;NSObject&gt;)
          productsRequest.delegate = self
          productsRequest.start()
          println("Fetching products...")
      }
      else {
          println("Can't make purchases")
      }
  }
  
  
  func unlockLevel2() {
      if SKPaymentQueue.canMakePayments() {
          var productID:NSSet = NSSet(object: "unlockLevelThree")
          var productsRequest:SKProductsRequest = SKProductsRequest(productIdentifiers: productID as Set&lt;NSObject&gt;)
          productsRequest.delegate = self
          productsRequest.start()
          println("Fetching products...")
      }
      else {
          println("Can't make purchases")
      }
  }
  
  
  
  func buyProduct(product: SKProduct) {
      println("Sending the Payment Request to Apple");
      var payment = SKPayment(product: product)
      SKPaymentQueue.defaultQueue().addPayment(payment);
  }
  
  func productsRequest(request: SKProductsRequest!, didReceiveResponse response: SKProductsResponse!) {
      var count : Int = response.products.count
      if (count&gt;0) {
          var validProducts = response.products
          var validProduct: SKProduct = response.products[0] as! SKProduct
          if (validProduct.productIdentifier == "unlockLevelTwo") {
              println(validProduct.localizedTitle)
              println(validProduct.localizedDescription)
              println(validProduct.price)
              buyProduct(validProduct);
          }
          if (validProduct.productIdentifier == "unlockLevelThree") {
              println(validProduct.localizedTitle)
              println(validProduct.localizedDescription)
              println(validProduct.price)
              buyProduct(validProduct);
          }
  
  
          else {
              println(validProduct.productIdentifier)
          }
      }
      else {
          println("nothing")
      }
  }
  
  func request(request: SKRequest!, didFailWithError error: NSError!) {
      println("Error fetching product info")
  }
  
  func RestorePurchases() {
      SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
  
  
  }
  
  func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue!) {
  
      for item in queue.transactions {
          if let transaction = item as? SKPaymentTransaction {
              if transaction.transactionState == .Restored {
                  unlockLevel()
                  unlockLevel2()
                  SKPaymentQueue.defaultQueue().finishTransaction(transaction)
                  break
              }
          }
      }
      if queue.transactions.count == 0 {
          println("not restored")
          displayRestoreAlert()
      }
  }
  
  func displayRestoreAlert() {
  
      let alertController = UIAlertController(title: "Level Two has not been purchased on this account.", message: nil, preferredStyle: .Alert)
      let OKAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
      alertController.addAction(OKAction)
      self.viewController.presentViewController(alertController, animated: true, completion: nil)
  
  }
  
  
  
  func paymentQueue(queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!) {
      println("Received Payment Transaction Response from Apple");
  
      for transaction:AnyObject in transactions {
          if let trans:SKPaymentTransaction = transaction as? SKPaymentTransaction{
              switch trans.transactionState {
              case .Purchased:
                  println("Product Purchased");
                  SKPaymentQueue.defaultQueue().finishTransaction(transaction as! SKPaymentTransaction)
                  NSUserDefaults().setBool(true, forKey: "Leavel2")
                  unlockLevelTwo()
                  unlockLevelTwoImage.removeFromParent()
                  unlockLevelTwoButton.removeFromParent()
  
                  NSUserDefaults().setBool(true, forKey: "Leavel3")
                  unlockLevelThree()
                  unlockLevelThreeImage.removeFromParent()
                  unlockLevelThreeButton.removeFromParent()
  
                  break;
              case .Failed:
                  println("Purchased Failed");
                  SKPaymentQueue.defaultQueue().finishTransaction(transaction as! SKPaymentTransaction)
                  break;
              case .Restored:
                  println("Already Purchased");
                  SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
  
              default:
                  break;
              }
          }
      }
  }
  </code></pre>