Developers Manual > SDK Integration > Facebook > Facebook API References in JavaScript > Facebook-logPurchase

.logPurchase(amount, currency, parameters)

Logs real-money in-app purchases through App Events, which is the most common use of event logging. More details at App Events.

Parameters

1
plugin.FacebookAgent.prototype.logPurchase = function(amount, currency, parameters){}
Name Type Required Description
amount float Yes The amount of currency the user spent
currency string No ISO-4217 3-letter code for currency used (e.g. "USD", "EUR", "GBP")
parameters Dictionary No Any parameters needed to describe the event

Example

1
2
3
4
5
var facebook = plugin.FacebookAgent.getInstance();
var floatVal = 9.99;
var parameters = {};
parameters[plugin.FacebookAgent.AppEventParam.SUCCESS] = 1;
facebook.logPurchase(floatVal, "USD", parameters);

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.