简体   繁体   English

是否可以在没有 UI/应用程序开销的情况下以编程方式创建测试收据?

[英]Is it possible to create test receipts programmatically without an UI/app overhead?

We own backend services that react to the receipts generated after making in-app purchases (specifically subscriptions).我们拥有对应用内购买(特别是订阅)后生成的收据做出反应的后端服务。 Right now we are using few pre-generated test receipts for validating changes in our services.现在,我们很少使用预先生成的测试收据来验证我们服务中的更改。

But using these pre-generated receipts (generated using sandbox environment) restricts automation of tests as the products associated with these receipts renew/cancel/expire when we run these tests over a period of time.但是使用这些预先生成的收据(使用沙箱环境生成)会限制测试的自动化,因为当我们在一段时间内运行这些测试时,与这些收据相关的产品会更新/取消/过期。 Looking at the apple documentation, I couldn't find any such APIs.查看苹果文档,我找不到任何此类 API。 So, is there a way I could generate these test receipts dynamically for my tests (without using UI, of course)?那么,有没有一种方法可以为我的测试动态生成这些测试收据(当然,不使用 UI)?

If you want to create receipt data that Apple's endpoint will validate, that would be very difficult because it is a signed secure container generated by StoreKit.如果您想创建 Apple 端点将验证的收据数据,那将非常困难,因为它是由 StoreKit 生成的签名安全容器。 This WWDC talk goes into depth on what the receipt actually is.这个WWDC 演讲深入探讨了收据实际上是什么。

The validation isn't all the important since it is outside of your system.验证并不重要,因为它在您的系统之外。 You can mock the Apple verifyReceipt call and write a little script to just generate fake receipt responses (the JSON) that match what you expect receipts to look like.您可以模拟 Apple verifyReceipt调用并编写一个verifyReceipt生成与您期望的收据相匹配的假收据响应(JSON)。 This is what we do in our unit and functional tests at RevenueCat .这就是我们在RevenueCat 的单元和功能测试中所做的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM