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."
Thanks in advance,