Skip to main content

Quick Reference

This page provides a concise overview of the most-used types and methods in the cordova-plugin-purchase v13+ API. For full details, see the auto-generated API documentation.

Core Entry Point

const { store, ProductType, Platform, LogLevel } = CdvPurchase;
Property / MethodDescription
store.verbositySet log level (LogLevel.DEBUG, INFO, WARNING, ERROR, QUIET)
store.register([...])Register products before initialization
store.initialize([...platforms])Initialize platform adapters and load products
store.update()Refresh product prices and purchase status
store.restorePurchases()Trigger platform restore (iOS non-consumables, subscriptions)
store.when()Register event listeners (returns chainable builder)
store.get(id, platform)Get a registered Product by id and platform
store.owned(product)Check if a product is owned (based on validated receipts)
store.order(offer, additionalData?)Initiate a purchase for an offer
store.getStorefront()Get the user's billing country ({ countryCode })
store.checkSupport(platform, feature)Check if a platform supports a feature
store.productsArray of all loaded Product objects
store.localReceiptsArray of local Receipt objects
store.verifiedReceiptsArray of VerifiedReceipt objects
store.verifiedPurchasesFlattened array of all VerifiedPurchase objects
store.validatorURL string or function for receipt validation
store.validator_privacy_policyArray of privacy categories sent to validator
store.applicationUsernameApp-specific user identifier sent with purchases

Events (via store.when())

store.when()
.approved(transaction => { /* ... */ })
.verified(receipt => { /* ... */ })
.finished(transaction => { /* ... */ })
.productUpdated(product => { /* ... */ })
.receiptUpdated(receipt => { /* ... */ })
.storefrontUpdated(storefront => { /* ... */ })
.unverified(payload => { /* ... */ });
EventCallback ArgumentWhen It Fires
approvedTransactionA purchase has been approved by the store
verifiedVerifiedReceiptReceipt validation succeeded
finishedTransactionA transaction has been acknowledged/consumed
productUpdatedProductProduct metadata (price, title) changed
receiptUpdatedReceiptLocal receipt/transaction state changed
storefrontUpdatedStorefrontUser's billing country changed
unverifiedUnverifiedReceiptReceipt validation failed

Key Types

Product

Represents store metadata for a registered product.

FieldTypeDescription
idstringProduct identifier
platformPlatformWhich store this product belongs to
typeProductTypeCONSUMABLE, NON_CONSUMABLE, PAID_SUBSCRIPTION, NON_RENEWING_SUBSCRIPTION
titlestringLocalized title
descriptionstringLocalized description
offersOffer[]Pricing options for this product
pricingPricingPhaseShortcut to the first pricing phase of the first offer

Offer

A specific pricing option for a product.

FieldTypeDescription
idstringOffer identifier
pricingPhasesPricingPhase[]Phases (trial, intro, regular)
canPurchasebooleanWhether this offer can currently be purchased
order(additionalData?)methodInitiate purchase of this offer

PricingPhase

Details about a pricing period.

FieldTypeDescription
pricestringFormatted price string (e.g., "$4.99")
priceMicrosnumberPrice in micros (e.g., 4990000)
currencystringISO currency code
billingPeriodstringISO 8601 duration (e.g., "P1M" for monthly)
paymentModePaymentModePayAsYouGo, UpFront, FreeTrial
recurrenceModeRecurrenceModeFINITE_RECURRING, INFINITE_RECURRING, NON_RECURRING

Transaction

Represents a purchase attempt from the device SDK.

FieldTypeDescription
transactionIdstringUnique transaction identifier
stateTransactionStateINITIATED, PENDING, APPROVED, FINISHED
products{ id, offerId? }[]Products in this transaction
platformPlatformOriginating platform
purchaseDateDateWhen the purchase was made
verify()methodSend this transaction for receipt validation
finish()methodAcknowledge/consume this transaction

VerifiedReceipt

Result from receipt validation (the trusted source for entitlement).

FieldTypeDescription
collectionVerifiedPurchase[]Validated purchases in this receipt
finish()methodFinish all transactions in this receipt

VerifiedPurchase

Authoritative purchase data from your validator.

FieldTypeDescription
idstringProduct identifier
purchaseDateDateOriginal purchase date
expiryDateDateSubscription expiry (if applicable)
isExpiredbooleanWhether the subscription has expired
renewalIntentstringWhether the user intends to renew
quantitynumberNumber of units (consumables, v13.15+)

Platforms

Enum ValueDescription
Platform.APPLE_APPSTOREApple App Store (iOS, macOS)
Platform.GOOGLE_PLAYGoogle Play Store (Android)
Platform.BRAINTREEBraintree payments
Platform.IAPTIC_JSIaptic/Stripe web payments
Platform.TESTBuilt-in test platform

Typical Flow

const { store, ProductType, Platform } = CdvPurchase;

// 1. Configure
store.verbosity = CdvPurchase.LogLevel.DEBUG;
store.validator = "https://validator.iaptic.com/v1/validate?appName=...";

// 2. Register products
store.register([{
id: 'premium_monthly',
type: ProductType.PAID_SUBSCRIPTION,
platform: Platform.APPLE_APPSTORE
}]);

// 3. Set up event listeners
store.when()
.approved(transaction => transaction.verify())
.verified(receipt => {
// Grant entitlement based on receipt.collection
receipt.finish();
});

// 4. Initialize
await store.initialize([Platform.APPLE_APPSTORE]);

// 5. Purchase (triggered by user action)
const product = store.get('premium_monthly', Platform.APPLE_APPSTORE);
const offer = product?.getOffer();
if (offer) {
const error = await offer.order();
if (error) console.error('Purchase failed:', error.message);
}