区分初始购买和免费“重新购买”。在StoreKit /应用程序内购买 [英] Differentiating between initial buy and free "re-buy" in StoreKit/In-App Purchase

查看:121
本文介绍了区分初始购买和免费“重新购买”。在StoreKit /应用程序内购买的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自StoreKit指南:

From the StoreKit guide:

如果用户尝试购买他们已购买的非消费产品或可续订订阅,您的应用程序将收到常规交易对于该项目,而不是还原事务。但是,该产品不会再次向用户收费。您的应用程序应该将这些交易视为与原始交易的交易相同。

这在我正在处理的应用程序中存在一个巨大的问题。我们已通过应用内购买向发布商许可了大量内容。他们要求我们每次出售这些内容(即用户向我们支付)时,我们的服务器会在其服务器上调用API来报告交易。这是出于会计目的,最终用于根据我们与他们的协议确定我们在月底支付的金额。

This presents a huge problem in an app I am working on. We have licensed a large body of content from a publisher for sale through in-app purchase. They require that every time we sell a piece of this content (i.e. user pays us), our server calls an API on their servers to report the transaction. This is for accounting purposes and ultimately used to determine how much we pay them at the end of the month, per our agreement with them.

我已经阅读了几条关于SO的建议和其他地方相关地经常调用restoreCompletedTransactions并在设备上保持用户已经购买的内容的本地理解,因此不允许他们再次购买它。这对我来说似乎应该能够在服务器端实现。但是,正如StoreKit指南所承诺的那样,我们从Apple服务器返回的收据与购买和重新购买的收据完全相同。

I have read several suggestions on SO and elsewhere about calling restoreCompletedTransactions rather frequently and maintaining a local understanding, on the device, of what the user has already purchased so they cannot be allowed to purchase it again. This to me seems like something that should be able to be implemented on the server side. However, the receipts that we are getting back from the Apple servers are exactly the same for a buy and a re-buy, as promised by the StoreKit guide.

如果付款在这种情况下,来自StoreKit的回调不能被视为有效的会计机制(你得到了报酬而不是你没有得到报酬),还有什么其他实时的交易流量见解?如果我们告诉他们我们必须在月底之后等待45天才能从iTunes Connect中获得真正支付的美元金额,我认为我们正在合作的出版商会很高兴。

If payment callbacks from StoreKit cannot be trusted as a valid accounting mechanism in this kind of situation ("you got paid" vs. "you didn't get paid"), what other real-time insights into transaction traffic are available? I don't think the publisher we are working with is going to be happy if we tell them we have to wait 45 days after the end of the month to get the REAL paid dollar amount out of iTunes Connect.

推荐答案

我最近遇到了同样的问题。就我而言,我希望使用移动应用跟踪实现准确的收入跟踪,以跟踪不同客户获取活动产生的收入。

I have recently looked into the same problem. In my case, I wanted to implement accurate revenue tracking using Mobile App Tracking to track revenue generated from different customer acquisition campaigns.

幸运的是,有办法做到这一点。应该注意的是, SKPaymentTransactionStatePurchased SKPaymentTransactionStateRestored 完全取决于发起动作,例如:无论你是开始恢复还是(重新)购买,所以这不起作用。

Fortunately enough, there is a way to do it. It should be noted that SKPaymentTransactionStatePurchased vs. SKPaymentTransactionStateRestored solely depends on the initating action, e.g. whether you initiated a restore or a (re-)purchase, so that doesn't work.

相反,工作是检查 SKPaymentTransaction。 originalTransaction 这将是!= nil ,用于恢复重新购买。后者遗憾的是未定义的行为( docs )。我会考虑公平无效。

What does work instead is checking for SKPaymentTransaction.originalTransaction which will be != nil for restores and re-purchases. The latter is unfortunately undefined behavior (docs). I'd consider a null check fair enough though.

另一种选择是使用 SKPaymentTransactionStatePurchased 验证交易的交易收据,并检查 original_transaction_id 属性与 transaction_id 匹配。

Another option is to validate the transaction-receipt of transactions with SKPaymentTransactionStatePurchased and check that the original_transaction_id property in the returned, validated receipt matches the transaction_id.

这篇关于区分初始购买和免费“重新购买”。在StoreKit /应用程序内购买的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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