in-app purchase (IAP) on 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.
Message
Author
cookienomnom
Newbie
Posts: 15
Joined: Thu Jan 11, 2018 10:02 am
Contact:

in-app purchase (IAP) on iOS

#1 Post by cookienomnom »

Hey y'all,

I've successfully implemented IAP on Android and am now trying to implement IAP on iOS.
I've tried all the combinations of 'Registering the product', 'Triggering IAP', and 'Mac Identity' below.
However, I just can't get iOS purchase dialog to appear.... :(

Could someone please let me know what I'm doing wrong and how I can fix it?
Thank you sooooooo much in advance!!! =)


[Registering the product]
(1)
init python:
iap.register("halfintro02",identifier = "halfintro02")
(2)
define halfintro02 = iap.register(
product = "halfintro02",
identifier = "com.company.game.halfintro02",
google = "halfintro02",
ios = "halfintro02",
)

[Triggering IAP]
(1)
menu:
"Buy This Special Offer":
$iap.Purchase ("halfintro02")
"No Thanks":
jump chap1

if iap.has_purchased("halfintro02"):
jump chap2

(2)
menu:
"Buy This Special Offer":
$iap.purchase ("halfintro02")
"No Thanks":
jump chap1

if iap.has_purchased("halfintro02"):
jump chap2


[Mac Identity - option.rpy]
(1)
#define build.mac_identity = "Developer ID Application: Company Name (XXXXXXXXXX)"
(2)
define build.mac_identity = "Company Name (XXXXXXXXXX)"
(3)
define build.mac_identity = "company.name@gmail.com (XXXXXXXXXX)"

cookienomnom
Newbie
Posts: 15
Joined: Thu Jan 11, 2018 10:02 am
Contact:

Re: in-app purchase (IAP) on iOS

#2 Post by cookienomnom »

Update:
In the xcode console output, it says:
Validated product identifiers.
Starting validation.
Already validated.

It seems like the product is valid but still can't figure out why iOS native purchase dialog doesn't show..........
It's not that the product has been already purchased either, because iap.has_purchased() returns false.
I've tried both using Testflight and Sandbox account.

I'd really appreciate if anyone has any idea/suggestion on how to solve this issue.

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: in-app purchase (IAP) on iOS

#3 Post by Meg' »

Stupid question on my part but did you turn the iap on your Xcode project ON?

cookienomnom
Newbie
Posts: 15
Joined: Thu Jan 11, 2018 10:02 am
Contact:

Re: in-app purchase (IAP) on iOS

#4 Post by cookienomnom »

There is no such thing as a stupid question =) and Yes! I've turned IAP on on my xcode project. Thanks for checking!

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: in-app purchase (IAP) on iOS

#5 Post by Meg' »

Did you manage to solve this?

edit: I don't see any iap.restore in your code. This could be the cause of your problem (I'm not sure, though). Mine is different because it's about consumables :(

Here is the code of Jibus:

Code: Select all

    label iap_chapter2:
        if iap.has_purchased("iap_chapter2") or iap.has_purchased("iap_chapter2_ipad"):
            jump chapter2
        else:
            jump ad_chapter2

    label ad_chapter2:
        s "{i}Continue the Story...{/i}"
        menu:
            "Continue":
                $ iap.purchase("iap_chapter2")
                jump iap_chapter2
            "I already bought this item":
                $ iap.restore()
                jump iap_chapter2
            "Return to the main menu":
                call screen main_menu
Here is the link toward the subject in question to see the full code :)

edit2:

After having tried different things for several days (including today during around 4hours), I understood one thing:
the iap system is already included in ren'py.

So, I ended up with a code looking like this for my part:

Code: Select all

  
init python:
  
    iap.register(product="boireA", identifier= "com.gmail.meggout.lpdv.boireA", consumable=True)
    iap.register(product="bainA", identifier= "com.gmail.meggout.lpdv.bainA", consumable=True)
    iap.register(product="dormirA", identifier= "com.gmail.meggout.lpdv.dormirA", consumable=True)

    iap.has_purchased(product="boireA")
    iap.has_purchased(product="bainA")
    iap.has_purchased(product="dormirA")

    iap.purchase(product="boireA", interact=True)
    iap.purchase(product="bainA", interact=True)
    iap.purchase(product="dormirA", interact=True)
