# cordova-plugin-inapppurchase-simulator

> In-app purchase simulator for testing apps that use cordova-plugin-inapppurchase

Latest version **0.3.1** (published 2019-05-22) · BSD license · 0 weekly downloads

## Install

```sh
npm install cordova-plugin-inapppurchase-simulator
pnpm add cordova-plugin-inapppurchase-simulator
yarn add cordova-plugin-inapppurchase-simulator
bun add cordova-plugin-inapppurchase-simulator
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2019-05-22 |
| First published | 2019-05-18 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Neil Rackett |
| Maintainers | mesmotronic |
| Keywords | ecosystem:cordova, cordova, cordova-ios, cordova-android, cordova-browser, phonegap, ionic, iap, purchase, storekit, ios, android, play, appstore, simulator, sandbox |

## Links

- npm: https://www.npmjs.com/package/cordova-plugin-inapppurchase-simulator
- Repository: https://github.com/neilrackett/cordova-plugin-inapppurchase-simulator
- Homepage: https://github.com/neilrackett/cordova-plugin-inapppurchase-simulator#readme
- Issues: https://github.com/neilrackett/cordova-plugin-inapppurchase-simulator/issues
- npm.io page: https://npm.io/package/cordova-plugin-inapppurchase-simulator

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2019-05-22
- 0.3.0 — 2019-05-21
- 0.2.1 — 2019-05-19
- 0.2.0 — 2019-05-18

## README

In-App Purchase Simulator plugin for Cordova
============================================

This is a simple Cordova plugin that overrides all of the methods of `cordova-plugin-inapppurchase` to enable developers to test their in-app purchase workflow on Android and iOS devices, or in the browser, by creating local sandbox that simulates the plugin's in-app purchase functionality.

The following methods are currently supported:

```javascript
inAppPurchase.getProducts(productIds);
inAppPurchase.buy(productId);
inAppPurchase.subscribe(productId); // Not currently implemented
inAppPurchase.consume(type, receipt, signature);
inAppPurchase.restorePurchases();
inAppPurchase.getReceipt(); // Not currently implemented
```

Don't forget to disable the simulator and test your apps using the official App Store and/or Google Play sandbox environments before going into production!

Installation
------------

```
cordova plugin add cordova-plugin-inapppurchase-simulator
```

Use
---

The quickest way to enable the local sandbox is to add the following command in your `"deviceready"` event handler:

```javascript
inAppPurchaseSimulator.enable();
```

However, to make things more realistic, you can pass an array of products into the `enable` method in the same format as those returned by the original plugin, which will be used to populate `buy` dialogues, etc, for example:

```javascript

let products =
[{
	productId: 'my.awesome.product',
	title: 'My Awesome Product',
	description: 'A super awesome product you definitely want to buy',
	currency: 'GBP',
	price: '£1.23',
	priceAsDecimal: 1.23
}];

inAppPurchaseSimulator.enable(products);
```

Alternatively, if you would like to automatically enable the simulator when you're testing in a browser, simulator or emulator (but not on devices):

```javascript
inAppPurchaseSimulator.autoEnable(); // Accepts same optional "products" parameter as above
```

To clear any test purchases you've made, use:

```javascript
inAppPurchaseSimulator.reset();
```

That's it!

Released under BSD 3-Clause license.

Make a donation
---------------

If you find this project useful, why not buy us a coffee (or as many as you think it's worth)?

[![Make a donation](https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif)](http://bit.ly/2JsLDDE)

---
_Source: https://npm.io/package/cordova-plugin-inapppurchase-simulator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
