这并不是一篇关于 In-App-Purcharse 的专业深入分析文章,只是在初次浏览有关IAP官方文档后记录的一些需要注意的地方,就像是课堂笔记。

因为这是原版、并且涉及到支付的内容,所以就不翻译,以免引起歧义,原文会让你更准确的理解文档。

如果各神有更多的踩坑经验,欢迎 回复、分享~

后续我自己的 踩坑经验 和 深入体会 也会继续更新

作为一个专业围观者、为了刷刷访问量、为了提高曝光率。。。。。转载请注明出处:http://www.cnblogs.com/zhuocheng/p/3512740.html

Good luck for you & your customer ~~

Updated by Zhuocheng Lee - 2014.1.9


购买信息标识:

To provide this information, populate the applicationUsername property of the payment object with a one-way hash of the user’s account name on your server
only in iOS 7 !!


结束购买:

Finishing a transaction tells Store Kit that you’ve completed everything needed for the purchase. Unfinished transactions remain in the queue until they’re finished, and the transaction queue observer is called every time your app is launched so your app can finish the transactions.
Complete all of the following actions before you finish the transaction:
Persist the purchase.
Download associated content.

Update your app’s UI to let the user access the product.


不要这样:

Don’t try to call the finishTransaction: method before the transaction is actually completed, attempting to use some other mechanism in your app to track the transaction as unfinished. Store Kit isn’t designed to be used this way. Doing so prevents your app from downloading Apple-hosted content and can lead to other issues.

After you finish a transaction, don’t take any actions on that transaction or do any work to deliver the product. If any work remains, your app isn’t ready to finish the transaction yet.


订阅时间的计算:

Don’t calculate the subscription period by adding a subscription duration to the purchase date. This approach fails to take into account the free trial period, the marketing opt-in period, and the content made available immediately after the user purchased the subscription.


自动续订的策略:

The App Store renews the subscription slightly before it expires, to prevent any lapse in the subscription. However, lapses are still possible. For example, if the user’s payment information is no longer valid, the first renewal attempt would fail. If the user doesn’t update this information until after the subscription expires, there would be a short lapse in the subscription between the expiration date and the date that a subsequent automatic renewal succeeds. The user can also disable automatic renewal and intentionally let the subscription expire, then renew it at a later date, creating a longer lapse in the subscription. Make sure your app’s subscription logic can handle lapses of various durations correctly.

After a subscription is successfully renewed, Store Kit adds a transaction for the renewal to the transaction queue. Your app checks the transaction queue on launch and handles the renewal the same way as any other transaction. Note that if your app is already running when the subscription renews, the transaction observer is not called; your app finds out about the renewal the next time it’s launched.


取消订阅:

To check whether a purchase has been canceled, look for the Cancellation Date field in the receipt. If the field has a date in it, regardless of the subscription’s expiration date, the purchase has been canceled—treat a canceled receipt the same as if no purchase had ever been made.

Depending on the type of product, you may be able to check only the currently active subscription, or you may need to check all past subscriptions. For example, a magazine app would need to check all past subscriptions to determine which issues the user had access to.


多平台购买:

Product identifiers are associated with a single app. Apps that have both an iOS and OS X version have separate products with separate product identifiers on each platform. You could let users who have a subscription in an iOS app access the content from an OS X app (or vice versa), but implementing that functionality is your responsibility. You would need some system for identifying users and keeping track of what content they’ve subscribed to, similar to what you would implement for an app that uses non-renewable subscriptions.


自动续订测试:
For the sake of testing, there are some differences in behavior between auto-renewable subscriptions in the production environment and in the test environment.
Renewal happens at an accelerated rate, and auto-renewable subscriptions renew a maximum of six times per day. This lets you test how your app handles a subscription renewal, a subscription lapse, and a subscription history that includes gaps.
Because of the accelerated expiration and renewal rate, the subscription can expire before the system starts trying to renew the subscription, leaving a small lapse in the subscription period. Such lapses are also possible in production for a variety of reasons—make sure your app handles them correctly.


恢复购买验证:

Restoring purchases prompts for the user’s App Store credentials, which interrupts the flow of your app: because of this, don’t automatically restore purchases, especially not every time your app is launched.


恢复receipt:

in iOS 7, use initWithReceiptProperties: method of SKReceiptRefreshRequest.

if you need to support versions of iOS earlier than iOS 7, where the app receipt isn’t available, restore completed transactions instead.

restore:

in iOS 7,If your app sets a value for the applicationUsername property of its payment requests, as described in “Detecting Irregular Activity,” use therestoreCompletedTransactionsWithApplicationUsername: method to provide the same information when restoring transactions.


