Sign In Register

How can we help you today?

Start a new topic
Answered

Buying Virtual Currency

Hello,


I'm attempting to create a Virtual Good which gives the user some currency. I've specified it to be a Currency Pack. However a BuyVirtualGoodsRequest says I don't have enough currency...


This would be done via an app store purchase in production, but unfortunately my client has yet to provide me with his developer account details so I can start working on that side of things.


I attempted to test the iOSBuyGoodsRequest using some example receipt JSON I found online, but I get the following error:

"Can not deserialize instance of String out of START_OBJECT token"




{

"@class": ".IOSBuyGoodsRequest",

"receipt": {

"is_trial_period": "false",

"purchase_date_pst": "2014-01-21 08:15:21 America/Los_Angeles",

"product_id": "com.blah.test.item",

"original_transaction_id": "1000000098953824",

"original_purchase_date_pst": "2014-01-20 11:03:05 America/Los_Angeles",

"original_purchase_date": "2014-01-20 19:03:05 Etc/GMT",

"original_purchase_date_ms": "1390244585000",

"purchase_date": "2014-01-21 16:15:21 Etc/GMT",

"purchase_date_ms": "1390320921000",

"transaction_id": "1000000098953824",

"quantity": "1"

},

"subUnitPrice": "69",

"currencyCode": "GBP",

"requestId": "1409834504271"

}


Best Answer

Bryan, please see response to your other post.  I had a quick look at your set up and you dont need to define the virtual goods.  You can simply make currency 1 coins and currency 2 the XP.  I have given you sample code to credit players with these currencies.


Let me know if you need any further help with this and I will mock something up for you.


Regards,


John.


Lee,


Sorry for the delay in answering this.  Anyway, I have had a look at your configuration.  It seems you have now modified the 'price' of the 100k currency pack to be -10000 in Currency 1.  Is this an intentional work around?  When you execute BuyVirtualGoodsRequest this now credits the player with 10000.  


Let me know.  There are other ways to credit players with currency. 


John.

Hey John, 


"There are other ways to credit players with currency."


Could you please provide some examples?

Answer

Bryan, please see response to your other post.  I had a quick look at your set up and you dont need to define the virtual goods.  You can simply make currency 1 coins and currency 2 the XP.  I have given you sample code to credit players with these currencies.


Let me know if you need any further help with this and I will mock something up for you.


Regards,


John.

Got it, thanks.

Hello, so how to credit player with currency? :)

Hi Mohamad,


You can credit a player in Cloud Code by using the following,

 

// you can credit any of the 1-6 currencies, currency 1 is credited here, the reason field is optional
Spark.getPlayer().credit1(10, "Reason");

     

You can read more about this here.


Thanks,

Liam



1 person likes this

Thank you :)

Sorry i meant how to credit user using virtual good ( which will be purchased with real money)

Hi Mohamad,


To do this you would set up a Virtual Good as a Currency Pack. This good would then be linked to an external store by Product ID (these can be set in the VG config). So when the user buys this Virtual Good Currency Pack they are charged the price from the external store. The values in currencies 1-6 are what is awarded to the player when the pack is successfully purchased. Does that make sense ? You can read more about this here.


Thanks,

Liam

Yes got you....thanks :)

Login to post a comment