鍍金池/ 教程/ iOS/ 如何測試應(yīng)用程序內(nèi)置購買
恢復購買記錄
內(nèi)置購買
介紹
準備應(yīng)用程序?qū)彶?/span>
創(chuàng)建和配置產(chǎn)品
獲取產(chǎn)品信息
支付請求
使用訂閱
如何測試應(yīng)用程序內(nèi)置購買
產(chǎn)品交付

如何測試應(yīng)用程序內(nèi)置購買

In-App Purchase allows you to sell additional features and functionality from within your iOS and OS X applications. If you wish to offer In-App Purchase in your applications, you must complete several steps before you can do it. This document provides step-by-step instructions for setting up and testing In-App Purchase. It also answers common questions about In-App Purchase. The "Contracts, Tax, and Banking Information" section describes all the financial documents that must be completed. The "Member Center" and "iTunes Connect" sections indicate the steps to be respectively done in the Member Center and iTunes Connect. The "What's Next" section shows how to test In-App Purchase.

內(nèi)置購買讓你從 iOS 和 OS X應(yīng)用內(nèi)部銷售更多的特性和功能。 如果你想在應(yīng)用程序里提供內(nèi)置購買,你必須完成以下步驟。 本文一步一步介紹配置和測試內(nèi)置購買,以及回答內(nèi)置購買的常見問題。 “Contracts, Tax, and Banking Information”一節(jié)描述了所有必須完成的財務(wù)文件。在 “Member Center”和 “iTunes Connect”部分講述了需要在 Member Center 和 iTunes Connect 里需要完成的步驟?!癢hat's Next”一節(jié)演示如何測試應(yīng)用程序內(nèi)置購買。

This document does not cover how to implement In-App Purchase in your applications. Read the In-App Purchase Programming Guide for detailed information about implementing In-App Purchase in your applications.

本文沒有覆蓋如何在你的應(yīng)用程序中實現(xiàn)內(nèi)置購買。閱讀 In-App Purchase Programming Guide 來了解在應(yīng)用程序中實現(xiàn)內(nèi)置購買的詳細情況。

Note: In-App Purchase is available in iOS 3.0 and later and OS X 10.7 and later.

注意:內(nèi)置購買僅在 iOS 3.0 及以后版本,OS X 10.7 及以后版本中有效。

Contracts, Tax, and Banking Information Member Center iTunes Connect Frequently Asked Questions References Document Revision History

Contracts, Tax, and Banking Information

一、合同,稅以及銀行信息

You must complete the following steps before you can support In-App Purchase in your applications:

你必須在應(yīng)用程序中支持內(nèi)置購買之前完成以下步驟:

1.Agree to the latest Developer Program License Agreement.

同意最新的開發(fā)者計劃許可協(xié)議。

Your Team agent must agree to the latest iOS Developer Program License Agreement (iOS) or to the latest Mac Developer Program License Agreement (OS X) in the Member Center before you are allowed to create In-App Purchase products.

在允許你創(chuàng)建內(nèi)置購買產(chǎn)品之前,你的團隊必須同意Member Center中的最新的iOS開發(fā)者計劃許可協(xié)議 (iOS) 或者同意最新的 Mac 開發(fā)者計劃許可協(xié)議 (OS X)。

2.Complete your contract, tax, and banking Information.

完成你的合同,稅以及銀行信息。

You must have an iOS Paid Applications contract (iOS) or a Mac OS X Paid Applications contract (OS X) in effect with Apple and have provided your tax and banking information in iTunes Connect as seen in Figure 1.

你必須有一個與蘋果相關(guān)的有效iOS 支付應(yīng)用合同 (iOS) 或一個 Mac OS X 支付應(yīng)用合同 (OS X),并且已經(jīng)在 iTunes Connect 中提供了你的稅以及銀行信息,如下圖:

Figure 1 Contract section in iTunes Connect

http://wiki.jikexueyuan.com/project/in-app-purchase/images/12.png" alt="" />

Member Center

二、 Member Center

The Member Center is used to configure your App ID and Provisioning Profiles for In-App Purchase. OS X and iOS developers must complete the following steps in theMember Center :

會員中心用來配置你的 App ID 以及內(nèi)置購買的配置信息(Provisioning Profiles). OS X 和 iOS 開發(fā)者必須在 Member Center 中完成以下步驟:

1.Register an explicit App ID for your application.

為你的應(yīng)用程序注冊一個 explicit App ID.

Explicit App IDs are App IDs whose Bundle Identifier portion is a string without the wildcard ("") character. Furthermore, they are automatically registered for In-App Purchase and Game Center as shown in Figure 2. Using an explicit App ID ensures that your In-App Purchase products are only associated with your application. For example, use com.example.MyGreatApplication rather than com.example..

Explicit App ID 的捆綁標識符 (Bundle Identifier)部分是由不包含通配符""的字符串組成的App ID。此外,它們會自動開啟內(nèi)置購買 (In App Purchase)和游戲中心 (Game Center),如圖2。 使用一個 explicit App ID確保你的內(nèi)置購買只跟你的應(yīng)用程序相關(guān)聯(lián)。 舉個例子,使用 com.example.MyGreatApplication 而不是 com.example..

Your Team Agent or Team Admin should navigate to the App IDs section of the Member Center to create App IDs for your applications. Read Registering App IDs in the App Distribution Guide to find out how to create App IDs.

你的團隊代理人或團隊管理者應(yīng)該到 Member Center的 App IDs 區(qū)為你的應(yīng)用程序創(chuàng)建 App IDs。請閱讀 App Distribution Guide的 Registering App IDs 來找出如何創(chuàng)建 App ID。

Figure 2 Explicit App ID

http://wiki.jikexueyuan.com/project/in-app-purchase/images/13.png" alt="" />

1.Certificates and Provisioning Profiles.

證書和配置信息

iOS 開發(fā)者必須用他們的 App ID 創(chuàng)建,下載和安裝一個新的 Development Provisioning Profile,用來開啟內(nèi)置購買,如圖3. 閱讀 App Distribution Guide 中的 Creating Provisioning Profiles Using Member CenterRefreshing Provisioning Profiles in Xcode 來學習如何創(chuàng)建和安裝配置信息。

  • OS X developers must create, download, and install a Mac Development Certificate that uses their App ID enabled for In-App Purchase. Read Requesting Signing Identities in the App Distribution Guide to learn how to create a Mac Development certificate.

OS X 開發(fā)者必須用他們的 App ID 創(chuàng)建,下載和安裝一個新 Development Provisioning Profile,用來開啟內(nèi)置購買。閱讀 App Distribution Guide 中的 Requesting Signing Identities 來學習如何創(chuàng)建一個 Mac 開發(fā)證書。

Figure 3 Provisioning Profile

http://wiki.jikexueyuan.com/project/in-app-purchase/images/14.png" alt="" />

iTunes Connect

三、iTunes Connect

To test In-App Purchase, you need to create products to purchase and test accounts to make the purchases. iTunes Connect allows you to create and manage In-App Purchase products and Test User accounts. Both iOS developers and OS X developers must complete the following steps in iTunes Connect:

要想測試內(nèi)置購買,你需要創(chuàng)建能購買的產(chǎn)品和測試賬號。 iTunes Connect 里可以創(chuàng)建并管理內(nèi)置購買產(chǎn)品和測試用戶賬號。 iOS 和 OS X 開發(fā)者必須在 iTunes Connect 中完成以下步驟:

1.Create test user accounts.

創(chuàng)建測試用戶賬號。

Apple provides a testing environment, called the sandbox, which allows you to test your In-App Purchase products without incurring any financial charges. The sandbox environment uses special test user accounts rather than your regular iTunes Connect accounts to test In-App Purchase. See Test Users in the iTunes Connect Developer Guide for more information about creating test user accounts.

蘋果提供了一個測試環(huán)境,叫做 sandbox (沙盒), 它讓您無需承擔任何財務(wù)費用測試你的程序內(nèi)置購買的產(chǎn)品。

Note: You can use the same test user accounts to test both your iOS and OS X applications. Each In-App Purchase test user account is tied to one and only one email address. As such, you cannot reuse an existing email address with another test user account. You can create as many test user accounts as you want in iTunes Connect. Furthermore, if your email service provider supports email addresses with "+" sign, you can use that as an alias for your normal email address. For instance, if your email is foo@example.com, then you can use the foo+us@example.com, foo+uk@example.com, and foo+fr@example.com emails when creating test user accounts in iTunes Connect. All communications sent to foo+us@example.com, foo+uk@example.com, and foo+fr@example.com will be routed to foo@example.com.

注意:你可以使用同樣的測試用戶賬號來測試 iOS 和 OS X 應(yīng)用。 每個內(nèi)置購買測試用戶賬號只綁定到一個 email 地址上。 因此,你不能用同一個 email 賬號綁定另一個測試賬號。 你可以在 iTunes Connect 中創(chuàng)建任意多的測試賬號。另外,如果你的 email 服務(wù)提供商支持“+”標記的 email 地址,你可以把它作為你的 email 地址的別名。 比如,如果你的 email 地址是 foo@example.com, 在iTunes Connect 中創(chuàng)建測試用戶賬號時,你可以使用 foo+us@example.com, foo+uk@example.com,以及 foo+fr@example.com 等。 所有發(fā)送到 foo+us@example.com, foo+uk@example.com,以及 foo+fr@example.com 中的通信都會轉(zhuǎn)發(fā)到 foo@example.com。

2.Create In-App Purchase products.

創(chuàng)建內(nèi)置購買產(chǎn)品。

Creating In-App Purchase products is available via the Manage In-App Purchases feature in iTunes Connect.

通過 iTunes Connect 中的內(nèi)置購買功能創(chuàng)建有效的內(nèi)置購買產(chǎn)品。

Your Admin or Technical users should navigate to the Manage Your Applications in iTunes Connect, select the application for which they want to create In-App Purchase products, then click on the Manage In-App Purchases button in the ensuing page for this application. See Creating In-App Purchase Products in the In-App Purchase Configuration Guide for iTunes Connect for more information about creating In-App Purchase products.

管理員或技術(shù)人員應(yīng)該到 iTunes Connect 中的 Manage Your Applications,選擇他們想要創(chuàng)建內(nèi)置購買產(chǎn)品的應(yīng)用,然后在確定頁面中點擊管理內(nèi)置購買按鈕 (Manage In-App Purchases button)。 參見In-App Purchase Configuration Guide for iTunes Connect 中的 Creating In-App Purchase Products 來了解關(guān)于創(chuàng)建內(nèi)置購買產(chǎn)品的更多信息。

  • Fill out the In-App Purchases form.

填寫內(nèi)置購買表格

The In-App Purchase form contains the Product ID field, which specifies a unique identifier for each of your In-App Purchase products. See Technical Q&A QA1329, 'In-App Purchase Product Identifiers' for more information about product identifiers and how to access the form.

內(nèi)置購買表格包括產(chǎn)品 ID 字段,它為每個內(nèi)置購買產(chǎn)品指定一個唯一的標示符 (identifier) , 參見 Technical Q&A QA1329, 'In-App Purchase Product Identifiers'' 來了解產(chǎn)品識別碼的更多信息,以及如何訪問該表格。

  • Leave the state of your product as Waiting for Screenshot as shown in Figure 4.

讓你的產(chǎn)品狀態(tài)保留在等待截圖 (Waiting for Screenshot) 狀態(tài),如圖4.

Note: Upload a a screenshot of your In-App Purchase product once you are done testing it and ready to upload it for review.

注意:當你完成測試并準備好提交審核時,上傳一張內(nèi)置購買產(chǎn)品的截圖。

  • Clear your product for sale.

