Tutorial on making in-game shop system

Sup my dudes.

This is sort of a request but I think this is needed.

While there is a guide on how to implement IAP:
https://docs.coronalabs.com/guide/monetization/IAP/index.html

There is no guide in making an actual in game shop.

I have looked into the forums and there is no clear way of doing it.

I think there should be a small tutorial in making an in-game shop system.

It would help a lot of new/basic coders like me and countless others.

Let me know you guys opinions and like this post so Corona can make it happen.

Thanks bros and stay frosty.

We have a sample app that implements a shop. It’s in the Corona/SampleCode/Monetization/InAppPurchase folder.  There are many different ways you might want to implement a shop from simply providing a few UI buttons to buy specific items via IAP to a full-blown in-game economy.  Maybe your shop lets you buy different weapons and armor and doesn’t use IAP at all and you have an IAP screen to buy gems or coins to supplement those earned during play.

The scope of such a tutorial would either be too huge to tackle in a single tutorial or too simple and just say stick some buttons on the screen and tapping them calls store.purchase(). 

Do you have specific questions or goals for what you want to implement?

Rob

“stay frosty” means what exactly?

as Rob said the implementation of IAPs in your game will need to fit your game and only you know that.

oh wow I completely forgot about that part of Corona. Thanks I will take a look.

stay frosty = stay cool

https://www.urbandictionary.com/define.php?term=stay%20frosty

Hi TheBusey,

There is the project I did dedicated  especially for the beginners in Corona SDK called “OOP Samples for Corona SDK”. I wrote about that at this forum

in “New a New Apps / Works in Progress” section here

https://forums.coronalabs.com/topic/68516-new-free-edu-app-oop-samples-for-corona-sdk/

This is app inspired by original Corona SDK samples, rewritten as object oriented programming code.

What you are looking for you can find on my GIT https://github.com/sebastianlis/OOP-Samples-for-Corona-SDK  exactly here:

classes/samples/Monetization folder of this project in GitHub:

https://github.com/sebastianlis/OOP-Samples-for-Corona-SDK/blob/master/classes/samples/Monetization/InAppPurchase.lua

These 141 lines of code show you a simple in app-purchase action, when you can buy the three types of coffee - small, strong or for all night.

For example in line  84 purchased item  productID is checked and the final code is executed in anonymous function with some delay.

timer.performWithDelay(1000, function() store.consumePurchase( “com.yourcompany.coffeesmall”, private.transactionCallback) end )

If you have a consumable product the last thing to do is :

store.consumePurchase( “com.yourcompany.coffeesmall”, private.transactionCallback)

If it’s not a consumable you don’t need to do that.

Now the most important part from the user perspective.

The user wants to see the result of his purchase for e.g. number of the coins, new weapon enabled, noAds, more lives, weapon upgrades …

So the final code in line 84 with this user issue should looks like this:

timer.performWithDelay(1000,

function()

store.consumePurchase( “com.yourcompany.coffeesmall”, private.transactionCallback)

ShopManager.addFiveCoins()

end )

or

timer.performWithDelay(1000,

function()

store.consumePurchase( “com.yourcompany.coffeesmall”, private.transactionCallback)

ShopManager.enableSuperLaserWeapon()

end )

or

timer.performWithDelay(1000,

function()

store.consumePurchase( “com.yourcompany.coffeesmall”, private.transactionCallback)

ShopManager.noAds()

end )

or

timer.performWithDelay(1000,

function()

store.consumePurchase( “com.yourcompany.coffeesmall”, private.transactionCallback)

ShopManager.upgradeLaserWeapon(25)

end )

Where ShopManager is a singleton object. If you don’t like this way you can just put a simple function:

addFiveCoins()

enableSuperLaserWeapon()

noAds()

upgradeLaserWeapon(25)

called from the same file.

By the way. Normally timer.performWithDelay(1000 ……… ) would not be needed.

It’s a hack taken from the forum (I think Rob mentioned  that).

No delay caused problem with the transaction. To be specific as I remember the window for a purchase action didn’t  appear. Using  this hack there is no problem.

——————————— Quotation ————————————

While there is a guide on how to implement IAP:

https://docs.coronalabs.com/guide/monetization/IAP/index.html

There is no guide in making an actual in game shop.

I have looked into the forums and there is no clear way of doing it.

I think there should be a small tutorial in making an in-game shop system.

It would help a lot of new/basic coders like me and countless others.

—————————————————————————————

I’ve struggled with that before. This is the main reason why I created  OOP Samples. Hope it will help you.

Take care

Sebastian

   

We have a sample app that implements a shop. It’s in the Corona/SampleCode/Monetization/InAppPurchase folder.  There are many different ways you might want to implement a shop from simply providing a few UI buttons to buy specific items via IAP to a full-blown in-game economy.  Maybe your shop lets you buy different weapons and armor and doesn’t use IAP at all and you have an IAP screen to buy gems or coins to supplement those earned during play.

The scope of such a tutorial would either be too huge to tackle in a single tutorial or too simple and just say stick some buttons on the screen and tapping them calls store.purchase(). 

