如果我的服务器失败并且无法提供内容,如何取消应用程序内购买? (IOS) [英] How To Cancel In-App-Purchase If My Server Fails and Cannot Provide Content? (iOS)

查看:103
本文介绍了如果我的服务器失败并且无法提供内容,如何取消应用程序内购买? (IOS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在iOS上的应用程序购买中实现,我的服务器将在用户购买项目时提供对某些内容的访问。我已经完成了所有工作,包括让服务器在提供对内容的访问权限之前验证购买的收据。

I am implementing in app purchase on iOS, where my server will provide access to certain content when the user purchases an item. I have everything working, including having the server able to verify the receipt from the purchase before providing access to the content.

但是,如果由于某种原因,该应用程序无法向我的服务器注册该交易(例如,由于服务器中断),我想取消该交易使用户不会被iTunes收费。 这可能吗?

However, if for some reason the app is not able to register the transaction with my server (due to a server outage, for example), I'd like to cancel the transaction so that the user isn't charged by iTunes. Is this possible?

要进一步详细说明,应用程序会在 paymentQueue:updatedTransactions <中联系我的服务器/ code>用户点击购买后的功能。目前,我致电:

To explain in further detail, the app contacts my server from within the paymentQueue:updatedTransactions function after the user clicks "buy." Currently, I call:

[_myQueue finishTransaction:transaction];

。但是,如果联系服务器时出错,是否有一个函数我可以调用取消事务而不是完成它?

after contacting my server. However, if there was an error in contacting the server, is there a function I can call to cancel the transaction instead of finishing it?

我从 finishTransaction ,这样交易就会在下次恢复时恢复 - 但不能完成用户启动应用程序并添加事务观察器(因此应用程序可以尝试再次联系服务器)但是,这不太理想,因为用户在重新启动应用程序并且服务器可用之前将无法访问内容再次,但用户已经付款了。

I see from here that some people just don't call finishTransaction, so that the transaction gets restored the next time the user starts the app and the transaction observer is added (so the app can try to contact the server again) However, this is less than ideal because the user won't have access to the content until they restart the app and the server is available again, and yet the user will have already paid.

谢谢!

推荐答案

我认为唯一优雅的方式来实现这是为了让您的服务器实现可用性检查,并在实际购买之前将其称为最后一件事。一旦用户通过呈现给他的UIAlertView确认购买,就会进行购买,并且您必须尽一切努力使他获得他的钱。

I think the only elegant way to achieve this is to have your server implement an availability check and call it as the last thing before you actually make the purchase. Once the user has confirmed the purchase via the UIAlertView that is presented to him, the purchase is made and you must do all that you can so that he gets his money's worth.

这篇关于如果我的服务器失败并且无法提供内容,如何取消应用程序内购买? (IOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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