準備出售

The In-App Purchases form contains a Cleared for Sale checkbox, which determines whether your In-App Purchase product will be available for purchase from within your application. Check that box to make sure your product is available for sale.

在內(nèi)置購買表格中包含了一個 Cleared for Sale 選擇框,它用來確定你的內(nèi)置購買產(chǎn)品是否能在你的應(yīng)用中出售。 選中該選擇框來確保你的產(chǎn)品已能出售。

Figure 4 Status of Product IDs

http://wiki.jikexueyuan.com/project/in-app-purchase/images/15.png" alt="" />

What's Next?

四、接下來。。。。

You have successfully set up In-App Purchase for your application, let's implement and test it:

你已經(jīng)成功為你的應(yīng)用程序設(shè)置了內(nèi)置購買功能,讓我們實現(xiàn)并測試它:

1.Launch or create your project in Xcode.

用 Xcode 啟動或創(chuàng)建你的項目。

2.Enter the Bundle Identifier portion of your App ID in the Bundle Identifier field of your Target's Info pane in Xcode.

進入 Xcode 的 Target 的 Info 面板,在 Bundle Identifier 字段輸入你的 App ID 。

3.Enter a version number (CFBundleVersion) and a build number (CFBuildNumber) in the Version and Build fields of your Target's Summary Pane in Xcode, respectively as seen in Figure 5.

Note: CFBundleVersion and CFBuildNumber are strings that can only contain positive integers and and period (.) characters. See CFBundleVersion for more information.

打開 Target 的 Summary 面板,在 Version 和 Build 字段輸入一個版本號 (CFBundleVersion) 和一個構(gòu)建號(CFBuildNumber),參見圖5.

注意: CFBundleVersion 和 CFBuildNumber 是只能包含正整數(shù)和"."的字符串。參見CFBundleVersion學習更多信息。

Figure 5 Setting the version and build in the Summary pane

http://wiki.jikexueyuan.com/project/in-app-purchase/images/16.png" alt="" />

1.2.Sign your application.

給你的應(yīng)用程序簽名。

Navigate to the Build Settings pane of your Target and select the iOS Development Certificate/Provisioning Profile pair (iOS) or Mac signing certificate (OS X) associated with your App ID in the code signing identity section.

進入Target的 Build Setting 面板,在 code signing identity 區(qū)選擇跟你的 App ID 相關(guān)聯(lián)的 iOS Development Certificate/Provisioning Profile pair (iOS) or Mac signing certificate (OS X)。

2.Write code for your application.

編寫你的應(yīng)用程序代碼。

iOS 開發(fā)者和 OS X 開發(fā)者都應(yīng)該分別閱讀 In-App Purchase Programming GuideReceipt Validation Programming Guide,以學習在應(yīng)用程序中實現(xiàn)內(nèi)置購買的詳細信息。

Important: The Feature Delivery section of the In-App Purchase Programming Guide describes how to request information about your products from the App Store. Apple strongly recommends that you populate your user interface with products that were returned by the App Store. This ensures that your customers are only presented with products they can buy.

重要提示:In-App Purchase Programming Guide 的 Feature Delivery 章節(jié)描述了如何從應(yīng)用商店請求關(guān)于你的產(chǎn)品的相關(guān)信息。蘋果強烈推薦你使用應(yīng)用商店返回的帶有產(chǎn)品的用戶界面。這樣能確保你的用戶看到的是它們能夠購買的產(chǎn)品。

  • OS X applications should perform receipt validation immediately after launch. The apps should call exit with a status of 173 if validation fails as shown in Listing 1.

OS X 應(yīng)用程序應(yīng)該在啟動后立即執(zhí)行 receipt 驗證。 如果驗證失敗,應(yīng)用程序應(yīng)該調(diào)用 exit(173) ,如列表1:

Listing 1 Receipt validation

