app crashes when hitting cancel button for iap (android & iOS)

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Meg'
Regular
Posts: 185
Joined: Tue Sep 27, 2011 10:37 am
Projects: Anges Démoniaques, Gang (Alex & Hugo), Le passé dans les veines
Location: France
Contact:

app crashes when hitting cancel button for iap (android & iOS)

#1 Post by Meg' »

Hi!

So here is the issue I am encountering on both android & iOS:

When a user clicks on the button to make the iap, the iap box dialogue appears (both on Google Play and on X-code (yes, my app can't pass Apple verification because of this T_T). You can either complete the purchase or change your mind and click on CANCEL.
The problem is that when we hit the "cancel" button, it makes the app crash.

Here is the code I am using:

Code: Select all

# number of versions available of this purchase

init python:
    IAPRange = 100
    
    energy_for_iap =  {
        "boire":    500,
        "bain":    1500,
        "dormir": 3500,
    }

    def RegisterIAP(product):
        iap.register(product)
        i = 0
        while IAPRange > i: 
            i = i + 1
            p = str(product) + str(i)  
            iap.register(p)

            
            
    RegisterIAP("boire")
    RegisterIAP("bain")
    RegisterIAP("dormir")
    
    def purchaseProduct(product):
        iap.restore(interact=False) 
        id = 1
        actual_product = str(product)

        while (iap.has_purchased(actual_product)):
            actual_product = product + str(id)
            id = id + 1
            if id > IAPRange:
                return False 
        
            
        success = iap.purchase(actual_product,interact=False)
        if (success):
            persistent.EnergyAvailable += energy_for_iap[product]
        else:
            pass
            
        return True
        
        
            

    PurchaseProduct = renpy.curry(purchaseProduct)



label iap_error:
    "Une erreur s'est produite durant l'achat."
Any idea on how to solve this?

Thanks in advance,

User avatar
Meg'
Regular
Posts: 185
Joined: Tue Sep 27, 2011 10:37 am
Projects: Anges Démoniaques, Gang (Alex & Hugo), Le passé dans les veines
Location: France
Contact:

Re: app crashes when hitting cancel button for iap (android & iOS)

#2 Post by Meg' »

Help, please? :?

Post Reply

Who is online

Users browsing this forum: peach_light