【问题标题】:Implement Receipt verification for Apple Store Receipt in C#在 C# 中实现 Apple Store Receipt 的收据验证
【发布时间】:2013-07-26 08:03:09
【问题描述】:

我正在尝试为 In App Apple Store 购买收据实施验证收据。

根据他们的网站,它看起来像?!?。

我需要知道结构,你能帮我提供一个加密的样本吗?

你能帮帮我吗?

要验证收据,请执行以下步骤:

检索收据数据。在 iOS 上,这是 交易的 transactionReceipt 属性。在 OS X 上,这是整个 应用程序包内收据文件的内容。编码 使用 base64 编码的收据数据。创建一个 JSON 对象 名为receipt-data 的键和您在步骤1 中创建的字符串。您的JSON 代码应该是这样的:

{
     "receipt-data" : "(receipt bytes here)" 
} 

使用 HTTP POST 请求将 JSON 对象发布到 App Store。商店的网址是

https://buy.itunes.apple.com/verifyReceipt。收到的回复来自 App Store 是一个 JSON 对象,有两个键,状态和收据。它 应该是这样的:

{
     "status" : 0,
     "receipt" : { (receipt here) } 
}

如果状态键的值为 0,这是一个有效的收据。如果该值不是 0,则

此收据无效。

【问题讨论】:

    标签: c# in-app-purchase


    【解决方案1】:

    您可以将商店收据反序列化为这样的类:

    public class receipt
    {
        public string original_purchase_date_pst { get; set; }
        public string original_transaction_id { get; set; }
        public string original_purchase_date_ms { get; set; }
        public string transaction_id { get; set; }
        public string quantity { get; set; }
        public string product_id { get; set; }
        public string bvrs { get; set; }
        public string purchase_date_ms { get; set; }
        public string purchase_date { get; set; }
        public string original_purchase_date { get; set; }
        public string purchase_date_pst { get; set; }
        public string bid { get; set; }
        public string item_id { get; set; }
    }
    

    In-App Purchase Programming Guide 的this page 的商店收据部分中的表 5-1 逐个字段细分。希望对您有所帮助!

    【讨论】:

    • 这是旧版本的字段值(例如,“出价”不属于(按该名称)新收据格式的一部分。但对于仍发送/使用旧格式收据的应用程序来说,这仍然很方便(我们仍然有一些未触及的古老的......)新应用可能需要新的“统一收据”模式。
    • 谢谢你提醒我过去的自己。因为我现在正在更新有问题的古老应用程序。在这里可以找到描述可用 json 字段的文档可能一文不值:developer.apple.com/documentation/appstorereceipts/responsebody/…
    猜你喜欢
    • 2014-10-17
    • 2015-03-12
    • 2016-09-17
    • 2018-06-16
    • 2017-02-04
    • 1970-01-01
    • 2011-05-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多