• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Get IAP Price From Store

C

Charzendat

Guest
Hi all,
so I've been able to build IAPs into my game and they are working fine for both Android and iOS. However I want to be able to pull the price from the store too. I know it has something to do with iap_ev_product but I am not sure how to use it or what needs to be done. Does anyone have some advice please?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I'm pretty sure you can't actually do this... The iap_activate function is only for you to create and activate an IAP with the details you give and the only important thing there is really setting up the product ID string... all the rest is simply an easy way for you to store information about the activated IAP so that you can then display it in game with the function iap_product_details.
 

DJ Coco

Member
Hey, do you still need help with this? Been struggling a bit myself but it's actually fairly simple if you read all the IAP stuff in the manual carefully.

Once you activate your IAP list using iap_activate an IAP event is triggered for each individual purchase.
In the IAP event you check if iap_data[? "type"] == iap_ev_product.

iap_ev_product means that the IAP event was triggered because the IAP product was just activated. Now, that we know that this is what triggered the event we can proceed to pull the price from the store:

You now use iap_product_details(iap_data[? "index"], map).
iap_data[? "index"] contains a unique ID for the product you just activated and by passing it to iap_product_details it now knows for which product to get the information you need (including the price). "map" is just a ds_map you created beforehand. Just leave it empty - it needs to be created because iap_product_details fills the ds_map with the information (Don't forget to destroy it later when you saved the price and don't need the map anymore!)

So, now you have your price inside map[? "price"].

If you wonder why I keep writing stuff like x[? "y"], it's just a shorter way of saying ds_map_find_value(x, "y"). (See accessors in the manual)

I hope this solves your issue!
 
S

signal

Guest
@DJ Coco Do you know if it pulls the price in the user's currency? If so, you'd have to add the various currency symbols to your font, no? I'm debating whether that's worth the benefit of displaying the price in-app.
 

DJ Coco

Member
@DJ Coco Do you know if it pulls the price in the user's currency? If so, you'd have to add the various currency symbols to your font, no? I'm debating whether that's worth the benefit of displaying the price in-app.
Yeah, it pulls the price in the user's currency, so if you're using a custom font you'd have to ensure you got all the needed symbols ready.
 
Top