-(void)applicationWillFinishLaunching:(NSNotification *)notification
{
   // Locate the receipt
   NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];

   // Test whether the receipt is present at the above path
   if(![[NSFileManager defaultManager] fileExistsAtPath:[receiptURL path]])
   {
        // Validation fails
        exit(173);
   }

   // Proceed with further receipt validation steps
}

3.Test your application in the sandbox environment.

在沙盒環(huán)境測試你的應(yīng)用程序。

  • iOS developers must complete the following steps:

iOS 開發(fā)者必須完成以下步驟:

  • Sign out of the Store in the Settings application on your testing device.

在你的測試設(shè)備上,打開”設(shè)置“應(yīng)用程序,登出應(yīng)用商店。

  • Set the run destination of your application to an iOS Device in Xcode.

在 Xcode 中,選擇你的運行設(shè)備。

  • Build and run your application from Xcode.

    從 Xcode 構(gòu)建并運行你的應(yīng)用程序。

  • OS X developers must complete the following steps:

OS X開發(fā)者必須完成以下步驟:

  • Build your application in Xcode.

在 Xcode 中構(gòu)建你的應(yīng)用程序。

  • Run your application.

運行你的應(yīng)用程序

You must launch your application from the Finder rather than from Xcode the first time in order to obtain a receipt. Click on your application in the Finder to launch it. OS X displays a "Sign in to download from the App Store." dialog. Enter your test user account and password as requested. The sandbox provides you with a new receipt upon successful authentication.

Note: Launch your application from the Finder whenever you need a new receipt.

第一次啟動你的應(yīng)用程序時,從你的 Finder 啟動來獲得一個receipt ,而不是從 Xcode 啟動。在 Finder 中點擊啟動你的應(yīng)用程序。 OS X 顯示一個 ”Sign in to download from App Store“ 對話框。 輸入你的測試用戶賬號和密碼。 成功驗證后,沙盒給你一個新的 receipt 。

注意:任何時候需要一個新的 receipt 時,就從 Finder 啟動你的應(yīng)用程序。

Important: Use your test user account when prompted by Store Kit to confirm a purchase from within your application.

重要提示:在你的應(yīng)用程序中,如果 Store Kit 要求你確認一次購買,使用你的測試用戶賬號。

Store Kit connects to the sandbox environment when you launch your application from Xcode, from your test device (iOS), or from the Finder (OS X). It connects to a production environment for applications that were downloaded from the App Store. You must not use your test user account to sign into the production environment. This will result in your test user account becoming invalid. Invalid test accounts cannot be used to test In-App Purchase again.

當你從 Xcode(iOS) 或者 Finder(OS X) 啟動你的應(yīng)用程序時,Store Kit 連接到沙盒環(huán)境。當從應(yīng)用商店下載應(yīng)用程序并啟動時,它連接到一個產(chǎn)品環(huán)境 (production environment) 。 你絕對不能用你的測試賬戶登陸產(chǎn)品環(huán)境。這將讓你的測試賬戶無效。無效測試賬戶不能再次用來測試內(nèi)置購買。

Submit your In-App Purchase products for review.

提交你的內(nèi)置購買產(chǎn)品以供審核。

Log in to iTunes Connect to submit your In-App Purchase products for review by Apple, after you are done thoroughly testing them in the sandbox environment.

當你在沙盒環(huán)境中測試成功后,登陸 iTunes Connect ,提交你的內(nèi)置購買產(chǎn)品讓蘋果審核。

Frequently Asked Questions

五、常見問題解答

How many In-App Purchase product IDs can we create per application in iTunes Connect?

在iTunes Connect中,每個應(yīng)用程序可以創(chuàng)建多少格內(nèi)置購買產(chǎn)品 ID ?

Read Configuring a Product in the In-App Purchase Configuration Guide for iTunes Connect to find out how many In-App Purchase product IDs you can create per application.

閱讀 In-App Purchase Configuration Guide for iTunes Connect 中的Configuring a Product來尋找答案。

2.My iOS application is currently signed with a Provisioning Profile that uses a wildcard App ID. How do I enable my App ID to support In-App Purchase?

