ios - 从 Cloud Code 解析 iOS 应用购买验证

标签 ios parse-platform in-app-purchase verify

几天以来,我一直在尝试在购买前保存(在沙盒上)上实现 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/

相关文章:

ios - 如何在 Swift 中实现 "share button"

ios - PFLogInViewController 问题

swift - 在 Swift 中,为什么 GCD 不能与解析一起使用?

objective-c - 关闭商店 View 后在 App Purchase 中崩溃

Android In-App Purchase 离线查看买家

ios - ios5中的自动旋转——失败的最常见原因?

javascript - 返回 promise 后无法从 Controller 更新 View

swift - 缩略图图像未显示在 MKMapView 注释 View 中

iphone - 应用内购买的内容来自哪里?

objective-c - 添加 CocoaAsyncSocket 时体系结构 armv7 的 undefined symbol