Profile PictureMartina Koenig
€5.99

cordova-plugin-inappchase

Add to cart

cordova-plugin-inappchase

€5.99

A lightweight Cordova plugin for in app purchases on iOS/Android. See demo app and blog post.

Looking for maintainers

If you would like to maintain this project, get in touch.

Features

Simple, promise-based API

Support for consumable/non-consumable products and paid/free subscriptions

Support for restoring purchases

Uses well tested native libraries internally - RMStore for iOS and an adjusted com.google.payments for Android

Install

$ cordova plugin add cordova-plugin-inapppurchase

Configuration

iOS

No configuration is necessary.

Android

You must create a manifest.json in your project's www folder with your Android Billing Key:

{ "play_store_key": "<Base64-encoded public key from the Google Play Store>" }

You can get this key from the Google Play Store (under "Services & APIs") after uploading your app.

Setting up and testing purchases

Configuring Cordova in app purchases on iOS and Android

Testing in app purchases

Receipt validation (with nodejs)

Tips for signing and running Cordova apps on Android to test in app purchases locally

API

All functions return a Promise.

Get Products

inAppPurchase.getProducts(productIds)

productIds - an array of product ids

Retrieves a list of full product data from Apple/Google. This function must be called before making purchases.

If successful, the promise resolves to an array of objects. Each object has the following attributes:

productId - SKU / product bundle id (such as 'com.yourapp.prod1')

title - short localized title

description - long localized description

currency - currency of the price (such as 'EUR', 'USD')

price - localized price

priceAsDecimal - price as a decimal

Example:

inAppPurchase

.getProducts(['com.yourapp.prod1', 'com.yourapp.prod2', ...])

.then(function (products) {

console.log(products);

/*

[{ productId: 'com.yourapp.prod1', 'title': '...', description: '...', currency: '...', price: '...', priceAsDecimal: '...' }, ...]

*/

})

.catch(function (err) {

console.log(err);

});

Add to cart
Size
65.9 KB
Copy product URL