iOS Developer Library/Guides

Delivering Products, iOS In-App Purchase Programming Guide 번역

창업자닉군 2013. 9. 19. 09:49

Introduction | Designing Your App’s Store | Displaying Your App’s Store UI | Requesting Payment
Delivering Products | Providing Purchased Content | Working with Subscriptions | Preparing for App Review

본 페이지는 iOS In-App Purchase Programming Guide 문서의 Delivering Products 부분을 번역해 놓은 페이지 입니다. 발 번역이라 이상한 부분이 있을 수 있습니다. 발견즉시 댓글을 달아 주세요.




Delivering Products
제공하는 제품

In the last part of the purchase process, after the App Store has processed the payment request, your app stores information about the purchase for future launches, downloads the purchased content, and marks the transaction as finished, as shown in Figure 4-1.

구매 프로세스의 마지막 부분에서는 앱 스토어 후 지불 요청, 향후 출시, 구입 한 콘텐츠 다운로드의 구입에 대한 귀하의 응용 프로그램 정보를 저장, 처리 및 마무리 트랜잭션을 표시, 그림 4-1에서 보여 주었다.

Figure 4-1  Stages of the purchase process—delivering products


Waiting for the Store to Process Transactions
공정 거래에 스토어 대기

Implement the paymentQueue:updatedTransactions: method on your transaction queue observer. Store Kit calls this method when the status of a transaction changes—for example, when a payment request has been processed. The transaction status tells you what action your app needs to perform, as shown in Table 4-1and Listing 4-1.

updatedTransactions : 트랜잭션 큐 관찰자의 방법 paymentQueue를 구현합니다. 트랜잭션의 상태가 변경 - 예를 들어, 때 지불 요청이 처리 된 경우 스토어 키트는이 메서드를 호출합니다.트랜잭션 상태는 4-1과 목록 4-1 표에서와 같이 응용이 수행해야 할 작업을 알려줍니다.

Table 4-1  Transaction statuses and corresponding actions

Status

Meaning

Action to take in your app

SKPaymentTransactionStatePurchasing

Transaction still in progress

Update your UI to reflect the status, and wait to be called again.

상태를 반영하기 위해 UI를 업데이트하고 다시 호출 할 때까지 기다립니다.

SKPaymentTransactionStateFailed

Transaction failed

Use the value of the error property to present a message to the user.

사용자에게 메시지를 표시하는 오류 속성의 값을 사용합니다.

SKPaymentTransactionStatePurchased

Transaction succeeded

Provide the purchased functionality.

구입 한 기능을 제공합니다.

Validate the receipt, as described in Receipt Validation Programming Guide, and download any content, as described in “Providing Purchased Content.”

로 영수증 검증 프로그래밍 가이드에 설명 된 영수증을, 검증, 및에 설명 된대로 콘텐츠를 다운로드 "를 구입 한 콘텐츠를 제공."

SKPaymentTransactionStateRestored

Transaction ready to restore

For information about restoring transactions, see Restoring Transactions.

복원 트랜잭션에 대한 자세한 내용은 트랜잭션 복원을 참조하십시오.

Listing 4-1  Responding to transaction statuses

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    for (SKPaymentTransaction *transaction in transactions)
    {
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
                [self completeTransaction:transaction];
                break;
            case SKPaymentTransactionStateFailed:
                [self failedTransaction:transaction];
                break;
            case SKPaymentTransactionStateRestored:
                [self restoreTransaction:transaction];
            default:
                break;
        }
    }
}

To keep your user interface up to date while waiting, the transaction queue observer can implement optional methods from the SKPaymentTransactionObserverprotocol as follows. The paymentQueue:removedTransactions: method is called when transactions are removed from the queue—in your implementation of this method, remove the corresponding items from your app’s UI. The paymentQueue:restoreCompletedTransactionsFailedWithError: orpaymentQueueRestoreCompletedTransactionsFinished: method is called when Store Kit finishes restoring transactions, depending on whether there was an error. In your implementation of these methods, update your app’s UI to reflect the success or error.

