我如何知道应用内购买收据是否来自沙盒? [英] How do I know if an in-app-purchase receipt comes from the sandbox?

查看:402
本文介绍了我如何知道应用内购买收据是否来自沙盒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS IAP文档状态,如果要测试商店,则应从设置应用程序中的itunes帐户注销。在进行应用内购买时,会要求您输入用户名和密码。但是,在应用程序内部,我不知道用户是否已登录或是否正在使用沙盒帐户。

The iOS IAP documentation states, that if you want to test a store you should log out from you itunes account in the settings application. When doing an in-app-purchase, you are then asked for username and password. However, inside the app, I don't know if the user is logged in or if he is using a sandbox account.

事实上,我并不在乎如果是沙盒交易,但是:在服务器上我必须通过URL验证真实收据 https:// buy.itunes.apple.com/verifyReceipt 和沙箱收据通过URL https:// sandbox。 itunes.apple.com/verifyReceipt 。如何在服务器上知道收据是沙盒收据还是真实收据?

In fact, I don't really care if it is a sandbox transaction, but: on the server I have to verify real receipts via the URL https://buy.itunes.apple.com/verifyReceipt and sandbox receipts via the URL https://sandbox.itunes.apple.com/verifyReceipt . How do I know on the server, if the receipt is a sandbox receipt or a real receipt?

或者应用程序如何知道收据是真实还是沙箱,因为将附加参数从应用程序传递到我的服务器没有问题。

Or how does the app know if the receipt is real or sandbox, because I have no problem with passing an additional parameter from the app to my server.

什么不起作用:你不能只说应用程序的DEBUG版本使用沙箱环境和应用程序的ADHOC或RELEASE版本使用生产环境。使用ADHOC版本,完全可以使用iTunes测试帐户进行应用内购买。

What does not work: You cannot just say that the DEBUG version of the app uses the sandbox environment and the ADHOC or RELEASE version of the app uses the production environment. With an ADHOC-version it is perfectly possible to use iTunes Test Accounts to do in-app-purchases.

推荐答案

验证时收据,如果您收到状态代码21007,则表示其是沙箱收据。请看这里: https://developer.apple.com/library/content/technotes/tn2413/_index.html#//apple_ref/doc/uid/DTS40016228-CH1-RECEIPTURL

When you verify the receipt, if you receive a status code 21007 it means its a sandbox receipt. Look here: https://developer.apple.com/library/content/technotes/tn2413/_index.html#//apple_ref/doc/uid/DTS40016228-CH1-RECEIPTURL


我应该使用哪个网址来验证我的收据?

请务必先使用生产网址验证收据;如果您收到21007状态代码,请继续使用沙箱URL进行验证。遵循此方法可确保您在沙盒中测试或查看应用程序时不必在URL之间切换,或者在App Store中进行实时更新。

What url should I use to verify my receipt?
Always verify your receipt first with the production URL; proceed to verify with the sandbox URL if you receive a 21007 status code. Following this approach ensures that you do not have to switch between URLs while your application is being tested or reviewed in the sandbox or is live in the App Store.

21007状态代码表示此收据是沙盒收据,但已发送到生产服务进行验证。状态为0表示收据已正确验证。请参阅 WWDC 2012:使用应用程序内购买管理订阅以获取更多信息信息。

The 21007 status code indicates that this receipt is a sandbox receipt, but it was sent to the production service for verification. A status of 0 indicates that the receipt was properly verified. See WWDC 2012: Managing Subscriptions with In-App Purchase for more information.

这篇关于我如何知道应用内购买收据是否来自沙盒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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