初次提交商品:

The first time you submit your app for review, you also need to submit in-app products to be reviewed at the same time. After the first submission, you can submit updates to your app and products for review independently of each other.


提交测试:

When validating receipts on your server, your server needs to be able to handle a production-signed app getting its receipts from Apple’s test environment. The recommended approach is for your production server to always validate receipts against the production App Store first. If validation fails with the error code “Sandbox receipt used in production”, validate against the test environment instead.


验证receipt:

Perform receipt validation immediately after your app is launched, before displaying any user interface or spawning any child processes. Implement this check in the main function, before the NSApplicationMain function is called. For additional security, you may repeat this check periodically while your application is running.


receipt的验证响应:

The receipt field on the JSON object holds the parsed information from the receipt. The receipt data for an auto-renewable subscription includes some additional keys, and some other keys are used differently for subscriptions. For information about keys found in a receipt, see “Receipt Fields.”
In addition to the receipt field, the response may also include two other fields. If the user’s subscription is active and was renewed by a transaction that took place after the receipt your server sent to the App Store, the latest_receipt field includes a base-64 encoded receipt for the last renewal for this subscription. The decoded data for this new receipt is also provided in the latest_expired_receipt_info field. Your server can use this new receipt to maintain a record of the most recent renewal.


几个关键的receipt验证响应字段:

Receipt Expiration Date
The date that the app receipt expires.
ASN.1 Field Type 21
ASN.1 Field Value IA5STRING, interpreted as an RFC 3339 date
JSON Field Name expiration_date
JSON Field Value IA5STRING, interpreted as an RFC 3339 date
This key is present only for apps purchased through the Volume Purchase Program. If this key is not present, the receipt does not expire.
When validating a receipt, compare this date to the current date to determine whether the receipt is expired. Do not try to use this date to calculate any other information, such as the time remaining before expiration.

Original Transaction Identifier
For a transaction that restores a previous transaction, the transaction identifier of the original transaction. Otherwise, identical to the transaction identifier.
ASN.1 Field Type 1705
ASN.1 Field Value UTF8STRING
JSON Field Name original_transaction_id
JSON Field Value string
This value corresponds to the original transaction’s transactionIdentifier property.
All receipts in a chain of renewals for an auto-renewable subscription have the same value for this field.

Purchase Date
The date and time that the item was purchased.
ASN.1 Field Type 1704
ASN.1 Field Value IA5STRING, interpreted as an RFC 3339 date
JSON Field Name purchase_date
JSON Field Value string, interpreted as an RFC 3339 date
This value corresponds to the transaction’s transactionDate property.
For a transaction that restores a previous transaction, the purchase date is the date of the restoration. Use “Original Purchase Date” to get the date of the original transaction.
In an auto-renewable subscription receipt, this is always the date when the subscription was purchased or renewed, regardless of whether the transaction has been restored.

Original Purchase Date
For a transaction that restores a previous transaction, the date of the original transaction.
ASN.1 Field Type 1706
ASN.1 Field Value IA5STRING, interpreted as an RFC 3339 date
JSON Field Name original_purchase_date
JSON Field Value string, interpreted as an RFC 3339 date
This value corresponds to the original transaction’s transactionDate property.
In an auto-renewable subscription receipt, this indicates the beginning of the subscription period, even if the subscription has been renewed.

Subscription Expiration Date
The expiration date for the subscription, expressed as the number of milliseconds since January 1, 1970, 00:00:00 GMT.
ASN.1 Field Type 1708
ASN.1 Field Value IA5STRING, interpreted as an RFC 3339 date
JSON Field Name expires_date
JSON Field Value number
This key is only present for auto-renewable subscription receipts.



add by Zhuocheng Lee

Good luck for you & your customer ~~

2014.1.9

