                 }
                 
                 break
-            case .failed:
-                
-                //update the UI to let user know it is happenening
-                let transactionIndex = pendingTransactions.index(of: transaction)
-                if let transactionIndex = transactionIndex {
-                    pendingTransactions.remove(at: transactionIndex)
-                }
-                
+                
+            case .deferred:
+                
+                //this could take some time before transaction is updated
+                
+                //update the UI to let user know it is happenening
+                //for deferred cases, transaction is pending.
+                pendingTransactions.append(transaction)
                 
                 //determine the indexPath of this payment
                 //go through the data source array and look for the payment ID

                }
                
                break
                
            case .deferred:
                
                //this could take some time before transaction is updated
                
                //update the UI to let user know it is happenening
                //for deferred cases, transaction is pending.
                pendingTransactions.append(transaction)
                
                //determine the indexPath of this payment
                //go through the data source array and look for the payment ID
                var index = 0
                for product in appStoreProducts {
                    if product.productIdentifier == transaction.payment.productIdentifier {
                        
                        let section = iapsSection //section 2 is IAPs here
                        let indexPath = IndexPath(item: index, section: section)
                        
                        //reload this cell, it will check for this when reloading
                        collectionView.reloadItems(at: [indexPath])
                        break
                    }
                    index += 1
                }
                
                break
            default:
                break
                

                    pendingTransactions.remove(at: transactionIndex)
                }
                
                //reload the characters and the tools (and the in app purchase cell)
                collectionView.reloadData()
                
                //determine the indexPath of this payment
                //go through the data source array and look for the payment ID
//                var index = 0
//                for product in appStoreProducts {
//                    if product.productIdentifier == transaction.payment.productIdentifier {
//                        
//                        let section = iapsSection //section 2 is IAPs here
//                        let indexPath = IndexPath(item: index, section: section)
//                        
//                        //reload this cell, it will check for this when reloading
//                        collectionView.reloadItems(at: [indexPath])
//                        break
//                    }
//                    index += 1
//                }
                
                break
            case .failed:
                
                //update the UI to let user know it is happenening
                let transactionIndex = pendingTransactions.index(of: transaction)
                if let transactionIndex = transactionIndex {
                    pendingTransactions.remove(at: transactionIndex)
                }
                
                
                //determine the indexPath of this payment
                //go through the data source array and look for the payment ID
