如何从用户的订单列表中查看用户发送给我的购买 ID?
例如,他可以发送如下内容:M1VYXX7VX7(如他在应用商店的购买列表中所写)并要求退回他的购买(可能是他不小心删除了他的应用),
但是当我在代码中获取订单信息时(通过 SKPaymentTransaction
),我无法访问该标识符。然后我只有 ID 看起来像:1000000020706713。
那么有什么方法可以使用应用商店发送给我的信息来验证购买 ID 吗?
谢谢。
最佳答案
阅读Verifying Store Receipts在应用程序内购买编程指南中。根据文档:
To verify the receipt, perform the following steps:
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.
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)" }
Post the JSON object to the App Store using an HTTP POST request. The URL for the store is https://buy.itunes.apple.com/verifyReceipt.
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) } }
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.
阅读文章了解更多详情。
关于iOS 验证开发者的应用商店购买 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17695901/