기다리는 동안 최신 사용자 인터페이스를 유지하려면, 트랜잭션 큐 관찰자는 다음과 같이 SKPaymentTransactionObserverprotocol에서 선택적 방법을 구현할 수 있습니다.paymentQueue : removedTransactions : 트랜잭션에서 제거 될 때 메서드가 호출 대기열이 메소드의 구현, 앱의 UI에서 해당 항목을 제거합니다.paymentQueue : restoreCompletedTransactionsFailedWithError : orpaymentQueueRestoreCompletedTransactionsFinished : 스토어 키트 복원 트랜잭션을 완료 할 때 방법은 오류가 발생했습니다 여부에 따라 호출됩니다. 이러한 방법의 구현에 성공 또는 오류를 반영하는 앱의 UI를 업데이트합니다.

Persisting the Purchase
구매를 지속

After making the product available, your app needs to make a persistent record of the purchase, to ensure that it continues to make the product available to the user in the future. Depending on the product’s type and the versions of iOS your app supports, you may need to explicitly persist the purchases or the system may handle this for you.

제품을 사용할 수 있도록 한 후, 응용 프로그램은 미래의 사용자가 사용할 수있는 제품을 만들기 위해 계속하기 위해, 구입의 영구적 인 기록을 확인해야합니다. 제품의 종류와 IOS 앱이 지원의 버전에 따라 명시 적으로 구매를 유지하거나 시스템이이 작업을 처리 할 수 ​​필요가 있습니다.

  • Consumable products. Your app updates its internal state to reflect the purchase, but there is no need to keep a persistent record because consumable products are not restored or synced across devices. Ensure that the updated state is part of an object that supports state preservation or that you manually preserve the state across app launches. For information about state preservation, see “State Preservation and Restoration” in iOS App Programming Guide.
    소모품 제품. 앱 업데이트는 내부 상태는 구입을 반영하지만, 소모품 제품은 복원 또는 장치를 통해 동기화되지 않기 때문에 영구적 인 기록을 유지 할 필요가 없습니다. 업데이트 된 상태가 상태를 보존하거나 수동으로 응용 프로그램 출시를 통해 상태를 유지하는 기능을 지원하는 오브젝트의 일부인지 확인합니다. 상태 보존에 대한 자세한 내용은 IOS 앱 프로그래밍 가이드에서 "국가 보존 및 복원"을 참조하십시오.

  • Non-consumable products, auto-renewable subscriptions, and free subscriptions. In iOS 7 and later, the system persists non-consumable products in the app receipt for you. If you need to support older versions of iOS, your app is responsible for keeping a persistent record of the purchase.
    비 소모품 제품, 자동 재생 구독 및 무료 구독. IOS 7 및 이후 버전에서, 시스템은 당신을 위해 응용 프로그램 영수증이 아닌 소모품 제품을 계속. 당신의 iOS 이전 버전을 지원해야하는 경우, 귀하의 응용 프로그램은 구입의 지속적인 기록을 유지하는 책임이 있습니다.

  • Non-renewing subscriptions. Persisting the purchase is your app’s responsibility on all versions of iOS and OS X. Store the receipt outside the device so that you can restore transactions across devices.
    구독을 비 갱신. 구입을 지속하는 것은 IOS와 OS X의 저장 장치 외부의 영수증이 장치에서 트랜잭션을 복원 할 수 있도록 모든 버전의 앱의 책임입니다.

Information about consumable products and non-renewing subscriptions is added to the receipt when they are paid for, and remains in the receipt until you finish the transaction. After you finish the transaction, this information is removed the next time the receipt is updated—for example, the next time the user makes a purchase.

소모품 제품 및 비 갱신 등록에 대한 정보는 그들이 지불 할 때 영수증을 추가, 당신은 트랜잭션을 완료 할 때까지 영수증에 남아 있습니다. 당신이 거래를 완료 한 후,이 정보는 영수증 업데이트 -입니다 예를 들어 다음 번에 제거되고 다음 번에 사용자가 구매를합니다.

For information about the app’s receipt, including how to read it and how to validate it, see Receipt Validation Programming Guide

을 읽고이를 확인하는 방법을 방법을 포함하여 응용 프로그램의 접수에 대한 자세한 내용은, 영수증 유효성 검사 프로그래밍 가이드를 참조하십시오

Persisting Using User Defaults or iCloud

사용자 기본값을 사용하거나 iCloud를 지속

The User Defaults system is the simplest approach, but it doesn’t sync across devices. In OS X, because users can edit the user defaults using Terminal, it may be more appropriate for your app to store a copy of the receipt in the user defaults—the receipt is signed and can’t be tampered with, unlike simple Boolean or integer values.

