Auto renew not working in app purchase in swift

I am working on project in which subscription is required. So in that Once I Sign out and do the subscription of purchase than my app work's fine. But Sometimes when I do subscription I get message on console of Subscription Successfull but actually the Subscription is Unsuccessfull. This is my app purchase code of activePurchase which is not working and in paymentQueue code only goes for first time after the sign in but doesn't work everytime

func payments(productID : String){

    if SKPaymentQueue.canMakePayments(){
        
        SVProgressHUD.show()
        
        let paymentRequest = SKMutablePayment()
        paymentRequest.productIdentifier = productID
        SKPaymentQueue.default().add(paymentRequest)
        
    }else{
        
        SVProgressHUD.showError(withStatus: "User unable to make payment")
        print("DEBUG: - User unable to make payment!")
    }
}

func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {

    for transaction in transactions{
        
        switch (transaction.transactionState) {
        
        case .purchasing:
            
            print("DEBUG: - Purchasing... From category")
           
        case .purchased:
            
            print("DEBUG: - Yuppy!!!")
            
            SVProgressHUD.show()
            SKPaymentQueue.default().finishTransaction(transaction)
            SKPaymentQueue.default().remove(self)
            
            print("DEBUG: Transecton - \(transaction)")
            
            let transid = "\(transaction.transactionIdentifier!)"
            
             validate()
            //riceptData()
            
            print("DEBUG: Call InApp From Category!")
            
            SVProgressHUD.showSuccess(withStatus: "Purchase Successfully!")
            
            self.dismiss(animated: true, completion: nil)
            
        case .deferred:
            
            print("DEBUG: - Payment Failed")
            
            SKPaymentQueue.default().finishTransaction(transaction)
            SKPaymentQueue.default().remove(self)
            
            svProgressHUD.dismiss()
            
        case .failed:
            
            print("DEBUG: - Payment Failed")
            
            SKPaymentQueue.default().finishTransaction(transaction)
            SKPaymentQueue.default().remove(self)
            
            svProgressHUD.dismiss()
            
        default:
            
            SKPaymentQueue.default().finishTransaction(transaction)
            SKPaymentQueue.default().remove(self)
            
            svProgressHUD.dismiss()
            
            print("DEBUG: - Something went wrong.")
        }
        
    }
}