If I did not write correctly, or not exactly - please correct meI decided to make an alternative to monetization through advertising (AdMob). Installed even easier AdMob.
On iOS is done similarly, just do not need to copy the application key. More I will not write, because there is no iPhone.
1) We purchase a Google Play Developer account, if it does not already exist.
2) In the Google Play Developer Console, on the "All Apps" tab, click "New Application".
3) Enter the name of the game and click "Create".
4) We are thrown to the window of filling in the data about the future game, but we are only interested in the "Services and API" tab on the left side of the screen.
5) Copy the application key from the "Licensing and Selling Content" section.
6) Open your options.rpy and uncomment the line define build.google_play_key = "" and insert the copied key between the quotes. CHECK THAT THERE IS NO SPACE IN THE COPYED KEY!
7) Now you can insert the code into script.rpy. Before starting, we register the purchase as follows:unlock_lvl is the identifier of the purchase, the name is coming up yourselfCode: Select all
init: define unlock_lvl = iap.register(product = "unlock_lvl", identifier = "ru.chislov.mygame", google = "My Game",)
In the identifier, respectively, your package name
google is the name of the game, if you put None, then the name of the game will be the name of the package.
Then we do the buttons "Buy level" and "Restore purchase". I usually do it through imagebutton, you can at least through the menu or via imagemap - there is no difference:9) Next, we check whether the game was purchased earlier or not. In the place where it is necessary to open a new level, prescribe:Code: Select all
screen billing: imagebutton xalign 0.2 yalign 0.3: idle ("images/idle_billing.png") hover ("images/hover_billing.png") action Jump("label_billing") screen restore: imagebutton xalign 0.2 yalign 0.4: idle ("images/idle_restore.png") hover ("images/hover_restore.png") action Jump("label_restore")
10) If the game is not purchased, then we transfer the user to label_billing or label_restore, if he bought the previous level:Code: Select all
if iap.has_purchased ("unlock_lvl"): jump continue_game else: show screen billing show screen restore "To continue the game you need to buy a level or restore the purchase" $ renpy.pause (hard = True)
11) Now re-configure the project. Open RenPy - Android - Customize. MANDATORY: On the question you like support in-app purchasing choose Google Play and allow access the internet choose Yes.Code: Select all
label label_billing: $ iap.purchase ("unlock_lvl") "If the payment is successful, the game will continue." Click to continue " if iap.has_purchased ("unlock_lvl"): "Thank you for purchasing the level! Continue the game" jump continue_game else: "Payment canceled" label label_restore: $ iap.restore ("unlock_lvl") "If the purchase is restored, the game will continue." Click to continue. " if iap.has_purchased ("unlock_lvl"): "The purchase was restored! We continue to play" jump continue_game else: "The purchase was not reinstated."
12) We collect the project and fill apk in the developer console. After downloading apk, go to the tab on the left "Content for sale." Specify: product type - subscription, product ID - unlock_lvl (without quotes) and click "Continue". Next, specify the description, price, etc. - I think you will understand.
All is ready! We can rejoice, now our game is monetized and will bring you revenue (I hope)
That's all, thank you for your attention.
Author gaida: I (https://vk.com/chislov_vladimir)
References: https://www.renpy.org/doc/html/iap.html
ios
viewtopic.php?f=8&t=35847&p=398158&hili ... ap#p398158