-
Notifications
You must be signed in to change notification settings - Fork 66
added: Initial part of the GooglePlay consumable support #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds initial support for Google Play consumable in-app purchases to Ren'Py's Android platform. Consumable products (like in-game currency or energy) can be purchased multiple times, unlike one-time purchases, and require explicit consumption after purchase to allow repurchasing.
Key changes:
- Added
consumePurchase()method to consume purchased items and allow repurchasing - Added
addConsumableSKU()method to track which SKUs are consumable products - Introduced
consumableSKUsHashSet to store consumable product identifiers
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| rapt/prototype/renpyiap/src/main/java/org/renpy/iap/Store.java | Added base addConsumableSKU() and consumePurchase() method stubs to the Store interface |
| rapt/prototype/renpyiap/src/main/java/org/renpy/iap/PlayStore.java | Implemented Google Play-specific consumable purchase logic with async API calls and added consumableSKUs field |
| rapt/prototype/renpyandroid/src/main/java/org/renpy/android/PythonSDLActivity.java | Added addConsumableSKU() implementation to track consumable SKUs in the activity |
Comments suppressed due to low confidence (1)
rapt/prototype/renpyiap/src/main/java/org/renpy/iap/PlayStore.java:39
- The contents of this container are never accessed.
private HashSet<String> consumableSKUs = new HashSet<>();
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rapt/prototype/renpyiap/src/main/java/org/renpy/iap/PlayStore.java
Outdated
Show resolved
Hide resolved
rapt/prototype/renpyandroid/src/main/java/org/renpy/android/PythonSDLActivity.java
Outdated
Show resolved
Hide resolved
rapt/prototype/renpyandroid/src/main/java/org/renpy/android/PythonSDLActivity.java
Outdated
Show resolved
Hide resolved
rapt/prototype/renpyiap/src/main/java/org/renpy/iap/PlayStore.java
Outdated
Show resolved
Hide resolved
| Log.i("iap", "Successfully consumed " + sku); | ||
| purchased.remove(sku); | ||
| } else { | ||
| Log.e("iap", "Failed to consume " + sku); |
Copilot
AI
Nov 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the error case is hit (line 244), the error is logged but the finished flag is not set until after the sleep. Additionally, if the query fails but no matching purchase is found, finished is set to true at line 259, but if a matching purchase is found and consumption begins, the early return at line 255 means the line 259 will never execute. This is correct, but the error logging at line 244 should include more details about the failure (e.g., billingResult.getDebugMessage()).
| Log.e("iap", "Failed to consume " + sku); | |
| Log.e("iap", "Failed to consume " + sku + ": " + billingResult.getDebugMessage()); |
rapt/prototype/renpyiap/src/main/java/org/renpy/iap/PlayStore.java
Outdated
Show resolved
Hide resolved
rapt/prototype/renpyiap/src/main/java/org/renpy/iap/PlayStore.java
Outdated
Show resolved
Hide resolved
rapt/prototype/renpyandroid/src/main/java/org/renpy/android/PythonSDLActivity.java
Outdated
Show resolved
Hide resolved
rapt/prototype/renpyiap/src/main/java/org/renpy/iap/PlayStore.java
Outdated
Show resolved
Hide resolved
|
I think Copilot activated because of me, sorry. |
|
I don't mind the Copilot reviews, and I think they point out actual errors here - I'm not sure why you closed them. I'm trying to figure out why you're changing PythonSDLActivity.java at all. From initial inspection, and then I saw the copilot review, the changes to those files won't even compile. (If it does, I don't see how.) How did you test this? |
I made the edits in the compiled version of Rapt, editing in Project and Prototype, and testing. All changes were made by editing the already compiled version of Rapt and Renpy for (00iap.rpy). Since I don't have the resources to compile all the code from the SRC. As for Copilot, I felt it could be annoying. Some developers don't like filling issues with automations, so I thought it could become annoying or lead to incorrect corrections. As for PythonSDLActivity, it was my mistake. The code editing Rapt and Renpy already compiled seems to work. It lets me make the purchase several times. What I don't know is if it breaks any of the existing code. Since I don't have iOS, I can't test it. |
…java Co-authored-by: Copilot <[email protected]>
…java Co-authored-by: Copilot <[email protected]>
…java Co-authored-by: Copilot <[email protected]>
…java Co-authored-by: Copilot <[email protected]>
|
i'll try to compile and test |
|
Okay, I tried compiling from SRC and I can't use WSL (I use Windows). I tried from my Ubuntu server that is connected to my network and it won't let me either. I get an error when installing the sudo packages. |
|
You don't need to compile Ren'Py to test changes to Android. These files get copied into rapt/prototype/renpyiap/src/main/java/org/renpy/iap/... , so if you make the changes there you can test them. As long as it works there, I can accept them into Ren'Py - it was mostly PythonSDLActivity that's the issue. |
Oh!! I see! I thought I had to run some tests from the SRC to make sure there were no problems. In general, it should work fine. Editing the engine (stable version) and Rapt (stable version), I didn't find any problems in my tests. (Apart from the fact that I cannot make consecutive purchases of the same product and I get the error message “Already purchased” if I buy the same product too often). So perhaps in the future, it would be a good idea to implement some way of preventing attempts to purchase the same consumable for a period of time. For example, 1 minute, so that the backend can process everything correctly. With these changes, can you check if everything is correct? |
-- Tested with the compiled version of Ren'Py.
-- The second part changes 00iap.rpy.
The code isn't perfect, but it was tested to a certain extent with Google Play purchases.
The use of Restore for consumable products (e.g., energy or in-game currency) is not covered, but this is a starting point for future changes and opens up the possibility of creating games with consumable systems.
Code reviews are recommended to prevent bugs. One bug I encountered is that I cannot purchase the same product too often. I have to wait a short period of time before I can buy it again.
If you try to purchase the same product repeatedly, the error “Already purchased” appears, but if you wait a few minutes, you can purchase it again.
important: I understood that the changes should go in rapt/prototype/*, I apologize if the changes should go somewhere else.
I think Copilot activated because of me, sorry.
Update: I disabled Copilot reviews for future PR