iOS 验证开发者的应用商店购买 ID [英] iOS verify app store purchase id by developer

查看:36
本文介绍了iOS 验证开发者的应用商店购买 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何查看用户从他的订单列表中发送给我的购买 ID?

How can I check purchase id which was sent by user to me from his orders list?

例如,他可以发送类似:M1VYXX7VX7(如他在应用商店的购买列表中所写)并要求退货(可能是他不小心删除了他的应用),

For example, he can send something like: M1VYXX7VX7 (as written in his purchases list in appstore) and ask to return his purchase (may be he had deleted his app accidentally),

但是当我在代码中获取订单信息时(通过 SKPaymentTransaction),我无法访问该标识符.那么只有我的 ID 看起来像:1000000020706713.

But when I get order information inside of my code (through SKPaymentTransaction) I have no access to that identifier. Then only ID i have looks like: 1000000020706713.

那么有什么方法可以使用应用商店发送给我的信息来验证购买 ID?

So is there any ways to validate that purchase ID using information which was sent to me by app store?

谢谢.

推荐答案

阅读应用程序内购买编程指南中的验证商店收据.根据文档:

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

To verify the receipt, perform the following steps:

  1. 检索收据数据.在 iOS 上,这是交易的 transactionReceipt 属性的值.在 OS X 上,这是应用程序包内收据文件的全部内容.使用 base64 编码对收据数据进行编码.

  1. Retrieve the receipt data. On iOS, this is the value of the transaction's transactionReceipt property. On OS X, this is the entire contents of the receipt file inside the application bundle. Encode the receipt data using base64 encoding.

使用名为receipt-data 的单个键和您在步骤1 中创建的字符串创建一个JSON 对象.您的JSON 代码应如下所示:

Create a JSON object with a single key named receipt-data and the string you created in step 1. Your JSON code should look like this:

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

  • 使用 HTTP POST 请求将 JSON 对象发布到 App Store.商店的 URL 是 https://buy.itunes.apple.com/verifyReceipt.

    从 App Store 收到的响应是一个 JSON 对象,有两个键,状态和收据.它应该看起来像这样:

    The response received from the App Store is a JSON object with two keys, status and receipt. It should look something like this:

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

  • 如果状态键的值为 0,则这是一个有效的收据.如果该值为 0 以外的任何值,则此收据无效.

    If the value of the status key is 0, this is a valid receipt. If the value is anything other than 0, this receipt is invalid.

    阅读文章了解更多详情.

    Read the article for more details.

    这篇关于iOS 验证开发者的应用商店购买 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