Introduction | Overview of In-App Purchase | Retrieving Product Information | Making a Purchase
Adding a Store to Your Application | Verifying Store Receipts | Testing a Store | Auto-Renewable Subscriptions


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




Adding a Store to Your Application
귀하의 응용 프로그램에 저장소 추가

This chapter provides guided steps for adding a store to your application.
이 장에서는 응용 프로그램 저장소를 추가 안내 단계를 제공합니다.

The Step-By-Step Process

When you set up the project, make sure to link to StoreKit.framework. You can then add a store by following these steps:

프로젝트를 설정할 때, StoreKit.framework에 연결해야합니다. 그런 다음 단계를 수행하여 저장소를 추가 할 수 있습니다 :


  1. Decide what products you wish to deliver with your application.
    응용 프로그램과 함께 제공하고자하는 어떤 제품을 결정합니다.

    There are limitations on the types of features you can offer. Store Kit does not allow your application to patch itself or download additional code. Products must either work with existing code in your application or must be implemented using data files delivered from a remote server. If you wish to add a feature that requires changes to your source code, you need to ship an updated version of your application.

    당신이 제공 할 수있는 기능의 종류제한이 있습니다. 스토어 키트는 응용 프로그램 자체를 패치 또는 추가 코드를 다운로드 할 수 없습니다. 제품은 어느 응용 프로그램에서 기존 코드로 작업해야하거나 원격 서버에서 전송 데이터 파일을 사용하여 구현해야합니다. 당신은 소스 코드를 변경해야하는 기능을 추가하고자하는 경우, 당신은 응용 프로그램의 업데이트 된 버전을 출시합니다.


  2. Register product information for each product with iTunes Connect.
    아이튠즈 연결 각 제품에 대한 제품 정보를 등록합니다.

    You revisit this step every time you want to add a new product to your application’s store. Every product requires a unique product identifier string. The App Store uses this string to look up product information and to process payments. Product identifiers are specific to your iTunes Connect account and are registered with iTunes Connect in a way similar to how you registered your application.

    이 단계 당신이 응용 프로그램의 저장소에 제품을 추가 할 때마다 방문. 각 제품은 고유 한 제품 ID 문자열이 필요합니다.앱 스토어이 문자열 제품 정보를 조회하고 결제를 처리하는 데 사용합니다. 제품 ID는 아이튠즈에 특정 계정을 연결하고 아이튠즈 응용 프로그램을 등록하는 방법과 유사한 방법으로 연결에 등록됩니다.


    The process to create and register product information is described in iTunes Connect Developer Guide.
    제품 정보를 작성하고 등록하는 과정은 iTunes에서 설명하는 개발자 가이드를 연결합니다.


  3. Determine whether payments can be processed.
    결제가 처리 할 수 있는지 여부를 결정합니다.

    A user can disable the ability to make purchases inside applications. Your application should check to see whether payments can be purchased before queuing new payment requests. Your application might do this before displaying a store to the user (as shown here) or it may defer this check until the user actually attempts to purchase an item. The latter allows the user to see items that they could purchase when payments are enabled.

    사용자는 응용 프로그램 내부에 구매를 할 수있는 능력을 해제 할 수 있습니다. 응용 프로그램은 지불이 큐에 새로운 지불 요청하기 전에 구입 할 수 있는지 여부를 확인해야합니다. 응용 프로그램이 사용자에게 저장소를 표시하기 전에작업을 수행 할 수 있습니다 (다음과 같이) 또는 사용자가 실제로 상품을 구입하려고 할 때까지이 검사를 연기 할 수 있습니다.후자는 사용자가 결제가 활성화 될 때 그들이 구입할 수있는 항목을 볼 수 있습니다.

    if ([SKPaymentQueue canMakePayments]) {
       // Display a store to the user.
    } else {
       // Warn the user that purchases are disabled.
    }
  4. Retrieve information about products.
    제품에 대한 정보 검색 할 수 있습니다.

    Your application creates an SKProductsRequest object and initializes it with a set of product identifiers for the items you wish to sell, attaches a delegate to the request, and then starts it. The response holds the localized product information for all valid product identifiers.

    응용 프로그램 SKProductsRequest 개체를 만들고 당신이 판매하고자하는 항목에 대한 제품 식별자 세트로 초기화 요청에 대리자를 연결 한 시작합니다.응답이 유효한 모든 제품 식별자에 대한 지역화 된 제품의 정보를 보유하고 있습니다.


    Keep the array of valid products from the response. When the user selects a product to buy, you will need a product object to create the payment request.

    응답에서 유효한 제품의 배열을 유지한다.사용자가 구입할 수있는 제품을 선택하면, 당신은 지불 요청을 만들어야 할 제품 개체가 필요합니다.

    - (void) requestProductData
    {
        SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers:
                [NSSet setWithObject: kMyFeatureIdentifier]];
        request.delegate = self;
        [request start];
    }
    - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
    {
        NSArray *myProducts = response.products;
        // Populate your UI from the products list.
        // Save a reference to the products list.
    }
  5. Add a user interface that displays products to the user.
    사용자에게 제품을 표시하는 사용자 인터페이스를 추가합니다.

    Store Kit does not provide user interface classes. The look and feel of how you offer products to your customers is up to you!
    스토어 키트사용자 인터페이스 클래스를 제공하지 않습니다. 당신이 당신의 고객에게 제품을 제공하는 방법의 모양과 느낌당신에게 달려!

  6. Register a transaction observer with the payment queue.
    결제 트랜잭션 옵저버를 등록합니다.

    Your application should instantiate a transaction observer and add it as an observer of the payment queue.
    응용 프로그램이 트랜잭션 관찰자를 인스턴스화하고 결제 큐의 관찰자 추가해야합니다.

    MyStoreObserver *observer = [[MyStoreObserver alloc] init];
    [[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

    Your application should add the observer when your application launches. The App Store remembers queued transactions even if your application exited before completing all transactions. Adding an observer during initialization ensures that all previously queued transactions are seen by your application.
    응용 프로그램을 시작할 때 응용 프로그램은 관찰자를 추가해야합니다. 응용 프로그램이 모든 트랜잭션을 완료하기 전에 종료해도 앱 스토어대기중인 트랜잭션을 기억합니다. 초기화하는 동안 관찰자를 추가하면 이전에 대기중인 트랜잭션은 응용 프로그램에서 볼 수 있도록합니다.

  7. Implement the paymentQueue:updatedTransactions: method on MyStoreObserver.
    updatedTransactions : MyStoreObserver 방법 paymentQueue를 구현합니다.

    The observer’s paymentQueue:updatedTransactions: method is called whenever new transactions are created or updated.
    관찰자의 paymentQueue : updatedTransactions : 새 트랜잭션을 만들거나 업데이트 할 때마다 메서드가 호출됩니다.

    - (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;
            }
        }
    }
  8. Your observer provides the product when the user successfully purchases an item.
    귀하의 관찰자는 사용자가 성공적으로 아이템을 구매 제품을 제공합니다.

    - (void) completeTransaction: (SKPaymentTransaction *)transaction
    {
        // Your application should implement these two methods.
        [self recordTransaction:transaction];
        [self provideContent:transaction.payment.productIdentifier];
     
        // Remove the transaction from the payment queue.
        [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
    }

    A successful transaction includes a transactionIdentifier property and a transactionReceipt property that record the details of the processed payment. Your application is not required to do anything with this information. You may wish to record this information to establish an audit trail for the transaction. If your application uses a server to deliver content, the receipt can be sent to your server and validated by the App Store.
    성공적인 거래transactionIdentifier 속성과 처리 된 지불의 세부 사항을 기록하는 transactionReceipt 속성을 포함합니다. 응용 프로그램은이 정보를 아무것도 할 필요가 없습니다. 당신은 트랜잭션에 대한 감사 추적을 설정하려면이 정보를 기록 수 있습니다. 응용 프로그램 콘텐츠를 제공하는 서버를 사용하는 경우, 영수증은 서버로 전송 앱 스토어에서 유효성을 검사 할 수 있습니다.

    It is critical that your application take whatever steps are necessary to provide the product that the user purchased. Payment has already been collected, so the user expects to receive the new purchase. See “Feature Delivery” for suggestions on how you might implement this.
    응용 프로그램은 사용자가 구매 한 제품을 제공하는 데 필요한 모든 단계를 수행하는 것이 중요합니다. 결제이미 수집 된, 그래서 사용자는 새로운 구매를받을 것으로 기대하고있다. 당신이 구현하는 방법에 대한 제안 "기능 배달"을 참조하십시오.

    Once you’ve delivered the product, your application must call finishTransaction: to complete the transaction. When you call finishTransaction:, the transaction is removed from the payment queue. To ensure that products are not lost, your application should deliver the product before callingfinishTransaction:.
    제품을 전달하고 나면, 응용 프로그램 finishTransaction를 호출해야합니다 : 트랜잭션을 완료 할 수 있습니다. 당신이 finishTransaction를 호출 할 , 트랜잭션은 결제 에서 제거됩니다. 제품이 손실되지 않도록하려면 응용 프로그램 callingfinishTransaction 전에 제품을 제공합니다.

  9. Finish the transaction for a restored purchase.
    복원 구입 거래를 완료하십시오.

    - (void) restoreTransaction: (SKPaymentTransaction *)transaction
    {
        [self recordTransaction: transaction];
        [self provideContent: transaction.originalTransaction.payment.productIdentifier];
        [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
    }

    This routine is similar to that for a purchased item. A restored purchase provides a new transaction, including a different transaction identifier and receipt. You can save this information separately as part of any audit trail if you desire. However, when it comes time to complete the transaction, you’ll want to recover the original transaction that holds the actual payment object and use its product identifier.
    이 루틴은 구입 항목에 대한 유사합니다.복원 구입은 다른 트랜잭션 식별자와 영수증 새 트랜잭션을 제공합니다. 당신이 원하는 경우에 당신은 어떤 감사의 일부로서 별도로 정보를 저장할 수 있습니다. 그러나, 트랜잭션을 완료하는 데 시간이 올 때, 당신은 실제 지불 객체를 보유하고있는 원래의 트랜잭션을 복구하고 자사의 제품 식별자를 사용하는 것이 좋습니다.

  10. Finish the transaction for a failed purchase.
    실패한 구입 거래를 완료하십시오.

    - (void) failedTransaction: (SKPaymentTransaction *)transaction
    {
        if (transaction.error.code != SKErrorPaymentCancelled) {
            // Optionally, display an error here.
        }
        [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
    }

    Usually a transaction fails because the user decided not to purchase the item. Your application can read the error field on a failed transaction to learn exactly why the transaction failed.

    The only requirement for a failed purchase is that your application remove it from the queue. If your application chooses to put up an dialog displaying the error to the user, you should avoid presenting an error when the user cancels a purchase.
    사용자가 아이템을 구매하지 않기로 결정하기 때문에 일반적으로 트랜잭션이 실패합니다. 응용 프로그램이 트랜잭션이 실패한 이유를 정확하게 배울 수있는 실패 트랜잭션오류 필드를 읽을 수 있습니다.
    실패한 구입을위한 유일한 요구 사항은 응용 프로그램이 큐에서 제거하는 것입니다. 응용 프로그램이 사용자에게 오류를 표시하는 대화 상자를 넣어 선택하면, 사용자가 구매를 취소 할 때 오류를 제시 피해야한다.

  11. With all the infrastructure in place, you can finish the user interface. When the user selects an item in the store, create a payment object and add it to the payment queue.
    곳에서 인프라, 사용자 인터페이스를 완료 할 수 있습니다.사용자가 저장소에 항목을 선택하면 결제 개체를 만들고 결제 에 추가합니다.

    SKProduct *selectedProduct = <#from the products response list#>;
    SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct];
    [[SKPaymentQueue defaultQueue] addPayment:payment];

    If your store offers the ability to purchase more than one of a product, you can create a single payment and set the quantity property.
    당신의 가게는 제품 중 하나 이상을 구입 할 수있는 기능을 제공하는 경우, 당신은 하나의 지불을 만들고 속성을 설정할 수 있습니다.

    SKProduct *selectedProduct = <#from the products response list#>;
    SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:selectedProduct];
    payment.quantity = 3;
    [[SKPaymentQueue defaultQueue] addPayment:payment];

Where to Go Next

The code provided in these steps is best used for the built-in product model. If your application uses a server to deliver content, you are responsible for designing and implementing the protocols used to communicate between your application and your server. Your server should also verify receipts before delivering products to your application.
단계에서 제공된 코드가장 기본 제품 모델에 사용됩니다. 응용 프로그램 콘텐츠를 제공하는 서버를 사용하는 경우, 당신은 응용 프로그램과 서버 사이의 통신에 사용되는 프로토콜을 설계 및 구현에 대한 책임이 있습니다. 서버응용 프로그램에 제품을 전달하기 전에 영수증을 확인해야합니다.

Posted by 창업자닉군
,