Do you have specific questions or goals for what you want to implement?

Rob

“stay frosty” means what exactly?

as Rob said the implementation of IAPs in your game will need to fit your game and only you know that.

oh wow I completely forgot about that part of Corona. Thanks I will take a look.

stay frosty = stay cool

https://www.urbandictionary.com/define.php?term=stay%20frosty

Hi TheBusey,

There is the project I did dedicated  especially for the beginners in Corona SDK called “OOP Samples for Corona SDK”. I wrote about that at this forum

in “New a New Apps / Works in Progress” section here

https://forums.coronalabs.com/topic/68516-new-free-edu-app-oop-samples-for-corona-sdk/

This is app inspired by original Corona SDK samples, rewritten as object oriented programming code.

What you are looking for you can find on my GIT https://github.com/sebastianlis/OOP-Samples-for-Corona-SDK  exactly here:

classes/samples/Monetization folder of this project in GitHub:

https://github.com/sebastianlis/OOP-Samples-for-Corona-SDK/blob/master/classes/samples/Monetization/InAppPurchase.lua

These 141 lines of code show you a simple in app-purchase action, when you can buy the three types of coffee - small, strong or for all night.

For example in line  84 purchased item  productID is checked and the final code is executed in anonymous function with some delay.

timer.performWithDelay(1000, function() store.consumePurchase( “com.yourcompany.coffeesmall”, private.transactionCallback) end )

If you have a consumable product the last thing to do is :

store.consumePurchase( “com.yourcompany.coffeesmall”, private.transactionCallback)

If it’s not a consumable you don’t need to do that.

Now the most important part from the user perspective.

The user wants to see the result of his purchase for e.g. number of the coins, new weapon enabled, noAds, more lives, weapon upgrades …

So the final code in line 84 with this user issue should looks like this:

timer.performWithDelay(1000,

function()

store.consumePurchase( “com.yourcompany.coffeesmall”, private.transactionCallback)

ShopManager.addFiveCoins()

end )

or

timer.performWithDelay(1000,

function()

store.consumePurchase( “com.yourcompany.coffeesmall”, private.transactionCallback)

ShopManager.enableSuperLaserWeapon()

end )

or

timer.performWithDelay(1000,

function()

store.consumePurchase( “com.yourcompany.coffeesmall”, private.transactionCallback)

ShopManager.noAds()

end )

or

timer.performWithDelay(1000,

function()

store.consumePurchase( “com.yourcompany.coffeesmall”, private.transactionCallback)

ShopManager.upgradeLaserWeapon(25)

end )

Where ShopManager is a singleton object. If you don’t like this way you can just put a simple function:

addFiveCoins()

enableSuperLaserWeapon()

noAds()

upgradeLaserWeapon(25)

called from the same file.

By the way. Normally timer.performWithDelay(1000 ……… ) would not be needed.

It’s a hack taken from the forum (I think Rob mentioned  that).

No delay caused problem with the transaction. To be specific as I remember the window for a purchase action didn’t  appear. Using  this hack there is no problem.

——————————— Quotation ————————————

While there is a guide on how to implement IAP:

https://docs.coronalabs.com/guide/monetization/IAP/index.html

There is no guide in making an actual in game shop.

I have looked into the forums and there is no clear way of doing it.

I think there should be a small tutorial in making an in-game shop system.

It would help a lot of new/basic coders like me and countless others.

—————————————————————————————

I’ve struggled with that before. This is the main reason why I created  OOP Samples. Hope it will help you.

Take care

Sebastian

   

Newbie here.

How do you set the price for each product (consumable)?

I can’t find any examples on how to set the price (actual real money price) in the iap tutorials, :unsure:

even in Sebastian’s iap sample code.

Say for example, I want to set the price of “50 foods” to $0.9.

Also how will the price convert to different currencies?

Thanks.

In-App purchases are set either in Apple’s App connect portal (formerly iTunes Connect) or the Google Play developer’s console. You set the price and description there, provide localizations to other languages and they calculate the local price. (Same for Amazon) When you call the various store’s .loadProducts() method, you will get a list of the items, with their local descriptions and prices that you can use to draw the various text bits on your display for your users.

Rob

@jasson.archimedes, can you clarify more about what you’re talking about? 

What information are you seeking?

Rob

Newbie here.

How do you set the price for each product (consumable)?

I can’t find any examples on how to set the price (actual real money price) in the iap tutorials, :unsure:

even in Sebastian’s iap sample code.

Say for example, I want to set the price of “50 foods” to $0.9.

Also how will the price convert to different currencies?

Thanks.

In-App purchases are set either in Apple’s App connect portal (formerly iTunes Connect) or the Google Play developer’s console. You set the price and description there, provide localizations to other languages and they calculate the local price. (Same for Amazon) When you call the various store’s .loadProducts() method, you will get a list of the items, with their local descriptions and prices that you can use to draw the various text bits on your display for your users.

Rob

@jasson.archimedes, can you clarify more about what you’re talking about? 

What information are you seeking?

Rob