Skip to content

Commit 0a87a0b

Browse files
committed
Added new getProduct method and fixed naming of consumePurchases.
1 parent 9ad4ed6 commit 0a87a0b

2 files changed

Lines changed: 35 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ Notes:
3636
* `ArcadePhysics.furthest` now iterates the bodies Set, rather than the RTree, which keeps it working even if the RTree has been disabled.
3737
* `ArcadePhysics.closest` now iterates the bodies Set, rather than the RTree, which keeps it working even if the RTree has been disabled.
3838

39+
### Facebook Instant Games Plugin
40+
41+
* The method `consumePurchases` has been renamed to `consumePurchase` to bring it in-line with the Facebook API.
42+
* `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.
43+
3944
### New Features
4045

4146
* 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.

plugins/fbinstant/src/FacebookInstantGamesPlugin.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,33 @@ var FacebookInstantGamesPlugin = new Class({
14601460
return this;
14611461
},
14621462

1463+
/**
1464+
* Fetches a single Product from the game's product catalog.
1465+
*
1466+
* The product catalog must have been populated using `getCatalog` prior to calling this method.
1467+
*
1468+
* Use this to look-up product details based on a purchase list.
1469+
*
1470+
* @method Phaser.FacebookInstantGamesPlugin#getProduct
1471+
* @since 3.17.0
1472+
*
1473+
* @param {string} productID - The Product ID of the item to get from the catalog.
1474+
*
1475+
* @return {?Product} The Product from the catalog, or `null` if it couldn't be found or the catalog isn't populated.
1476+
*/
1477+
getProduct: function (productID)
1478+
{
1479+
for (var i = 0; i < this.catalog.length; i++)
1480+
{
1481+
if (this.catalog[i].productID === productID)
1482+
{
1483+
return this.catalog[i];
1484+
}
1485+
}
1486+
1487+
return null;
1488+
},
1489+
14631490
/**
14641491
* Begins the purchase flow for a specific product.
14651492
*
@@ -1569,14 +1596,14 @@ var FacebookInstantGamesPlugin = new Class({
15691596
* If they cannot, i.e. it's not in the list of supported APIs, or the request
15701597
* was rejected, it will emit a `consumepurchasefail` event instead.
15711598
*
1572-
* @method Phaser.FacebookInstantGamesPlugin#consumePurchases
1573-
* @since 3.13.0
1599+
* @method Phaser.FacebookInstantGamesPlugin#consumePurchase
1600+
* @since 3.17.0
15741601
*
15751602
* @param {string} purchaseToken - The purchase token of the purchase that should be consumed.
15761603
*
15771604
* @return {this} This Facebook Instant Games Plugin instance.
15781605
*/
1579-
consumePurchases: function (purchaseToken)
1606+
consumePurchase: function (purchaseToken)
15801607
{
15811608
if (!this.paymentsReady)
15821609
{

0 commit comments

Comments
 (0)