我的iOS應(yīng)用程序當前是使用了一個 wildcard App ID 的 Provisioning Profile 來簽名的。我應(yīng)該如何讓我的 App ID 支持內(nèi)置購買?

Read Editing App IDs in the App Distribution Guide to learn how you can enable your App ID to support In-App Purchase.

閱讀 App Distribution Guide 的 https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingProfiles/MaintainingProfiles.html#//apple_ref/doc/uid/TP40012582-CH30-SW4 來學習如何讓你的 App ID 支持內(nèi)置購買。

3.I cannot find the Manage In-App Purchases button in iTunes Connect?

不在 iTunes Connect 中找不到 Manage In-App Purchase 按鈕?

The Manage In-App Purchases button may not be available to you for one or more of the following reasons:

由于以下原因,你或許沒有 Manage In-App Purchase 按鈕:

  • You are not an Admin or Technical user for your iTunes Connect account.

你的 iTunes Connect 賬號不是一個管理員或技術(shù)人員賬號。

  • Your Team Agent has not agreed to the latest iOS or Mac Developer Program License Agreement.

你的團隊代理人還沒有同意最新的 iOS 或 Mac 開發(fā)者計劃許可協(xié)議( Developer Program License Agreement)。

  • You do not have the latest Paid Applications contract in effect.

你沒有最新支付的應(yīng)用合同。

4.Must I upload a binary to test In-App Purchase?

我必須上傳一個二進制文件來測試內(nèi)置購買嗎?

No. Testing In-App Purchase does not require uploading a binary.

Important: DO NOT upload the development binary to iTunes Connect until the application is ready for App Review approval. If the binary is present in iTunes Connect and it is not fully functional, App Review will review the binary and likely reject the development binary. Testing In-App Purchase will fail if you or App Review reject your most recent binary in iTunes Connect. The workaround in this case is to upload a binary without In-App Purchase features that can get approved by App Review. Once the binary is approved, resume testing the binary with In-App Purchase features.

不需要,測試內(nèi)置購買不要求上傳一個二進制文件。

重要提示:不要把開發(fā)二進制上傳到iTunes Connect,直到應(yīng)用程序?qū)徍送ㄟ^。如果iTunes Connect里有二進制文件,并且它的功能還不完善,應(yīng)用審核時會審核該二進制并且很可能會駁回該開發(fā)二進制文件。 如果你或應(yīng)用審核駁回你在iTunes Connect中最近的二進制文件,測試內(nèi)置購買將失敗。這種情況的變通辦法是上傳一個沒有內(nèi)置購買功能的二進制文件,這樣就可以被審核通過。當二進制文件審核通過以后,恢復帶有內(nèi)置購買功能的二進制測試。

5.How do I resolve the 'Your account info has changed' error?

我該如何解決“你的賬戶信息已經(jīng)改變”錯誤?

You are getting the 'Your account info has changed' error because you are signed in with your test user account on your device while testing In-App Purchase. To resolve this error, sign out of the Store in the Settings application on your device, create a new test user account in iTunes Connect, and use it when testing In-App Purchase.

你之所以得到這個錯誤,是因為你在測試內(nèi)置購買時用測試用戶賬號登陸了設(shè)備。 解決該錯誤的辦法是,在設(shè)備的設(shè)置那登出應(yīng)用商店,然后在 iTunes Connect 重新創(chuàng)建一個新的測試用戶賬號并用它測試內(nèi)置購買。

6.Why are my product identifiers being returned in the invalidProductIdentifiers array?

為什么我的產(chǎn)品標識符在 invalidProductIdentifiers 數(shù)組中返回?

Your product identifiers may be returned in the invalidProductIdentifiers array for one or more of the following reasons:

這可能是以下原因造成的:

You did not complete all the financial requirements (see the "Contracts, Tax, and Banking Information" section of this document).

