title: Testing In-App Purchases (IAP) - Need Help Clearing Transaction Queue
body: <p>I've made an app with an IAP and I'm in my first attempts at testing it, I got the login prompt, but since then, I've failed to get any login prompts (I think it's because there's a failed transaction stuck in the queue). </p>
  
  <p>I'm in desperate need of help in clearing the transaction queue since all this IAP language is very foreign to me. I've read in several places the the below snippet works, but I'm honestly not sure how to use it properly:</p>
  
  <pre><code>for transaction in SKPaymentQueue.default().transactions {
                  guard
                      transaction.transactionState != .purchasing,
                      transaction.transactionState != .deferred
                  else {
                      //Optionally provide user feedback for pending or processing transactions
                      return
                  }
                  //Transaction can now be safely finished
                  SKPaymentQueue.default().finishTransaction(transaction)
              }
  </code></pre>
  
  <p>The snippet finally had the login prompt show up again, but then I'm stuck in a never-ending cycle of logging in.</p>
  
  <p>Below is where I chose to place it but it's currently just having me login again right after already logging in....
  (The new code snippet is between the two comment lines stating "NEW")</p>
  
  <pre><code>func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) { //--------- In App Purchase
          for transaction in transactions{
              //------------------------------------------------------------ New
              for transaction in SKPaymentQueue.default().transactions {
                  guard
                      transaction.transactionState != .purchasing,
                      transaction.transactionState != .deferred
                  else {
                      //Optionally provide user feedback for pending or processing transactions
                      return
                  }
                  //Transaction can now be safely finished
                  SKPaymentQueue.default().finishTransaction(transaction)
              }
              //------------------------------------------------------------ New
              if transaction.transactionState == .purchased {
                  print("Transaction Successful")
                  packsUnlocked = true
              } else if transaction.transactionState == .failed {
                  print("Transaction Failed with error: \(transaction.error)")
              }
          }
  
      }
  </code></pre>
  
  <p>Any help on this really is appreciated since Apple Support could only provide me non-technical support and I've sunk a lot of resources into this app to only be held up by the last step.</p>
  
  <p>Thanks</p>