npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-impac-inapppayment

v1.0.10

Published

An Cordova plugin for iOS and Android that allows to make in app payments for auto renewable subscriptions.

Downloads

33

Readme

README

Cordova Plugin for iOS and Android to buy InApp payment subscriptions.

Supported platforms

  • Android 6+
  • iOS 11+

Install

To install the cordova plugin perform: 'cordova plugin add cordova-plugin-impac-inapppayment'

Basic

The plugin creates the object window.plugins.impacInappPayment and is accessible after deviceready has been fired.

For iOS make sure to set the product ids. Make sure to do this as early as possible. It would be best to perfom it directly after deviceready.

window.plugins.impacInappPayment.setIds(ids: ["PRODUCT_ID"]);

After setting the ids you have to set the validation configuration for your server. The configurations expects a valid token, the url of the endpoint and a string for the authorizationType this could be "Bearer" or "Basic".

window.plugins.impacInappPayment.setValidation(
    token: "YOUR_AUTHENTICATION_TOKEN"
    url: "URL_ENDPOINT",
    authorizationType: "Bearer or Basic" 
)

The purchase process is complete asynchron, therefor you need to listen to updates with onupdate.

window.plugins.impacInappPayment.onUpdate((result) => {
        //Example
        const json = JSON.parse(result);
        const message = plainToClass(UpdateMessage, json as any);
        message.products;
        message.status;
        message.description;
        message.transactions;
    }, (error) => {
        const json = JSON.parse(error);
        const message = plainToClass(UpdateMessage, json as any);
        message.products;
        message.status;
        message.description;
        message.transactions;
    });

Load Products

Load the available products with getProductList. Make sure you've set the ids before in ios.

window.plugins.impacInappPayment.getProductList(onSuccess, onFail)

function onSuccess(inAppProducts) {

    //Example
    inAppProducts[0].id
    inAppProducts[0].localeCode
    inAppProducts[0].currency
    inAppProducts[0].localizedDescription
    inAppProducts[0].localizedTitle
    inAppProducts[0].price
}

function onFail(error) {
    alert('Failed because: ' + error);
}

Buy product

Before you buy a product make sure the user is entitled to purchase products and the app can communicate with the store.

window.plugins.impacInappPayment.canMakePayments((canMake) => {
    if (canMake) {
        // Purchase products
    }
})

To purchase a product perform buyProduct with the product id. If you want to upgrade or downgrade a subscription on android, make sure to also add the old sku. Otherwise you create a new subscrition.

window.plugins.impacInappPayment.buyProduct(productId, oldSku)

Status of subscriptions

You can refresh the status of your subscriptions manually by calling:

window.plugins.impacInappPayment.refreshStatus()

This will check if there are changes of your subscriptions and will send them for validation to your server. Please note that this mechanism will automatically run daily for android. For iOS this runs only if a subscrition changes.

Manage subscriptions

It's best practice to make is as easy as possible for the users to manage there subscriptions. With the following function you can open the subscrition management of android or ios.

window.plugins.impacInappPayment.manageSubscriptions(onSuccess, onFail)