【问题标题】:how to setup test and production environment for apple iap server-to-server notification如何为苹果 iap 服务器到服务器通知设置测试和生产环境
【发布时间】:2020-03-30 01:13:12
【问题描述】:
我希望苹果在应用发布后将真实用户的购买通知发送到我的生产环境。
同时,我需要苹果将沙盒测试账户的购买通知发送到我的测试环境。
但是,我只能在苹果连接中从苹果 iap 服务器到服务器通知中配置一个 URL。
我尝试在我的生产环境中接收通知,并解析通知的有效负载,如果是沙箱通知,则将其传递到测试环境。但我认为这不是一个好方法,因为我的测试环境依赖于我的生产环境。
我该如何解决这个问题?
【问题讨论】:
标签:
ios
testing
in-app-purchase
app-store
subscription
【解决方案1】:
App Store 不提供不同环境的 URL。你必须用自己的单台服务器检查从App Store接收到的消息的环境字段,区分是用于测试还是生产,然后将其发送回各个服务器。
引用自 Apple 文档:
If you enabled App Store server notifications for your app, test your logic for
transactions in the sandbox environment. To determine if a notification for a
subscription event occurred in the test environment, check whether the value of
the environment field in the server-to-server JSON responseBody object equals
Sandbox.