你沒有完成所有的財務(wù)要求(查看本文的 “Contracts, Tax, and Banking Information” 章節(jié))。

You did not use an explicit App ID.

你沒有使用一個 explicit App ID.

  • You did not use the Provisioning Profile associated with your explicit App ID.

你沒有使用跟你的 explicit App ID 相關(guān)聯(lián)的 Provisioning Profile .

你在代碼中沒有使用正確的產(chǎn)品標識符。 關(guān)于產(chǎn)品標識符,請看Technical Q&A, QA1329, 'In-App Purchase Product Identifiers' 以獲得更多信息。

  • You did not clear your In-App Purchase products for sale in iTunes Connect.

你沒有在iTunes Connect中出售你的內(nèi)置購買產(chǎn)品。

  • You might have modified your products, but these changes are not yet available to all the App Store servers.

你或許已經(jīng)修改了你的產(chǎn)品,但是這些更改并不是適用于所有的應(yīng)用商店服務(wù)器。

  • If you or App Review rejected your most recent binary in iTunes Connect.

你活著應(yīng)用審查駁回了你在 iTunes Connect 中最新的二進制文件。

7.How do I resolve the "You've already purchased this In-App Purchase but it hasn't been downloaded." error message?

我該如何解決“你已經(jīng)完成了該內(nèi)置購買,但是它還沒被下載。”錯誤信息?

You are getting the "You've already purchased this In-App Purchase but it hasn't been downloaded." error message because you did not callSKPaymentQueue 's finishTransaction:method in your application. Calling finishTransaction: allows you to remove a transaction from the payment queue.

這是因為你沒有在你的應(yīng)用程序里調(diào)用 SKPaymentQueue 的 finishTransaction: 方法。 調(diào)用該方法把一個交易從支付列表里移除。

8.How do I resolve the "You've already purchased this. Tap OK to download it again for free." error message?

我該如何解決"你已經(jīng)成功購買。點擊 OK 再次免費下載。"錯誤信息?

The "You've already purchased this. Tap OK to download it again for free." message is a notification rather than an error. It indicates that you are attempting to purchase a nonconsumable product that you have already bought. You are not charged when purchasing an already bought nonconsumable product.

該信息是一個提醒,而不是一個錯誤。它說你正在嘗試購買一個你已經(jīng)購買過的非消耗產(chǎn)品。再次購買已經(jīng)購買過的非消耗產(chǎn)品并不需要再次支付。

Calling the payment queue’s restoreCompletedTransactions method does not restore any products in my application.

調(diào)用支付隊列的 restoreCompletedTransactions 方法不能恢復應(yīng)用程序中的任何產(chǎn)品。

9.Calling the payment queue’s restoreCompletedTransactions method may not restore any products in your application for one or more of the following reasons:

這可能是以下原因造成的:

  • You did not have any previously bought non-consumable, auto-renewable subscriptions, or free subscriptions.

你以前并沒有購買任何非消耗,自動更新訂閱,或免費訂閱的產(chǎn)品。

  • You were trying to restore non-renewing subscription or consumable products, which are not restorable. The restoreCompletedTransactionsmethod only restores non-consumable, auto-renewable subscriptions, and free subscriptions.

你正在嘗試恢復不能恢復的非自動更新訂閱或者消耗產(chǎn)品。 restoreCompletedTransactions 方法只能恢復非消耗,自動更新訂閱和免費訂閱產(chǎn)品。

Note: Store Kit does not call the paymentQueue:updatedTransactions: method when there are no restorable products.

注意:當沒有可恢復的產(chǎn)品時,Store Kit 不會調(diào)用 paymentQueue:updatedTransactions: 方法。

10.When should I restore my In-App Purchase products?

什么時候我應(yīng)該恢復我的內(nèi)置購買產(chǎn)品?

You should only restore your auto-renewal subscription or nonconsumable products in both of these cases:

你只能在以下兩種情況下才可以恢復你的自動更新訂閱或者非消耗產(chǎn)品:

  • To install them on additional devices owned by your customers.

