xcode - macOS In-App Purchase in sandbox environment not authorised
问题描述
I'm trying to get In-App Purchases (IAPs) working in a macOS app using the same Swift code, sandbox testers, and iTunes Connect account that I used for my iOS app. However, I can't get it to work. I'm using macOS High Sierra 10.13.6.
Open app
Apple's IAP testing recommendations are found here:
On a development macOS device, sign out of the Mac App Store. Then build your app in Xcode and launch it from the Finder.
If the text “[Environment: Sandbox]” doesn’t appear, you’re using the production environment. Make sure you’re running a development-signed build of your app. Production-signed builds use the production environment.
I have followed these steps by signing out of the Mac App Store, and building my app – signed for development – then launching it from the Finder. This means I don't get debug logs, unfortunately.
Navigate to table of products in-app
Here's my table of products:
I can buy a product by pressing the "Free" button or the "£4.99" button.
Attempt to buy product by pressing "Free"
After a short wait, brings up this popup saying 'Sign-in required'. I sign in using one of my sandbox testers (note: I have tried five different test accounts now, all of which worked on an iOS app under the same iTunes Connect account), registered with email addresses that aren't Apple IDs:
Having selected 'Buy', a short wait after that, this next popup appears:
After selecting 'Cancel' (as recommended here), after a short wait, the next popup appears:
You are not authorized to make purchases of this InApp in Sandbox at this time.
[Environment: Sandbox]
So I'm not sure whether it logged me in or not, and I assume that my purchase has failed (my table UI doesn't update to say 'purchased'). Note that I have also tried pressing 'Change Store' here, and it still fails ultimately.
Attempt to buy product by pressing "Free" again
This time, I'm not prompted to log in; I'm instead asked immediately whether I'd like to purchase the product. I click 'Confirm'.
However, now the purchase transaction never completes:
What might I be doing wrong? Do I need to log out of anything (e.g. iCloud) in Settings > Internet Accounts
too?
解决方案
看起来很蹩脚,但我最终通过创建新的沙盒测试帐户解决了这个问题(提示:这一次,我将它们配置为基于美国,以避免在支付流程中切换商店的复杂性)。
我认为问题在于我没有验证我一直在使用的沙盒测试员帐户。这可能是因为 Apple 要求我验证/激活沙盒测试员帐户的电子邮件被分类到我的垃圾邮件中并且完全错过了,或者因为当我点击他们电子邮件中的链接时他们的后端出现了问题(我经历了这两种行为)。
推荐阅读
- javascript - 如何使用 API 从谷歌云平台读取文本文件
- java - 我正在尝试使用以下代码获取客户数据,它总是返回 null
- python - 在 conda 环境中使用 pip,是否仅在该 conda 环境中安装包?
- c# - 使用只有一个类型参数 C# 的泛型接口调用泛型方法
- r - 用相等的索引替换数字元素
- javascript - 弹出信息以在 Squarespace 中分享 FB 上的帖子
- java - 当执行需要很长时间时,nanoTime() 显示的差异太小
- isabelle - Isabelle/HOL 中的灵活/模糊规则应用
- c# - 试图抓取 facebook messenger 聊天,尤其是。facebook Messenger 群聊
- docker - 来自守护进程的错误响应:此操作系统上的守护进程不支持导出 Windows 容器