Tuesday, 9 July 2013

Multi - In-App Purchase API


In mobile games nowadays, players tend to upgrade or customize their character with the spending of gold coins they collect through gameplay or money. I wanted to make it super-easy for you to be able to introduce your own virtual economy to your games by adding an item shop api to the 3d multiplayer games maker - Multi.

If you add the following line of code
 new SceneItemShop( "Get more coins", "topup_1", true, 1000, 10, 10, function (type, itemCode, value)
 {
      alert( type + " " + value );
 }); 

This screen will appear, asking for either a Facebook like, an in-app purchase or a tweet for payment.

The function SceneItemShop takes in 7 parameters.
title,
itemCode,
isConsumable,
inAppPurhcaseValue,
facebookLikeValue,
tweetValue,
onCompleteFunctionCallback

Allowing you to customise the in-app purchase id, type, value and the values for tweeting and liking (or completely remove them).

Once a payment is made, the function callback is triggered with the type of payment ("facebook","twitter","in-app"), and the itemCode and value you specified for it.

In my use case for World of Fighters, I used that value to top up the coins balance of the player.
new SceneItemShop( "Get more coins", "topup_1", true, 1000, 10, 10, function (type, itemCode, value)
{
      WOF.AddCoins( value, "Thanks +" + value );
}); 

And that's it, the idea is that if you publish the games via the app stores yourself you can use your own custom in-app purchase ids. Or, if you publish the games with Multi, you can use our generic ids and the revenue once cleared will be funneled to your accounts.

Ash :)

No comments:

Post a Comment