사용자 기본 시스템은 간단한 방법이지만, 그것은 장치에 걸쳐 동기화되지 않습니다. 사용자가 터미널을 사용하여 사용자 기본 설정을 편집 할 수 있기 때문에 OS X에서, 사용자의 영수증의 사본을 저장하기 위해 응용 프로그램에 더 적합 할 수 있습니다 기본값 - 영수증 간단한 부울 또는 달리 서명하고 조작 할 수 없습니다 정수 값.

To persist the purchase with the User Defaults system, set the value of a key.
사용자 기본 시스템과 함께 구입을 유지하려면 키의 값을 설정합니다.

NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
 
// Store a simple value.
[defaults setBool:YES forKey:@"enable_rocket_car"];
[store setInteger:@15 forKey:@"highest_unlocked_level"];
 
// Update an array of receipts.
NSArray * receipts = [defaults arrayForKey@"receipts"];
NSData * newReceipt;  // Assume this exists.
NSArray * updatedReceipts = [receipts arrayByAddingObject:newReceipt];
[defaults setObject:newReceipts forKey@"receipts"];
 
[defaults synchronize];

To persist the purchase with iCloud, set the value of a key in the key-value store—the code in this approach is almost identical to the code for using the User Defaults system except you use an instance of NSUbiquitousKeyValueStore instead of NSUserDefaults.

iCloud를 함께 구입을 유지하려면, 키의 값을 설정 키 - 값 저장소 -이 방법의 코드는 NSUbiquitousKeyValueStore 대신 NSUserDefaults의 인스턴스를 사용하여 제외하고 사용자 기본 시스템을 사용하는 코드와 거의 동일합니다.

NSUbiquitousKeyValueStore * store = [NSUbiquitousKeyValueStore defaultStore];
 
// Store a simple value.
[store setBool:YES forKey:@"enable_rocket_car"];
[store setInteger:@15 forKey:@"highest_unlocked_level"];
 
// Update an array of receipts.
NSArray * receipts = [store arrayForKey@"receipts"];
NSData * newReceipt;  // Assume this exists.
NSArray * updatedReceipts = [receipts arrayByAddingObject:newReceipt];
[store setArray:newReceipts forKey@"receipts"];
 
[store synchronize];

Persisting Using Your Own Server
자신의 서버를 사용하여 지속

To store the receipts on your server, send a copy of the receipt to your server along with some kind of credentials or identifier so that you can keep track of which receipts belong to a particular user. For example, let users identify themselves to your server with an email or user name, plus a password. Don’t use theidentifierForVendor property of UIDevice—you can’t use it to identify and restore purchases made by the same user on a different device, because different devices have different values for this property.

당신은 영수증은 특정 사용자에게 속한 추적 할 수 있도록 서버에 영수증을 저장하려면 자격 증명 또는 식별자의 일종과 함께 서버에 영수증 사본을 보내드립니다. 예를 들어, 사용자가 이메일 또는 사용자 이름, 플러스 암호로 서버에 자신을 식별 할 수 있습니다. 의 theidentifierForVendor 속성을 사용하지 마십시오 UIDevice를 사용하면 다른 장치가이 속성에 대해 다른 값을 가지고 있기 때문에, 다른 장치에 동일한 사용자에 의해 구매를 확인하고 복원하는 데 사용할 수 없습니다.

Making the Product Available
제품이 사용 가능하게 만들기

Your app needs to take the appropriate actions to make the purchased product available to the user—unlock new app functionality, perform the purchased service, download now content, and so on. The exact details of how you make a product available depend on your app and the product.

앱이 사용자 잠금 해제 새로운 응용 프로그램 기능에 구입 한 제품을 사용할 수 있도록 적절한 조치를 취할 필요가 구입 한 서비스를 수행, 지금은 콘텐츠를 다운로드, 등등.정확한 ​​사용 가능한 제품이 귀하의 응용 프로그램과 제품에 따라 만드는 방법에 대한 자세한.

If the product has associated content, your app needs to deliver that content to the user. For example, purchasing a level in a game requires delivering the files that define that level, and purchasing additional instruments in a recording app requires delivering the sound assets that the app needs to let the user play those instruments. For information about how to provide content, see “Providing Purchased Content.”

