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

iab-myket-reactnative

v1.0.10

Published

ReactNative In-App Billing SDK for Myket App Store

Downloads

32

Readme

Myket IAB React native

React native in app billing SDK for React native.

Dependency

npm i iab-myket-reactnative

Configuration

To activate Myket reactNative Billing SDK, open the android directory located in your root project and add this piece of code to app level build.gradle file:

def marketApplicationId = "ir.mservices.market"
def marketBindAddress = "ir.mservices.market.InAppBillingService.BIND"
manifestPlaceholders = [marketApplicationId: "${marketApplicationId}",
marketBindAddress : "${marketBindAddress}",
marketPermission : "${marketApplicationId}.BILLING"]

if your project doesn't have and android directory, make one using the command below:

expo eject

Note that application must have the same application Id as you definded in the Myket panel.

Functional Components

import  myket  from  'myket-iab-reactnative';

function MyComponent() {
  const myketInstance = useMyket(myInAppBillingKey);
  // ...
  const someHandler = async () => {
    const inventory = await myket.queryPurchaseProduct(true, productIds);
    console.log(JSON.JSON.stringify(inventory));
  };
  // ...
}

Class Components

import  myket  from  'myket-iab-reactnative';
class  App extends Component 
	componentDidMount() {
		this.didMount = true;
			myket.connect(base64RSA).catch((error) => {
				/**
				* myket is not installed or RSA public key is null or empty
				*/

				this.log(error)
		    }).then(this.retrieverProducts);

	}
	componentWillUnmount() {
		myket.disconnect().catch(() =>  this.log);
	}
}

Complete Example

For better understanding see the Trivial drive app in here which provided a complete react-native implementation.

API Documentation

connect/disconnect

  • Connect and initialize myket billing , take RSA public key as a parameter, find more information about public key here.
  • disconnect will release the resources occupied by the SDK and mhelper.

enableDebugging(isEnable:boolean):void

  • Enable Debugging in Android logcat.

purchaseProduct( sku:Boolean , developerPayload :String ):Promise <Purchase>

  • Launches an Activity and shows the myket billing dialog.

  • developerPayload : Generate a string and pass it to the function and compare to the response of purchase for security reasons.

  • sku : The SKU of the item that user intended to buy.

consumePurchase( purchase ): Promise<Void>

  • Consume a Purchase, the result of purchasing the product must be consumed by the application.

queryPurchaseProduct(querySkuDetails,moreSku):Promise <Inventory >

  • query inventory for details of sku's and previously bought items that hasn't consumed. for some reasons , user may bought a SKU but hasn't consumed by the application , make sure you call consumed purchases immediately after calling queryPurchaseProduct.
  • moreSkus : list of array to define wich skuItem's details need to get fetched.
  • querySkuDetails : pass true if you want to get the sku details,pass false if you want to avoid calling another service.
export  type  Inventory = {
	allProducts: SkuDetails[];
	allPurchases: Purchase[];
};

export  type  SkuDetails = {
	itemType: string;
	sku: string;
	type: string;
	price: string;
	title: string;
	description: string;
	json: string;
};

export  type  Purchase = {
	itemType: string;
	orderId: string;
	packageName: string;
	sku: string;
	purchaseTime: string;
	purchaseState: number;
	developerPayload: string;
	token: string;
	originalJson: string;
	signature: string;
};

Error schema

the following is the error schema returned from almost every API of the SDK; in case you want to handle errors for more customized scenario :

{
	"message":"String"
	"responseCode":"Int"
}

License

MIT