In-App-Purcharse 官方原文摘要笔记的更多相关文章

  1. jQuery官方基础教程笔记(转载)

    本文转载于阮一峰的博文,内容基础,结构清晰,是jquery入门不可多得的资料,非常好,赞一个. 阮一峰:jQuery官方基础教程笔记 jQuery是目前使用最广泛的javascript函数库. 据统计 ...

  2. 【音乐App】—— Vue-music 项目学习笔记:播放器内置组件开发(二)

    前言:以下内容均为学习慕课网高级实战课程的实践爬坑笔记. 项目github地址:https://github.com/66Web/ljq_vue_music,欢迎Star. 播放模式切换 歌词滚动显示 ...

  3. 阮一峰:jQuery官方基础教程笔记

    jQuery是目前使用最广泛的javascript函数库. 据统计,全世界排名前100万的网站,有46%使用jQuery,远远超过其他库.微软公司甚至把jQuery作为他们的官方库. 对于网页开发者来 ...

  4. APP store 官方统计工具的常见的Q&A

    Apple最近在iTunesConnect里最新发布了官方统计工具,提供了现有友盟统计平台和自有统计平台无法统计的数据,具有自己的独有特点,尤其是下面几个最让人头疼的流量分析转化,可以在App Ana ...

  5. iOS原生App与H5页面交互笔记

    文/MikeZhangpy(简书作者)原文链接:http://www.jianshu.com/p/4ed3e5ed99c6著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”. 最近在做一个项 ...

  6. 【音乐App】—— Vue-music 项目学习笔记:歌单及排行榜开发

    前言:以下内容均为学习慕课网高级实战课程的实践爬坑笔记. 项目github地址:https://github.com/66Web/ljq_vue_music,欢迎Star. 歌单及详情页 排行榜及详情 ...

  7. 【音乐App】—— Vue-music 项目学习笔记:歌手详情页开发

    前言:以下内容均为学习慕课网高级实战课程的实践爬坑笔记. 项目github地址:https://github.com/66Web/ljq_vue_music,欢迎Star. 歌曲列表 歌曲播放 一.子 ...

  8. 【音乐App】—— Vue-music 项目学习笔记:推荐页面开发

    前言:以下内容均为学习慕课网高级实战课程的实践爬坑笔记. 上一篇总结了项目概述.项目准备.页面骨架搭建.这一篇重点梳理推荐页面开发.项目github地址:https://github.com/66We ...

  9. APP测试关注的点 - 笔记

    来源公开课笔记!!! 1.黑盒测试 是否正确并如设计的一样正常运行.测试自动化回归测试 2.测试主要关注参数: CPU.内存.耗电量.流量.FRS(流畅度).同时关注APP安装耗时和启动耗时 3.适配 ...

随机推荐

  1. Asp.net MVC @Html.DisplayNameFor中文乱码解决办法

    这是utf8的问题,vs2015默设要用utf8编码,以前的gb2312皆会产生乱码 这问题还是会继续发生,因为常会复制旧程序档进新方案.它会出现很奇怪的错误,而不是这么明显的乱码,你怎么抓bug都抓 ...

  2. 将Java程序作成exe文件的几种方法【转载】

    看到网上有同志的介绍将Java程序作成exe文件的方法,写的不错,但是也许是这篇文章完成的时间比较早,许多内容已经不合适了.我在这里补充几条: 一.exe4j 说明:exe4j可以将Jar文件制作成e ...

  3. Codeforces Round #326 (Div. 2) A. Duff and Meat 水题

    A. Duff and Meat Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/588/probl ...

  4. 【转】Linux下(C/C++)使用system()函数一定要谨慎

    转自:http://my.oschina.net/renhc/blog/53580   曾经的曾经,被system()函数折磨过,之所以这样,是因为对system()函数了解不够深入.只是简单的知道用 ...

  5. S5PV210开发系列四_uCGUI的移植

    S5PV210开发系列四 uCGUI的移植 象棋小子          1048272975 GUI(图形用户界面)极大地方便了非专业用户的使用,用户无需记忆大量的命令,取而代之的是能够通过窗体.菜单 ...

  6. spring mvc --自己定义converse

    在MVC中我们能够非常轻松的依据项目需求进行必要的信息转换,如设置默认的日期格式,自己定义String类型的格式等等... 配置中我们须要自己定义converseService: <bean i ...

  7. [Angular 2] *ngFor

    heros.ts: import {Component} from "@angular/core"; const HEROES = [ {id: 1, name:'Superman ...

  8. 阅读uboot

    下面是一个执行make XXX_config后的打印信息: pengdl@debian:~/work/costdown/new/Hi3520D_SDK_V1.0.2.2c/source/arm11/u ...

  9. 中兴电信光纤猫F612管理员密码获取方法

    1.telnet 192.168.1.1 账号:root 密码:Zte521 2.输入命令: sendcmd 1 DB p DevAuthInfo 得到管理员账号密码如下: <DM name=& ...

  10. PHP.4-DIV+CSS标准网页布局准备工作(下)

    DIV+CSS标准网页布局准备工作 区块属性(区块模型) 属 性 描 述 Margin(注) 是定义区块外边界与上级元素距离的属性,用1到4个值来设置元素的边界,每个值都是长度.百分比或者auto,百 ...