我正在为一个已经上线的应用程序进行应用程序内购买。应用程序名称是假设 TestApp,我在其中实现了应用程序购买,并假设用户从他的 iTunes id(比如说 itunes@example.com)订阅自动续订订阅以购买 ID 为“com.subscription.example”的自动续订订阅他的应用程序通过他的个人帐户 (personal@gmail.com) 登录。
他的 iTunes 电子邮件 ID 和个人电子邮件 ID 在这里是不同的。一切正常,付款完成,然后我相应地更新并点击相应的 API。
现在的问题:如果他从他朋友的电子邮件 ID 登录他的应用程序,假设“friend@gmail.com”并使用他的相同苹果 ID(即 itunes@example.com)为他购买订阅(“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()
}
}