在iOS中的InApp购买付款
我需要使用InApp购买来订阅计划。进行付款,但我正在显示沙盒环境中的警报,例如“您想购买....”。我需要添加我的卡详细信息,并显示一些示例交易。如何重定向到付款并添加卡详细信息?如何在以下情况下完成InApp购买付款 实时环境。
// MARK: - IAP payment queue
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
for transaction:AnyObject in transactions {
if let trans = transaction as? SKPaymentTransaction {
switch trans.transactionState {
case .purchased:
hideLoader()
if let paymentTransaction = transaction as? SKPaymentTransaction {
SKPaymentQueue.default().finishTransaction(paymentTransaction)
}
if productID == PRODUCT_ID {
UserDefaults.standard.set(true, forKey: "isPurchased")
lblPurchaseDone.text = "Pro version PURCHASED!"
lblPurchaseDone.isHidden = false
btnPurchase.isHidden = true
btnRestore.isHidden = true
self.present(Utilities().showAlertContrller(title: "Purchase Success", message: "You've successfully purchased"), animated: true, completion: nil)
}
case .failed:
hideLoader()
if trans.error != nil {
self.present(Utilities().showAlertContrller(title: "Purchase failed!", message: trans.error!.localizedDescription), animated: true, completion: nil)
print(trans.error!)
}
SKPaymentQueue.default().finishTransaction(transaction as! SKPaymentTransaction)
case .restored:
print("restored")
SKPaymentQueue.default().finishTransaction(transaction as! SKPaymentTransaction)
default: break
}
}
}
}