# iOS 인앱 메시지에서 구매

사용자가 iOS 앱에 표시되는 인앱 메시지에서 직접 구매할 수 있도록 하려면, 리치 미디어(Rich Medias)를 위한 즉시 사용 가능한 솔루션을 구현하고 인앱 구매에 대한 더 많은 정보를 얻기 위한 콜백(callbacks)을 추가할 수 있습니다.

<Aside type="note">
**6.4.5 iOS SDK 버전 이상**에서 사용 가능합니다.
</Aside>

## 리치 미디어 JavaScript 구현

리치 미디어(Rich Medias)에서 인앱 구매를 구현하려면 간단한 **JavaScript 함수 호출**을 사용하십시오:

```javascript
pushwooshImpl.makePurchaseWithIdentifier("Premium"); // App Store 제품 정보에 지정된 제품 식별자
```

## 콜백을 위한 AppDelegate 메서드

구매 시 콜백이 실행되어야 하는 경우, **PWPurchaseDelegate 프로토콜**을 다음과 같이 구현하십시오:

1.  프로젝트의 AppDelegate가 PWPurchaseDelegate 프로토콜을 준수하도록 합니다:

    ```objective-c
    @interface AppDelegate : PWAppDelegate <PushNotificationDelegate, PWPurchaseDelegate>
    ```

2.  AppDelegate에 PWPurchaseDelegate 메서드를 구현합니다:

    ```objective-c
    #pragma mark - Purchase delegate methods
    - (void) onPWInAppPurchaseHelperPaymentComplete:(NSString*) identifier {
        NSLog(@“Custom purchase delegate -- payment complete for identifier: %@“, identifier);
    }
    -(void)onPWInAppPurchaseHelperProducts:(NSArray<SKProduct *>* _Nullable)products {
        NSLog(@“Custom purchase delegate -- retrieved list of products”);
    }
    -(void)onPWInAppPurchaseHelperPaymentFailedProductIdentifier:(NSString* _Nullable)identifier error:(NSError* _Nullable)error {
        NSLog(@“Custom purchase delegate -- payment failed with identifier %@ and error %@“, identifier, error.description);
    }
    ```

### 사용 가능한 PWPurchaseDelegate 메서드 목록

#### 제품 목록

```objective-c
@protocol PWPurchaseDelegate <NSObject>
// 앱에 있는 제품 목록에 대한 자세한 정보
-(void)onPWInAppPurchaseHelperProducts:(NSArray<SKProduct *>* _Nullable)products;
@end
```

#### 성공적인 거래

```objective-c
@protocol PWPurchaseDelegate &#x3C;NSObject>
// 성공적으로 처리된 거래
<strong>-(void)onPWInAppPurchaseHelperPaymentComplete:(NSString* _Nullable)identifier;
</strong>
@end
```

#### 실패한 거래

```objective-c
@protocol PWPurchaseDelegate &#x3C;NSObject>
<strong>// 실패한 거래
</strong>-(void)onPWInAppPurchaseHelperPaymentFailedProductIdentifier:(NSString* _Nullable)identifier error:(NSError* _Nullable)error;
@end
```

#### App Store에서 승격됨

```objective-c
@protocol PWPurchaseDelegate <NSObject>
// App Store에서 인앱 구매가 시작되었고, 거래가 앱에서 계속됩니다.
-(void)onPWInAppPurchaseHelperCallPromotedPurchase:(NSString* _Nullable)identifier;
@end
```

#### 완료된 거래 복원 실패

```objective-c
@protocol PWPurchaseDelegate <NSObject>
// 거래 복원 중 오류가 발생했습니다.
-(void)onPWInAppPurchaseHelperRestoreCompletedTransactionsFailed:(NSError * _Nullable)error;
@end
```

<Aside type="note">
이 가이드에 명시된 메서드로 요구 사항이 충족되지 않는다면, [고객 지원팀](https://help.pushwoosh.com/hc/en-us/requests/new?utm\_content=pwwebsite\&utm\_term=footer\&utm\_campaign=support)에 문의해 주십시오. 추가 지침을 기꺼이 제공해 드리겠습니다.
</Aside>