為了在用戶的額外設(shè)備上下載它們時。

  • To reinstall them on devices where their associated application was deleted.

當它們的相關(guān)應(yīng)用程序被刪除時,為了可以在設(shè)備上重新下載它們。

11.How do I resolve the "This is not a test user account. Please create a new account in the Sandbox environment." error message?

我該如何解決"這不是一個測試用戶賬號。請在沙盒環(huán)境重新創(chuàng)建一個新賬號。"錯誤信息?

You are getting the "This is not a test user account. Please create a new account in the Sandbox environment." error message because you signed in with your iTunes user account when prompted by Store Kit to confirm a purchase. To resolve this error, sign out of the Store in the Settings application on your device and use your In-App Purchase test user account when prompted by Store Kit to confirm a purchase.

該錯誤是因為當 Store Kit 請求你確認購買時,你輸入了你的iTunes 用戶賬號。解決辦法是在你的設(shè)備的設(shè)置那登出你的應(yīng)用商店,當 Store Kit 要求你確認購買時輸入測試用戶賬號。

12.How do I retrieve the receipt data?

我該如何取回 receipt 數(shù)據(jù)?

Use NSBundle's appStoreReceiptURL method to first locate your application receipt, then read the entire receipt to retrieve your receipt data as shown inListing 2 (iOS 7, OS X 10.7 and later).

首先使用 appStoreReceiptURL 方法定位你的應(yīng)用 receipt ,然后如列表2中所示讀取整個 receipt 數(shù)據(jù)。(僅適用于 iOS 7, OS X10.7 以后版本)

Listing 2 Retrieving the receipt data

 NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
  // Test whether the receipt is present at the above URL
   if(![[NSFileManager defaultManager] fileExistsAtPath:[receiptURL path]])
   {
      NSData *receiptData = [NSData dataWithContentsOfURL:receiptURL];
   }

Note: For apps supporting iOS 6 and earlier, Use the transactionReceipt property of your SKPaymentTransaction object to retrieve your receipt data as shown in Listing 3.

注意:對于支持 iOS6 或早先版本的應(yīng)用程序,使用 SKPaymentTransaction 對象的 transactionReceipt 特性來取回你的 receipt 數(shù)據(jù),如列表3.

Listing 3 Retrieving the receipt data in iOS 6 and earlier

-(void)completeTransaction:(SKPaymentTransaction *)transaction
{
   NSData *receiptData = [transaction transactionReceipt];
}

Verifying my receipt fails with a status of (iOS)

驗證 receipt 失敗,狀態(tài)是一個<數(shù)字字符串>(iOS)

Verifying your receipt may fail with a status of for one or more of the following reasons:

這是由以下原因造成的:

  • You did not encode your receipt data using base64 encoding in your iOS application.

你沒有在你的 iOS 應(yīng)用程序中用 base64加密你的 receipt 數(shù)據(jù)。

  • The object being posted to the App Store is not formatted as JSON. See Listing 4 for a proper JSON object for an auto-renewable subscription.

發(fā)送到應(yīng)用商店的對象不是 JSON 格式。請看列表4,它是用于自動更新訂閱的一個正確的 JSON 對象。

Listing 4 valid sample receipt for verifying an auto-renewable subscription

{
    "receipt-data" : "...",
        "password" : "..."
}

14.I updated my iOS application with In-App Purchase. How do I test it (iOS)?

我給我的應(yīng)用程序添加了內(nèi)置購買功能。我該如何測試它 (iOS)?

Follow these steps if you are trying to test whether your updated app correctly implements In-App Purchase:

要想測試內(nèi)置購買是否正確實現(xiàn),請遵循以下步驟:

  • Install your original application via the Ad Hoc Distribution method.

通過 Ad Hoc 發(fā)布方法下載你的初始應(yīng)用程序。

  • Install your updated application also via the Ad Hoc Distribution method to verify that it overwrites the original application.

還是通過 Ad Hoc

下一篇:支付請求