感谢这里的支持,能够显示促销优惠,但在完成付款流程、输入密码并确认购买后,我收到一个错误弹出窗口,显示“无法购买。请联系开发商了解更多信息” .”
在日志中,我收到以下错误:
以下是我传递给组合字符串的示例参数值 appBundleId + '\u2063' + keyIdentifier + '\u2063' + ProductIdentifier + '\u2063' + OfferIdentifier + '\u2063' + appAccountToken + '\u2063' +随机数 + '\u2063' + 时间戳
我如何生成签名(Java)
/* promotionalOfferKey = value between "-----BEGIN PRIVATE KEY-----" and "-----END PRIVATE KEY-----" from the downloaded p8 file from App Store Connect associated with the keyIdentifier parameter above */
// stringToSign = the combined string above
byte[] encoded = Base64.getDecoder().decode(promotionalOfferKey);
KeyFactory keyFactory = KeyFactory.getInstance("EC");
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded);
Signature ecdsaSign = Signature.getInstance("SHA256withECDSA");
ecdsaSign.initSign(keyFactory.generatePrivate(keySpec));
ecdsaSign.update(stringToSign.getBytes(StandardCharsets.UTF_8));
byte[] signature = ecdsaSign.sign();
signatureToReturn = Base64.getEncoder().encodeToString(signature);
我做错了什么?预先感谢您。
我们在一个项目中也遇到了同样的问题。问题是我们的后端使用生产密钥来签署有效负载。但对于 StoreKit 测试,你必须使用测试密钥。
要检索该密钥:
.storekit
文件Editor > Subscription Offers Key
使用该密钥签署沙盒环境的报价。