iOS verify app store purchase id by developer

匿名 (未验证) 提交于 2019-12-03 08:54:24

问题:

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

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),

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.

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

Thanks.

回答1:

Read Verifying Store Receipts in the In-App Purchase Programming Guide. According to the documentation:

To verify the receipt, perform the following steps:

  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.

  2. 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)" } 
  3. 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.

  4. 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.

Read the article for more details.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!