Skip to content

Conversation

@neyunse
Copy link

@neyunse neyunse commented Nov 22, 2025

-- 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

Copilot AI review requested due to automatic review settings November 22, 2025 23:40
Copilot finished reviewing on behalf of neyunse November 22, 2025 23:43
Copy link

Copilot AI left a 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 consumableSKUs HashSet 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.

Log.i("iap", "Successfully consumed " + sku);
purchased.remove(sku);
} else {
Log.e("iap", "Failed to consume " + sku);
Copy link

Copilot AI Nov 22, 2025

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()).

Suggested change
Log.e("iap", "Failed to consume " + sku);
Log.e("iap", "Failed to consume " + sku + ": " + billingResult.getDebugMessage());

Copilot uses AI. Check for mistakes.
@neyunse
Copy link
Author

neyunse commented Nov 22, 2025

I think Copilot activated because of me, sorry.

@renpytom
Copy link
Member

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?

@neyunse
Copy link
Author

neyunse commented Nov 23, 2025

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.

@neyunse
Copy link
Author

neyunse commented Nov 23, 2025

i'll try to compile and test

@neyunse
Copy link
Author

neyunse commented Nov 23, 2025

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.

@renpytom
Copy link
Member

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.

@neyunse
Copy link
Author

neyunse commented Nov 23, 2025

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants