A capacitor plugin which simplifies subscription handling - implementing StoreKit 2 and Google Billing 5
npm install *to-be-changed*
ionic cap syncgetProductDetails(...)purchaseProduct(...)getCurrentEntitlements()getLatestTransaction(...)manageSubscriptions(...)setGoogleVerificationDetails(...)addListener('ANDROID-PURCHASE-RESPONSE', ...)- Interfaces
- Type Aliases
getProductDetails(options: { productIdentifier: string; }) => Promise<ProductDetailsResponse>Receives a product ID and returns the product details
| Param | Type |
|---|---|
options |
{ productIdentifier: string; } |
Returns: Promise<ProductDetailsResponse>
purchaseProduct(options: { productIdentifier: string; }) => Promise<PurchaseProductResponse>Receives the product ID which the user wants to purchase and returns the transaction ID
| Param | Type |
|---|---|
options |
{ productIdentifier: string; } |
Returns: Promise<PurchaseProductResponse>
getCurrentEntitlements() => Promise<CurrentEntitlementsResponse>Returns: Promise<CurrentEntitlementsResponse>
getLatestTransaction(options: { productIdentifier: string; }) => Promise<LatestTransactionResponse>| Param | Type |
|---|---|
options |
{ productIdentifier: string; } |
Returns: Promise<LatestTransactionResponse>
manageSubscriptions(options: { productIdentifier: string; }) => void| Param | Type |
|---|---|
options |
{ productIdentifier: string; } |
setGoogleVerificationDetails(options: { googleVerifyEndpoint: string; productId: string; }) => void| Param | Type |
|---|---|
options |
{ googleVerifyEndpoint: string; productId: string; } |
addListener(eventName: 'ANDROID-PURCHASE-RESPONSE', listenerFunc: (response: AndroidPurchasedTrigger) => void) => Promise<PluginListenerHandle> & PluginListenerHandle| Param | Type |
|---|---|
eventName |
'ANDROID-PURCHASE-RESPONSE' |
listenerFunc |
(response: AndroidPurchasedTrigger) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
| Prop | Type |
|---|---|
responseCode |
ProductDetailsResponseCode |
responseMessage |
ProductDetailsResponseMessage |
data |
Product |
| Prop | Type |
|---|---|
productIdentifier |
string |
price |
string |
displayName |
string |
description |
string |
| Prop | Type |
|---|---|
responseCode |
0 | 1 | 2 | 5 | 4 | 3 | -1 |
responseMessage |
'Incompatible with web' | 'Could not find a product matching the given productIdentifier' | 'Successfully purchased product' | 'Product seems to have been purchased but the transaction failed verification' | 'User closed the native popover before purchasing' | 'Product request made but is currently pending - likely due to parental restrictions' | 'An unknown error occurred whilst in the purchasing process' | 'Successfully opened native popover' | 'Failed to open native popover' |
| Prop | Type |
|---|---|
responseCode |
CurrentEntitlementsResponseCode |
responseMessage |
CurrentEntitlementsResponseMessage |
data |
Transaction[] |
| Prop | Type |
|---|---|
productIdentifier |
string |
expiryDate |
string |
originalStartDate |
string |
| Prop | Type |
|---|---|
responseCode |
LatestTransactionResponseCode |
responseMessage |
LatestTransactionResponseMessage |
data |
Transaction |
| Prop | Type |
|---|---|
remove |
() => Promise<void> |
| Prop | Type |
|---|---|
fired |
boolean |
-1 | 0 | 1
"Incompatible with web" | "Successfully found the product details for given productIdentifier" | "Could not find a product matching the given productIdentifier"
-1 | 0 | 1 | 2 | 3 | 4 | 5
-1 | 0 | 1
"Incompatible with web" | "Successfully purchased product" | "Could not find a product matching the given productIdentifier" | "Product seems to have been purchased but the transaction failed verification" | "User closed the native popover before purchasing" | "Product request made but is currently pending - likely due to parental restrictions" | "An unknown error occurred whilst in the purchasing process"
"Incompatible with web" | "Successfully opened native popover" | "Failed to open native popover"
-1 | 0 | 1 | 2
"Incompatible with web" | "Successfully found all entitlements across all product types" | "No entitlements were found" | "Unknown problem trying to retrieve entitlements" |
-1 | 0 | 1 | 2 | 3
"Incompatible with web" | "Successfully found the latest transaction matching given productIdentifier" | "Could not find a product matching the given productIdentifier" | "No transaction for given productIdentifier, or it could not be verified" | "Unknown problem trying to retrieve latest transaction"