Added new getProduct method and fixed naming of consumePurchases.

This commit is contained in:
Richard Davey 2019-03-13 12:37:01 +00:00
parent 9ad4ed6d8f
commit 0a87a0bdef
2 changed files with 35 additions and 3 deletions

View file

@ -36,6 +36,11 @@ Notes:
* `ArcadePhysics.furthest` now iterates the bodies Set, rather than the RTree, which keeps it working even if the RTree has been disabled.
* `ArcadePhysics.closest` now iterates the bodies Set, rather than the RTree, which keeps it working even if the RTree has been disabled.
### Facebook Instant Games Plugin
* The method `consumePurchases` has been renamed to `consumePurchase` to bring it in-line with the Facebook API.
* `getProduct` is a new method that will return a single Product from the product catalog based on the given Product ID. You can use this to look-up product details based on a purchase list.
### New Features
* There is a new Game Config property `input.windowEvents` which is true by default. It controls if Phaser will listen for any input events on the Window. If you disable this, Phaser will stop being able to emit events like `POINTER_UP_OUTSIDE`, or be aware of anything that happens outside of the Canvas re: input.

View file

@ -1460,6 +1460,33 @@ var FacebookInstantGamesPlugin = new Class({
return this;
},
/**
* Fetches a single Product from the game's product catalog.
*
* The product catalog must have been populated using `getCatalog` prior to calling this method.
*
* Use this to look-up product details based on a purchase list.
*
* @method Phaser.FacebookInstantGamesPlugin#getProduct
* @since 3.17.0
*
* @param {string} productID - The Product ID of the item to get from the catalog.
*
* @return {?Product} The Product from the catalog, or `null` if it couldn't be found or the catalog isn't populated.
*/
getProduct: function (productID)
{
for (var i = 0; i < this.catalog.length; i++)
{
if (this.catalog[i].productID === productID)
{
return this.catalog[i];
}
}
return null;
},
/**
* Begins the purchase flow for a specific product.
*
@ -1569,14 +1596,14 @@ var FacebookInstantGamesPlugin = new Class({
* If they cannot, i.e. it's not in the list of supported APIs, or the request
* was rejected, it will emit a `consumepurchasefail` event instead.
*
* @method Phaser.FacebookInstantGamesPlugin#consumePurchases
* @since 3.13.0
* @method Phaser.FacebookInstantGamesPlugin#consumePurchase
* @since 3.17.0
*
* @param {string} purchaseToken - The purchase token of the purchase that should be consumed.
*
* @return {this} This Facebook Instant Games Plugin instance.
*/
consumePurchases: function (purchaseToken)
consumePurchase: function (purchaseToken)
{
if (!this.paymentsReady)
{