Ben*_*ert 4 storekit in-app-purchase ios
来自StoreKit指南:
如果用户尝试购买他们已购买的非消费产品或可续订订购,则您的应用程序将收到该项目的常规交易,而不是恢复交易.但是,不会再向该用户收取该产品的费用.您的应用程序应将这些事务视为与原始事务的事务相同.
这在我正在开发的应用程序中提出了一个巨大的问题.我们已通过应用内购买向发布商许可了大量内容.他们要求我们每次出售这些内容(即用户向我们支付)时,我们的服务器会在其服务器上调用API来报告交易.这是出于会计目的,并且最终用于根据我们与他们的协议确定我们在月底支付的金额.
我已经在SO和其他地方阅读了几个关于调用restoreCompletedTransactions的建议,并且在设备上保持了用户已经购买的内容的本地理解,因此不允许他们再次购买它.这对我来说似乎应该能够在服务器端实现.但是,正如StoreKit指南所承诺的那样,我们从Apple服务器返回的收据与购买和重新购买的收据完全相同.
如果来自StoreKit的付款回调在这种情况下无法被信任为有效的会计机制("你得到了报酬"而不是"你没有得到报酬"),那么还有什么其他实时的交易流量见解?如果我们告诉他们我们必须在月底之后等待45天才能从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.
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.
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.
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.
| 归档时间: |
|
| 查看次数: |
3145 次 |
| 最近记录: |