how to set renpy game to open the rest of the story after in app purchase from google play ?

Forum organization and occasional community-building.
Forum rules
Questions about Ren'Py should go in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
mr-kumar-abhishek
Newbie
Posts: 7
Joined: Sun Feb 26, 2023 1:44 pm
Contact:

how to set renpy game to open the rest of the story after in app purchase from google play ?

#1 Post by mr-kumar-abhishek »

Hi was wondering how to set renpy to open the rest of story of after in app purchase from google play ?

I searched around the answer but I couldn't find one. I only found this answer.
To implement in-app purchases in your Ren'Py project, you will need to use the Google Play Billing Library, which is a set of APIs that allows you to integrate Google Play's billing system into your app. You will also need to create a product list in the Google Play Console, which defines the items that you want to sell in your app.

One possible way to open the rest of the story after an in-app purchase is to use a variable that stores the purchase status of the item, and then check that variable before jumping to the next label. For example, you could do something like this:

Code: Select all

# Define a variable that stores the purchase status of the item
default story_unlocked = False

# Use the Google Play Billing Library to initiate a purchase flow
# This is a simplified example, you will need to follow the documentation for more details
$ result = google_play_billing.purchase("story_item")

# Check the result of the purchase flow
if result == "success":
    # Set the variable to True if the purchase was successful
    $ story_unlocked = True
    # Show a message to the player
    "Thank you for your purchase! You can now enjoy the rest of the story."
else:
    # Show an error message to the player
    "Sorry, something went wrong. Please try again later."

# Check the variable before jumping to the next label
if story_unlocked == True:
    # Jump to the label that contains the rest of the story
    jump story_label
else:
    # Show a message to the player that prompts them to buy the item
    "You need to buy this item to unlock the rest of the story. Do you want to buy it now?"
    menu:
        "Yes":
            # Repeat the purchase flow
            $ result = google_play_billing.purchase("story_item")
            # Check the result and jump accordingly
            if result == "success":
                $ story_unlocked = True
                "Thank you for your purchase! You can now enjoy the rest of the story."
                jump story_label
            else:
                "Sorry, something went wrong. Please try again later."
        "No":
            # Return to the previous label or menu
            return
But when I go to in app purchases in google play console using following video:



I get a message "To add in-app products, you need to add the BILLING permission to your APK" in google play console. How should I enable that ?
Last edited by mr-kumar-abhishek on Mon Sep 18, 2023 11:15 pm, edited 1 time in total.

mr-kumar-abhishek
Newbie
Posts: 7
Joined: Sun Feb 26, 2023 1:44 pm
Contact:

Re: how to set renpy game to open the rest of the story after in app purchase from google play ?

#2 Post by mr-kumar-abhishek »

The documentation says something different https://www.renpy.org/doc/html/iap.html
It says to use iap object? So how will I use it to achieve this?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: how to set renpy game to open the rest of the story after in app purchase from google play ?

#3 Post by PyTom »

You will get the billing permission added automatically when you build an apk (or more likely an aab) with the Google Play store enabled.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: Semrush [Bot]