我正在为已经上线的应用进行应用内购买。应用程序名称是假设TestApp,我在其中购买了应用程序,并假设用户从其iTunes ID(例如itunes@example.com)订阅自动更新订阅,以购买ID为“ com.subscription.example”的自动更新订阅通过他的个人帐户(personal@gmail.com)登录的他的应用。
他的iTunes电子邮件ID和个人电子邮件ID在这里不同。一切正常,付款完成,然后我进行相应更新并点击相应的API。
现在是问题:如果他从朋友的电子邮件ID登录到他的应用,则假设“ friend@gmail.com”并使用相同的苹果ID(即itunes @)为他购买了订阅(“ com.subscription.example”)例如,在购买时Apple会说该产品已被订阅,并将进入购买支付功能的成功区,然后所有API等都将被点击,因此新的订阅将在其朋友的帐户中被激活,而无需任何付款。该怎么办?
这是我用于购买付款的功能(我正在使用swiftystorekit),它仅需要购买ID作为参数。
func purchaseProduct(id: String) {
if self.canMakePurchases() {
UIApplication.shared.isNetworkActivityIndicatorVisible = true
purchaseButton.isUserInteractionEnabled = false
purchaseButton.alpha = 0.6
NVActivityIndicatorPresenter.sharedInstance.startAnimating(activityData)
purchaseButton.setTitle("Please wait..", for: .normal)
SwiftyStoreKit.purchaseProduct(id, quantity: 1, atomically: true) { result in
NVActivityIndicatorPresenter.sharedInstance.stopAnimating()
UIApplication.shared.isNetworkActivityIndicatorVisible = false
self.purchaseButton.isUserInteractionEnabled = true
self.purchaseButton.setTitle("Purchase", for: .normal)
self.purchaseButton.alpha = 1
switch result {
case .success(let purchase):
print("Purchase Success: \(purchase.productId)")
let transactionId = purchase.transaction.transactionIdentifier
self.createSubscription(status:"active",transID : transactionId!)
case .error(let error):
self.createSubscription(status: "not_subscribed",transID:"")
switch error.code {
case .unknown: print("Unknown error. Please contact support")
case .clientInvalid: print("Not allowed to make the payment")
case .paymentCancelled: break
case .paymentInvalid: print("The purchase identifier was invalid")
case .paymentNotAllowed: print("The device is not allowed to make the payment")
case .storeProductNotAvailable: print("The product is not available in the current storefront")
case .cloudServicePermissionDenied: print("Access to cloud service information is not allowed")
case .cloudServiceNetworkConnectionFailed: print("Could not connect to the network")
case .cloudServiceRevoked: print("User has revoked permission to use this cloud service")
}
}
}
} else {
UIAlertView(title: "Sorry",
message: "Purchases are disabled in your device!",
delegate: nil, cancelButtonTitle: "OK").show()
}
}