0

我正在处理需要订阅的项目。因此,一旦我退出并订阅购买,我的应用程序就可以正常工作了。但有时当我订阅时,我会在订阅成功的控制台上收到消息,但实际上订阅不成功。这是我的 activePurchase 应用程序购买代码,该代码不起作用,并且在 paymentQueue 代码中仅在登录后第一次使用,但并非每次都有效

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.")
            }
            
        }
    }
4

0 回答 0