@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
-
Add the following library dependency to the
dependenciessection of your package.json file."@amazon-devices/keplerscript-appstore-iap-lib": "~2.13.0", -
In your manifest.toml, add the following privileges.
[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.
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:
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.
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
API Reference
Classes
- PurchasingService — Presents the primary API for interacting with the Amazon Appstore purchasing framework.
Interfaces
- CoinsReward — Contains data about Amazon Coins that may be rewarded to customers after they purchase the associated Product.
- ModifySubscriptionRequest — Input parameters for Modify Subscription request.
- ModifySubscriptionResponse — Represents the result of a call to .
- NotifyFulfillmentRequest — Input parameters for fulfillment status notification request.
- NotifyFulfillmentResponse — Represents the result of a call to .
- Price — Data model for Price
- Product — Represents an in-app product, such as consumable, entitlement, or subscription content. Retrieve
- ProductDataRequest — Input parameters for the requests to get product data.
- ProductDataResponse — Represents the result of a call to .
- Promotion — Represents a promotion configured for a
- PromotionPlan — Represents a promotion plan such as "Introductory promotion with $3.00 weekly for 3 terms",
- PurchaseRequest — Input parameters for purchase request.
- PurchaseResponse — Represents the result of a call to .
- PurchaseUpdatesRequest — Input parameters for purchase updates retrieval request.
- PurchaseUpdatesResponse — Represents the result of a call to .
- Receipt — Represents the purchase of consumable, entitlement, or subscription content, as well as the renewal
- RequestId — Represents the id of any in-app purchasing request.
- UserData — Represents the user information of the customer that is used for in-app purchases.
- UserDataRequest — Input parameters for User data fetching request.
- UserDataResponse — Represents the result of a call to .
- UserProfileAccessResponse — Represents the result of a call to .
Enumerations
- FulfillmentResult — Represents the fulfillment result for an in-app purchase.
- LwaConsentStatus — Supported LWA Consent status.
- ModifySubscriptionResponseCode — Represents the response code for a modify subscription request initiated by .
- NotifyFulfillmentResponseCode — Represents the response code of a fulfillment notification request initiated via
- ProductDataResponseCode — Represents the response code for a product data request initiated via .
- ProductType — Represents the type of product. Can be consumable, entitlement, or subscription content.
- ProrationMode — Subscription proration modes.
- PurchaseResponseCode — Represents the response code for a purchase request initiated via .
- PurchaseUpdatesResponseCode — Represents the response code for a purchase updates request initiated via .
- UserDataResponseCode — Represents the response code for a get user data request initiated by .
- UserProfileAccessConsentStatus — Supported Consent status for user profile access.
- UserProfileAccessResponseCode — Represents the response code for a UserProfileAccess request initiated by .
Functions
- useIapProductData — useIapProductData hook is typically called in the product page for getting and displaying IAP product
- useIapPurchaseUpdates — useIapPurchaseUpdates hook should be called in your main screen component. This hook automatically invokes
- useIapUserData — useIapUserData hook should be called in your main screen component. This hook automatically invokes
Last updated: Jul 22, 2026

