Home > Services & APIs > Earn > In-App Purchasing

IAP Plugin Methods and Events for Unity

Introduction

This document gives an overview of the available methods and events for the In-App Purchasing (IAP) v2.0 plugin for Unity.

Method Summary

You can initiate method calls to request information from the system. The following table describes the available methods.

Return Type Method Summary Link to Sample Code
RequestOutput GetUserData()
Initiates a request to retrieve the user ID and marketplace of the currently logged-in user.
Unity
RequestOutput Purchase(SkuInput input)
Initiates a purchase flow for a product.
Unity
RequestOutput GetProductData(SkusInput input)
Initiates a request to retrieve item data for up to 100 SKUs.
Unity
RequestOutput GetPurchaseUpdates(ResetInput input)
Initiates a request to retrieve updates about items the customer has purchased and/or cancelled.
Unity
void NotifyFulfillment(NotifyFulfillmentInput input)
Notifies Amazon about the purchase fulfillment.
Unity

Event Summary

Events are system-generated messages that you can listen for. They are generated in response to developer-initiated requests (method calls). The following table describes the available events.

Event Parameters Event Summary Link to Sample Code
GetUserDataResponse GetUserDataResponse
Returns the response from the GetUserData call.
Unity
PurchaseResponse PurchaseResponse
Returns the response from the Purchase call.
Unity
GetProductDataResponse GetProductDataResponse
Returns the response from the GetProductData call.
Unity
GetPurchaseUpdatesResponse GetPurchaseUpdatesResponse
Returns the response from the GetPurchaseUpdates call.
Unity

Supporting Data Objects

Objects used as method and event parameters are described in the following table.

Object Members Description
AmazonUserData string userId The user ID.
string marketplace The two-character ISO 3166-1 Alpha-2 code denoting the marketplace of the user. Can be null if the marketplace information is not available; this may happen with previous versions of the Amazon Appstore.
GetProductDataResponse string requestId The request ID originally returned by GetProductData.
ProductDataMap productDataMap See ProductDataMap.
List<string> unavaliableSkus The list of SKUs provided in the original request for which product data is not available.
string status One of SUCCESSFUL, NOT_SUPPORTED, or FAILED. SUCCESSFUL indicates a successful request. NOT_SUPPORTED indicates this call is not supported. FAILED indicates an unsuccessful request.
GetPurchaseUpdatesResponse string requestId The request ID originally returned by GetPurchaseUpdates.
AmazonUserData amazonUserData See AmazonUserData.
List<PurchaseReceipt> purchaseReceipts Returns a list of receipts, or an empty list if status is not SUCCESSFUL or there are no receipts.
string status One of SUCCESSFUL, NOT_SUPPORTED, or FAILED. SUCCESSFUL indicates a successful request. NOT_SUPPORTED indicates this call is not supported. FAILED indicates an unsuccessful request.
boolean hasMore True if more results are available.
GetUserDataResponse string requestId The request ID originally returned by GetUserData.
AmazonUserData amazonUserData See AmazonUserData.
string status One of SUCCESSFUL, NOT_SUPPORTED, or FAILED. SUCCESSFUL indicates a successful request. NOT_SUPPORTED indicates this call is not supported. FAILED indicates an unsuccessful request.
NotifyFulfillmentInput string receiptId A receipt ID is a unique identifier of a purchase and is returned as part of the purchase response.
string fulfillmentResult Either FULFILLED or UNAVAILABLE. FULFILLED means the app successfully fulfilled the purchase. Calling with this status forces the Amazon Appstore to mark this purchase as successfully completed. UNAVAILABLE means the purchase can never be fulfilled by the app. Calling with this status forces the Amazon Appstore to cancel the purchase.
ProductData string sku The SKU of the purchase.
string productType The type of product. Can be CONSUMABLE, ENTITLED or SUBSCRIPTION. See Implementing Consumables, Entitlements, and Subscriptions in IAP 2.0 for more information.
string price The price of the product, including the currency symbol and the numerical value. In the case of a subscription parent product, this is null.
string title The localized title of the product. If no title for the locale, returns the default (English).
string description The localized description of the product. If no description for the locale, returns the default (English).
string smallIconUrl The URL of the small icon.
ProductDataMap key: string sku
value: ProductData productData
A map using a SKU as the key and a ProductData object as the value.
PurchaseReceipt string receiptId A receipt ID, which is a unique identifier of a purchase.
long cancelDate The cancel date for the purchase, in milliseconds since January 1, 1970, 00:00:00 GMT, or 0 if it is not canceled.
long purchaseDate The purchase date for the purchase, in milliseconds since January 1, 1970, 00:00:00 GMT.
string sku The SKU of the purchase. In the case of subscriptions, this SKU represents the subscription, not a specific term. Examine the PurchaseDate and CancelDate to determine the start and end dates of the subscription.
string productType The type of product. Can be CONSUMABLE, ENTITLED or SUBSCRIPTION. See Implementing Consumables, Entitlements, and Subscriptions in IAP 2.0 for more information.
PurchaseResponse string requestId The request ID originally returned by Purchase.
AmazonUserData amazonUserData See AmazonUserData.
PurchaseReceipt purchaseReceipt See PurchaseReceipt.
string status One of SUCCESSFUL, NOT_SUPPORTED, FAILED, INVALID_SKU, or ALREADY_PURCHASED. SUCCESSFUL indicates a successful request. NOT_SUPPORTED indicates this call is not supported. FAILED indicates an unsuccessful request. INVALID_SKU indicates that the SKU originally provided to the Purchase operation is not valid. ALREADY_PURCHASED indicates that the customer already owns the provided SKU.
RequestOutput string requestId A unique ID of an in-app purchasing request.
ResetInput boolean reset Set to true to get a list of all purchases. Set to false to get a list of all purchases made since the last invocation.
SkuInput string sku A SKU is a unique identifier for a purchasable product. A SKU is unique to each developer account with the Amazon Appstore. It is a case-sensitive string containing only alphanumerics, underscores, periods, and dashes. It must be 150 characters or less.
SkusInput List<string> skus A list of SKUs.