제품의 내용을 연결 한 경우, 귀하의 응용 프로그램은 사용자에게 콘텐츠를 제공 할 필요가있다. 예를 들어, 게임에서 레벨을 구입하면 해당 레벨을 정의하는 파일을 제공하고, 레코딩 응용 프로그램에 추가로 장비를 구입해야합니다 응용 프로그램은 사용자가 해당 악기를 연주하도록해야한다는 소리가 자산을 제공해야합니다. 콘텐츠를 제공하는 방법에 대한 자세한 내용은 "구입 한 컨텐츠를 제공"을 참조하십시오.

Finishing the Transaction
거래를 마무리

Finishing a transaction tells Store Kit that you have completed everything needed for the purchase. Unfinished transactions remain in the queue until they are finished, and the transaction queue observer is called every time your app is launched so that your app can finish them.
트랜잭션을 완료하는 것은 당신이 구입에 필요한 모든 것을 완료했다고 스토어 키트를 알려줍니다. 끝나지 않은 트랜잭션들이 완료 될 때까지 큐에 남아 있고, 트랜잭션 큐 관찰자는 앱이 앱이 그들을 완료 할 수 있도록 실행 때마다 호출됩니다.

Complete all the following actions before you finish the transaction:
당신이 거래를 완료하기 전에 다음 작업을 완료합니다 :

  • Persist the purchase if needed.
    필요한 경우 구입을 지속.

  • Download any purchased content.
    모든 구입 한 콘텐츠를 다운로드합니다.

  • Update your app’s UI to let the user access the product.
    사용자가 제품에 액세스 할 수 있도록 앱의 UI를 업데이트합니다.

  • Finish any other work needed to deliver the product.
    제품을 제공하는 데 필요한 다른 작업을 마칩니다.

To finish a transaction, call its finishTransaction: method. After you finish a transaction, do not take any actions on that transaction or do any work to deliver the product. If there is work remaining on a transaction, your app isn’t ready to finish the transaction yet.

방법 : 트랜잭션을 완료하려면 해당 finishTransaction를 호출합니다. 트랜잭션을 완료 한 후, 해당 트랜잭션에 대한 작업을 수행하거나 제품을 제공 할 수있는 작업을 수행하지 않습니다. 트랜잭션에 남은 작업이있는 경우, 당신의 앱은 아직 트랜잭션을 완료 할 준비가되지 않습니다.

Suggested Testing Steps
제안 된 테스트 단계

Test each part of your code to verify that you have implemented it correctly.
당신이 올바르게 구현되었는지 확인하는 코드의 각 부분을 테스트합니다.

Test a Successful Transaction
성공적인 트랜잭션을 테스트

Sign in to the iTunes Store with a test user account, and make a purchase in your app. Set a breakpoint in your implementation of the transaction queue observer’spaymentQueue:updatedTransactions: method, and inspect the transaction to verify that its status is SKPaymentTransactionStatePurchased.

테스트 사용자 계정을 사용하여 iTunes Store에 로그인하고 응용 프로그램에 구매를합니다. updatedTransactions : 트랜잭션 큐 observer'spaymentQueue의 구현에서 중단 점 설정 방법, 그 상태가 SKPaymentTransactionStatePurchased되어 있는지 확인하기 위해 트랜잭션을 검사합니다.

Set a breakpoint at the point in your code that persists the purchase, and confirm that this code is called in response to a successful purchase. Inspect the User Defaults or iCloud Key-Value Store, and confirm that the correct information has been recorded.

구입을 계속 코드의 시점에서 중단 점을 설정하고,이 코드가 성공적으로 구매에 대한 응답으로 호출되어 있는지 확인합니다.사용자 기본값 또는 iCloud에 키 - 값 저장소를 점검하고 올바른 정보가 기록되었는지 확인합니다.

Verify That Transactions Are Finished
트랜잭션이 완료되어 있는지 확인합니다

Locate where your app calls the finishTransaction: method. Verify that all work related to the transaction has been completed before the method is called, and that the method is called for every successful purchase.

방법 : 앱이 finishTransaction 호출 위치를 찾습니다.메서드를 호출하기 전에 거래에 관련된 모든 작업이 완료되었는지, 그리고 방법은 모든 성공적인 구입이라고되어 있는지 확인합니다.