如何在您的服务器上验证 ios 应用内购买 [英] How to verify ios In-App Purchase on your server

查看:32
本文介绍了如何在您的服务器上验证 ios 应用内购买的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我准备构建我的第一个应用内购买应用.我想知道是否有一种方法可以在您的服务器上验证购买.

I am up to build my first in-app purchase app. I would like to know whether there is a way to verify purchase on your server.

我必须建立整个用户管理,我想为所有注册用户知道他们已经在他们的 iOS 设备上购买了什么,以便他们免费获得网络应用程序,或者类似的东西.那么,有没有办法让我在苹果商店端查看该用户是否已经购买了一些产品?

I have to build the whole user management, and I would like to know for all registered user what they already bought on their iOS devices, so that they get web app for free, or something like that. So, is there a way for me to check on Apple store side, if this user has already buy some product?

场景是这样的:

用户 A 在移动设备上购买应用 B.在此之后,我想检查我的服务器(在我的网页上,...)是否用户 A 购买了应用 B,或者(类似)用户 A 购买了哪个应用.

User A buy app B on mobile device. After this I would like to check on my server (on my web page,...) if user A is bought app B, or (similar) which app was bought by user A.

我不想从移动设备向我的服务器发送用户 A 购买应用 B 的消息,因为即使用户没有购买应用 B,他们也可以在服务器上重现此调用.

I don't want to send message from mobile device to my server that user A buy app B, because users can reproduce this call on server even if they didn't buy app B.

如果用户 A 购买了应用 B,我会在服务器端的应用商店中查看.

I would check on server side whit app Store if user A bought app B.

推荐答案

获取应用的收据(从位于 [[NSBundle mainBundle] appStoreReceiptURL] 的文件)并将其发送到您的服务器.那么要么……

Fetch the app's receipt (from the file at [[NSBundle mainBundle] appStoreReceiptURL]) and send it to your server. Then either…

  • 解析收据并根据 Apple 的证书检查其签名如所述此处(在您的服务器上,而不是在应用程序中).或者,

  • Parse the receipt and check its signature against Apple's certificate as described here (on your server, not in the app). Or,

将收据(再次从您的服务器)发送到应用商店进行验证 如此处所述.

Send the receipt (again, from your server) to the app store for validation as described here.

这篇关于如何在您的服务器上验证 ios 应用内购买的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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