ios - 购买促销优惠(苹果):签名无效(SKErrorDomain 错误 12。)
问题描述
首先,我们实施了基本订阅和免费试用(介绍性优惠),并且都运行良好。在那之后,我们实现了Promotional Offer
这个问题:即使我们遵循 Apple 在他们的文档中提供的指南(从上到下),我们总是得到同样的错误,即“签名无效。”。
("Error: The operation couldn’t be completed. (SKErrorDomain error 12.)"
提及:
- 签名是在我们的服务器端实现的
- 签名被验证为有效
- 我尝试使用从终端使用 openssl 生成的签名(已验证也是有效的),但仍然无法正常工作
- 在 UI 上,我们有一个标记为按钮的按钮
Purchase Offer
,当点击该按钮时,Apple 的底部模式会正确显示,价格根据报价而定 - 在移动端,我们使用
swift (5)
和SwiftyStoreKit
处理购买。 - 测试是使用沙盒帐户进行的(开发和测试飞行构建)
以下是申请优惠的基本方法:
func proceedToApplyOffer(signatureResult: PromotionalOfferSignatureResponse, username: String, completion: @escaping ((_ purchaseResult: Result<PurchaseDetails>) -> ())) {
if #available(iOS 12.2, *) {
self.getAppleProducts() {
productsResult in
// Get the apple products in order to be able to create the discount object
switch productsResult {
case .success(products: let products):
// Create the discount object with which the purchase will be made
guard let monthlyProduct: SKProduct = products.first(where: { $0.productIdentifier == self.monthlyProductIdentifier}) else { return }
let discount = SKPaymentDiscount(identifier: self.promotionalOfferIdentifier, keyIdentifier: self.keyIdentifier, nonce: signatureResult.nonce, signature: signatureResult.signature, timestamp: NSNumber(value: signatureResult.timestamp))
let swiftyDiscount = PaymentDiscount(discount: discount)
self.paymentService.purchaseProductWithDiscount(product: monthlyProduct, username: username, discount: swiftyDiscount) {
result in
switch result {
case .error(error: let skError):
completion(.error(skError))
case .success(purchase: let purchaseDetails):
completion(.success(purchaseDetails))
}
}
case .error(error: let error):
completion(.error(error))
}
}
}
else {
debugPrint("Not available on current OS version")
}
}
我知道以前有人问过这个问题(我都读过),但他们没有任何答案,我希望这个问题会有答案,因为我得出的结论是,即使是在 apple.developer 上发布的问题论坛仍未得到答复。我将不胜感激任何帮助,任何想法谢谢
解决方案
推荐阅读
- php - 使用字符串连接的 SQL 查询
- azure - 删除 Azure 文件共享中的文件失败,错误:指定的资源是只读的,此时无法修改
- elasticsearch - 具有 xpack 安全性的 Elasticsearch 失败
- python - 为什么Python中的for循环会输出3次列表?
- php - 如何在 woocommerce 结帐(自定义主题)中更改“您的订单”标题 - 翻译成德语
- r - geom_density 在提供的美学方面是盲目的?
- c# - 在asp.net核心模态中绑定新的模态字段
- firebase - Firebase 托管重写无法正常工作
- excel - 在 Excel 中显示用破折号分隔的两个数字的类似数字格式
- python - Django:尝试在迁移中将用户设置为外键会引发 ValueError