几天以来,我一直在尝试在购买前保存(在沙盒上)上实现 iOS 应用内购买验证,但它总是失败。 我用 postman 尝试了收据,它有效。
那么,就是Parse.Cloud.httpRequest的问题了。
我还尝试将收据直接放入 Cloud Code 中,但始终出现相同的错误 (21002)。 https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html
这是我的代码:
Parse.Cloud.httpRequest({
method: 'POST',
url:'https://sandbox.itunes.apple.com/verifyReceipt',
body:{'receipt-data':receipt},
success: function (httpResponse) {
console.log(httpResponse.text);
if (httpResponse.status == 0) {
// success
} else {
// error
}
},
error: function (httpResponse) {
// error
}
});
有人做过吗?
最佳答案
如果这是自动续订订阅? 如果是这样,您错过了密码字段:
password Only used for receipts that contain auto-renewable subscriptions. Your app’s shared secret (a hexadecimal string).
在 jsonBody 中:
var jsonBody = {
"receipt-data" : reference,
"password" : "xxxxx"
};
你还应该对 POST BODY 进行 JSON 编码(下面的节点示例)
itunes_client.post("", {}, JSON.stringify(jsonBody),
关于ios - 从 Cloud Code 解析 iOS 应用购买验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31452246/