Method Detail

This section provides details about the different method calls available to developers.

GetUserData

RequestOutput GetUserData()
Description: Initiates a request to retrieve the user ID and marketplace of the currently logged-in user.
Returns: RequestOutput — See RequestOutput.

Purchase

RequestOutput Purchase(SkuInput input)
Description: Initiates a purchase flow for a product.
Parameters: SkuInput — See SkuInput.
Returns: RequestOutput — See RequestOutput.

GetProductData

RequestOutput GetProductData(SkusInput skus)
Description: Initiates a request to retrieve item data for up to 100 SKUs.
Parameters: SkusInput — See SkusInput.
Returns: RequestOutput — See RequestOutput.

GetPurchaseUpdates

RequestOutput GetPurchaseUpdates(ResetInput input)
Description: Initiates a request to retrieve updates about items the customer has purchased and/or canceled.
Parameters: ResetInput — See ResetInput.
Returns: RequestOutput — See RequestOutput.

NotifyFulfillment

void NotifyFulfillment(NotifyFulfillmentInput input)
Description: Notifies Amazon about the purchase fulfillment.
Parameters: NotifyFulfillmentInput — See NotifyFulfillmentInput.

Event Detail

This section provides details about the different kinds of events that are generated by the system in response to developer-initiated method calls.

GetUserDataResponse

Description: Returns the response from the GetUserData call.
Parameters: GetUserDataResponse — See GetUserDataResponse.

PurchaseResponse

Description: Returns the response from the Purchase call.
Parameters: PurchaseResponse — See PurchaseResponse.

GetProductDataResponse

Description: Returns the response from the GetProductData call.
Parameters: GetProductDataResponse — See GetProductDataResponse.

GetPurchaseUpdatesResponse

Description: Returns the response from the GetPurchaseUpdates call.
Parameters: GetPurchaseUpdatesResponse — See GetPurchaseUpdatesResponse.