and I'm calling the iap action with iap.Purchase(product="product name", success ="persistent.AvailableEnergy += quantity we bought")

My problem is the same as yours:
Xcode informs me about this ==> "Starting validation. Already validated."

Then nothing happens.

Can someone help us solve this? Thanks a lot!

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: in-app purchase (IAP) on iOS

#6 Post by PyTom »

For the people asking about this: Are you using a test identity on your device? If you're using your normal account, you already own the purchase, and no dialogue will appear.
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

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: in-app purchase (IAP) on iOS

#7 Post by Meg' »

Thank you for your answer! Yes, I'm using a tester account via the X-code simulator. I guess using it on Testflight is better?

Also does it mean that both my code and cookienomnom are correct?

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: in-app purchase (IAP) on iOS

#8 Post by PyTom »

The 2 code in the first post looks basically right. I'd have written it as:

Code: Select all

[Registering the product]
init python:
    define halfintro02 = iap.register(product = "halfintro02", identifier = "com.company.game.halfintro02)

menu:
    "Buy This Special Offer":
        $ iap.purchase ("halfintro02")
    "No Thanks":
        jump chap1

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

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: in-app purchase (IAP) on iOS

#9 Post by Meg' »

So if I write mine like this, is it correct? ==>

Code: Select all

init python:
    
    iap.register(product="boireA",identifier="com.gmail.meggout.lpdv.boireA",consumable=True)

label boireA:

menu:
    "Buy 500 energy?":
        $ iap.purchase ("boireA")
        
        if iap.has_purchased("boireA"):
            $ persistent.EnergyAvailable+=500
            
            "Thank you for your purchase! 500 points were added to your energy!"
    
        return()

    "Don't buy":
        return()
Mine being a consumable, is there any difference with the code for a non-consumable product? Or is there something like I saw in common00iap with "return iap.consume(product)"?

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: in-app purchase (IAP) on iOS

#10 Post by PyTom »

Ren'Py doesn't support consumable purchases, only unlocks.
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

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: in-app purchase (IAP) on iOS

#11 Post by Meg' »

What do you mean by "only unlocks"? It is written in the documentation that consumable purchases are supported on iOS, is it not the case? :o

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: in-app purchase (IAP) on iOS

#12 Post by Meg' »

Ok, I am still getting this message ==>

"Starting validations.
Already validated."

I have tested it on my device while being logged out but I don't get any dialogue box for the purchase. I understand that we "own" the purchase but when logged out, this is not the case so what is preventing the dialogue box from appearing??

Is it related to consumables???

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: in-app purchase (IAP) on iOS

#13 Post by Meg' »

No one to help?

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: in-app purchase (IAP) on iOS

#14 Post by Meg' »

Be it consumable or non-consumable purchase, I'm still getting the:

"Starting validation.
Already validated."

So, what could be the problem?

I don't have any dialogue box appearing. No, I don't own the purchase ==> I'm logged out. I have a Sandbox tester account that I could use if only the dialogue box to make the purchase wanted to appear...

So after a few weeks, an answer maybe? Please?

cookienomnom
Newbie
Posts: 15
Joined: Thu Jan 11, 2018 10:02 am
Contact:

Re: in-app purchase (IAP) on iOS

#15 Post by cookienomnom »

Sorry Meg... I just saw this thread.
Were you able to figure out what's causing the issue?

One theory I have is.. Apple requires registration of ITIN if an individual/company wants to sell via IAP - regardless of whether the individual/company is based in the US or not.
I ran into some trouble getting ITIN and wasn't able to complete the registration with Apple. Have you completed registration by any chance?

Post Reply

Who is online

Users browsing this forum: Andredron