1.1.1 • Published 9 years ago

cordova-plugin-inapp-purchase-winphone v1.1.1

Weekly downloads
36
License
-
Repository
-
Last release
9 years ago

Windows Phone 8 and Windows Phone 8.1 In-App Purchase plugin

Allows In-App Purchases to be made from Phonegap/cordova.

Adding the Plugin to your project

Visual Studio 2015

Adding the plugin to your project by adding zip file as plugin to your Visual Studio 2015 project

Phonegap Build

Add plugin to config.xml:

<gap:plugin name="cordova-plugin-inapp-purchase-winphone" source="npm" />

or for Windows Phone only:

<gap:plugin name="cordova-plugin-inapp-purchase-winphone" gap:platform="winphone" source="npm" />

Using the plugin

You can read Windows Phone 8 In-App purchase MSDN.

This plugin use the same method signature as cordova-plugin-appleiap cordova plugin to let you easily port your iOS and Android app to Windows Phone

The plugin creates the object window.InAppPurchaseManager with the following methods:

requestProductData(productId, successCallback, failCallback)

makePurchase(productId)

restoreCompletedTransactions()

You can also register the following callbacks:

window.InAppPurchaseManager.onPurchased = function(transactionIdentifier, productId, transactionReceipt) {}

window.InAppPurchaseManager.onFulFilled = function(productId) {}

window.InAppPurchaseManager.onRestored = function(productId) {}

window.InAppPurchaseManager.onFailed = function(errorCode, errorText);

To retrieve price of inapp purchase, you need to call requestProductData

A basic usage example is below:

	 // transactionIdentifier is null for now
	window.InAppPurchaseManager.onPurchased = function(transactionIdentifier, productId, transactionReceipt) {
		console.log('purchased: ' + productId);
		/* Give coins etc */

		window.InAppPurchaseManager.reportProductFulfillment(productId); // If consumable
	}

	window.InAppPurchaseManager.onRestored = function(productId) {
		console.log('restored: ' + productId);
	}

	window.InAppPurchaseManager.onFailed = function(errno, errtext) {
		console.log('failed: ' + errtext);
	}

	// title and description are null for now
	window.InAppPurchaseManager.requestProductData("com.example.test", function(productId, title, description, price) {
    		console.log("productId: " + productId + " title: " + title + " description: " + description + " price: " + price);
    		window.plugins.InAppPurchaseManager.makePurchase(productId, 1);
    	}, function(id) {
    		console.log("Invalid product id: " + id);
	    }
	);

To start a purchase you just have to call:

window.InAppPurchaseManager.makePurchase("com.myapp.mypurchase");

Licence

The MIT License

Copyright (c) 2015 RONCE Wandrille

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1.1.1

9 years ago

1.1.0

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago