as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

@amazon-devices/keplerscript-appstore-iap-lib

In-App Purchasing (IAP) API provides methods for interacting with the Amazon Appstore purchasing framework.

To implement IAP, you must do the following:

Get Started

Setup

  1. Add the following library dependency to the dependencies section of your package.json file.

    Copied to clipboard.

       "@amazon-devices/keplerscript-appstore-iap-lib": "~2.12.10",
       "@amazon-devices/package-manager-lib": "~1.0.0"
    
  2. In your manifest.toml, add the following privileges required to access Ad ID Retriever.

    Copied to clipboard.

    [wants]
    [[wants.service]]
    id = "com.amazon.iap.core.service"
    [[wants.module]]
    id = "/com.amazon.iap.core@IIAPCoreUI"
    
    [needs]
    [[needs.module]]
    id = "/com.amazon.kepler.appstore.iap.purchase.core@IAppstoreIAPPurchaseCoreService"
    

Usage

Purchasing Service

Represents the primary methods for interacting with the Amazon Appstore purchasing framework.

All methods return a response using a Promise.

Copied to clipboard.

public purchase(purchaseRequestParams: IAPTypes.PurchaseParams): Promise<PurchaseResponse>;

For additional information, see PurchasingService.

IAP API usage examples

The following examples show how to use the IAP methods:

Copied to clipboard.

const triggerPurchase = (sku?: string): void => {
      Logger.debug(`Item ${sku} clicked`);
      PurchasingService.purchase({ sku: sku })
            .then((res) => {
               // Handle purchase response.
            })
            .then((user) => {
               // perform operation for user if required.
            })
            .catch((err) => {
               // Handle exceptions if any
            });

      return;
}

The following shows the usage of the getProductData method.

Copied to clipboard.

useEffect(() => { // Validate product SKUs before rendering product screen
      // ...

      // Calling getProductData when the component is rendered.
      PurchasingService.getProductData({ skus: Constants.SKUS })
         .then((res) => {
            const [productData, unavailableSkus] = handleProductDataResponse(res);
         })
         .catch((err) => {
            Logger.error(`Exception while calling getProductData ${err}`);
         });
   }, []);

Releated topics

IAP Overview

Enumerations

Classes

Interfaces

Functions


Last updated: Sep 30, 2025