这并不是一篇关于 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. 对PostgreSQL中tablespace 与 database, table的理解

    开始: 当前的tablesapce信息 pgsql=# select * from pg_tablespace; spcname | spcowner | spclocation | spcacl | ...

  2. Java中反射的三种常用方式

    Java中反射的三种常用方式 package com.xiaohao.test; public class Test{ public static void main(String[] args) t ...

  3. JAVA-开发环境搭建之JDK安装配置教程

    在进行java开发前先要搭建java的开发环境 下载java的开发环境eclipse 安装&配置环境变量 1,JDK安装

  4. AlertView with password

    1. setAlertViewStyle:UIAlertViewStyleSecureTextInput UIAlertView *alertView = [[UIAlertView alloc] i ...

  5. ABAP FIELD-SYMBOLS 有大作用- 将没有可改参数的增强出口变得也能改主程序的值了

    看下图代码: report  z_xul_test2 中 定义了 全局变量 G_DATA1 , 分别调用了 z_xul_tes1 中的 form  和 function zbapi_test , 这两 ...

  6. Python学习 之 OS模块

    1.目录操作 import os os.mkdir('abc')   #创建abc文件 tree a  #查看目录结构 2.目录遍历 方式一:递归 import os def dirList(path ...

  7. Naive Bayes Algorithm

    朴素贝叶斯的核心基础理论就是贝叶斯理论和条件独立性假设,在文本数据分析中应用比较成功.朴素贝叶斯分类器实现起来非常简单,虽然其性能经常会被支持向量机等技术超越,但有时也能发挥出惊人的效果.所以,在将朴 ...

  8. TortoiseGit安装教程

    TortoiseGit 是Windows下的可视化Git界面. 下载Git 网站地址: http://code.google.com/p/tortoisegit/ 安装前必须装上msysgit才能在W ...

  9. 安装Laravel遇到You must enable the openssl extension to download files via https问题

    刚看了一篇文章说了2014年最火的10个php框架,看到了Laravel,于是便自己试试,孰料刚安装便遇到了一个问题(由于一不小心关掉了cmd,此处无法截图显示),便是如文章标题中所说的那样,goog ...

  10. 如何优雅的实现界面跳转 之 统跳协议 - DarwinNativeRouter

    PS 感谢大家的关注,由于我本想开源4个库,除了router, 另外三个分别是native dispatcher, web dispatcher 和 react dispatcher , 所以rout ...