Page 1 of 1
Struggling with in-app purchase
Posted: Tue Feb 18, 2014 11:16 pm
by joel.epsteinBUS31vi
Hi all -
I'd appreciate any advice you might have to help me through my in-app purchase blues. I've been reading the forums here and have reviewed the tutorial on in-app purchases.
I think I've set things up the way the should be, but have clearly missed something. Can you please help me figure out what it might be?
1. Created a new app listing in iTunesConnect
2. Created new in-app purchases in iTunesConnect
3. Linked my in-app purchases to my app in iTunesConnect
4. Left the new app in "Prepare for Upload" state
5. Created test user in iTunesConnect
6. on my device, signed out of iTunes
7. Coded my app (please see below) making sure to use the same in-app identifier used in iTunes Connect
8. Using xCode, installed app on my device
9. Ran app on my device
10. Attempted to initiate in-app purchase
11. via displayed dialog, I see app is "sendingRequest"
12. receive prompt to sign in to iTunes store (which I do with new test user)
13. via displayed dialog, I see app is "sendingRequest"
14. via displayed dialog, I see error: "Cannot connect to iTunes Store."
I'm hoping that I'm just over-tired and have missed something very obvious. Please help me see what that might be. I've included the relevant code below.
Thanks so much.
Joel
----------------
Code: Select all
in a button handler:
if line 6 of gPrefs ≠ "true" then
answer "Do you want to spend US$0.99 to...." with "Yes" and "No"
if it = "Yes" then
answer "Stand by while purchase is processed..."
mobilePurchaseCreate "com.projectiveart.1ThingDone.Shake"
put the result into tID
mobileEnablePurchaseUpdates
mobilePurchaseSendRequest tID
else
answer "Okay, maybe some other time..."
end if
----------------------------------
in my stack script:
on purchaseStateUpdate pPurchaseID
answer mobilePurchaseGet(pPurchaseID, "productID")&return&mobilePurchaseState(pPurchaseID)
switch mobilePurchaseState(pPurchaseID)
case "paymentReceived"
if mobilePurchaseGet(pPurchaseID, "productID") is "com.projectiveart.1ThingDone.Shake" then
put "true" into line 6 of gPrefs
else
put "true" into line 5 of gPrefs
end if
mobilePurchaseConfirmDelivery pPurchaseID
mobileDisablePurchaseUpdates
break
case "error"
answer "Error occured during purchase handling:" & return & return & mobilePurchaseError(pPurchaseID)
mobileDisablePurchaseUpdates
break
case "cancelled"
answer "Purchase cancelled."
mobileDisablePurchaseUpdates
break
end switch
end purchaseStateUpdate
Re: Struggling with in-app purchase
Posted: Tue Feb 18, 2014 11:52 pm
by splash21
Hi, Joel. I've not done anything with in app purchases for some time, but this code is straight out of a test app that uses them successfully. I don't see anything obvious in your code that would cause a problem, but it's clocking off time over here, so I'll post the handlers and hopefully it's useful
button script for purchase
Code: Select all
on mouseUp
buttonPress
if mobileCanMakePurchase() then
# purchase paid/full version
busyStart "Purchasing...", true
mobilePurchaseCreate "com.splash21.skidoodler.paid"
put the result into tID
mobileEnablePurchaseUpdates
mobilePurchaseSendRequest tID
else
answer "Purchasing not available." & LF & "Please try later."
end if
end mouseUp
In the stack script
Code: Select all
on purchaseStateUpdate pPurchaseID
switch mobilePurchaseState(pPurchaseID)
case "initialized"
break
case "sendingRequest"
break
case "paymentReceived"
busyStart "", true
answer "Purchase successful"
put mobilePurchaseGet(pPurchaseID, "productID") into tProduct
if tProduct ends with ".paid" then
# full version
put md5Hash(gAppA["Device"] & "Paid") into gAppA["Paid"]
put false into gAppA["AdsEnabled"]
saveAppData
else if tProduct begins with "com.splash21.skidoodler.skoins" then
# skoins top up
put char 31 to -1 of tProduct into tQty
if tQty is an integer then
put gAppA["SkoinsPurchased"] into tTotal
if tTotal is not an integer then put 0 into tTotal
put tTotal + tQty into gAppA["SkoinsPurchased"]
put md5Hash("SkoinsCheck" & gAppA["SkoinsPurchased"]) into gAppA["SkoinsHash"]
saveAppData
else
answer "An error occurred: quantity = " & tQty
end if
end if
mobilePurchaseConfirmDelivery pPurchaseID
put true into tComplete
serverRecordPurchases
break
case "error"
busyStart "", true
answer "Purchase failed" & LF & mobilePurchaseError(pPurchaseID)
put true into tComplete
break
case "cancelled"
busyStart "", true
answer "Purchase cancelled"
put true into tComplete
break
end switch
if tComplete then
busyStop
mobileDisablePurchaseUpdates
end if
end purchaseStateUpdate
Re: Struggling with in-app purchase
Posted: Wed Feb 19, 2014 12:39 am
by joel.epsteinBUS31vi
Thanks so much for your response.
I parsed your code and it looked largely similar (though admittedly more sophisticated) than mine. I copied your scripts into my app and then recompiled and reinstalled onto my device.
I got the same error: Cannot connect to iTunes Store
So...
The good news is that you've helped me narrow things down to the fact that it's probably something that I did (or didn't do) in iTunes Connect.
I have the app listed on my account and it is linked to the in-app purchases I set up. And I'm logging in as a test-user.
Anyone have any clue what I might have missed?
I'd appreciate any suggestions you might have.
Joel
Re: Struggling with in-app purchase
Posted: Wed Feb 19, 2014 12:46 am
by LCNeil
Hi Joel,
Have you confirmed the test user account via the "confirm this account" email that Apple sends?
We were testing in-app purchases earlier this week and an unconfirmed email is an issue that we encountered.
Kind Regards,
Neil Roger
--
RunRev Support Team ~
http://www.runrev.com
-
Re: Struggling with in-app purchase
Posted: Wed Feb 19, 2014 1:09 am
by joel.epsteinBUS31vi
Oh, dang! When I first read your reply, I was sure that this was going to be the answer.
I had previously set up users with fake email addresses so I never got the confirmation.
So this time, I went through the whole process of setting up another user with an actual email address. Then, after receiving the confirmation email, when I tried to sign on to iTunes, I had to go through the process of entering credit card number etc. I was convinced I was on the right track.
But alas...
Even with this new test user in place, I still get the "cannot connect to iTunes" error in my app.
Clearly I've done something wrong, but I keep staring at iTunes connect and can't seem to find the problem.
Is it okay for my app to be in "prepare for upload" status and my in-app purchases to be in "ready to submit" status? Or do I need to push things further?
Any ideas?
Thanks so much.
Joel
Re: Struggling with in-app purchase
Posted: Wed Feb 19, 2014 1:04 pm
by LCNeil
Hi Joel,
Are you always testing via your device or are you testing on the iOS simulator?
If you are testing on the latest simulator, then you will be experiencing this issue there is an iOS storeKit bug that does not allow in-app purchases to be tested.
More information on this can be found here-
http://stackoverflow.com/questions/1899 ... -simulator
Kind Regards,
Neil Roger
--
RunRev Support Team ~
http://www.runrev.com
-
Re: Struggling with in-app purchase
Posted: Wed Feb 19, 2014 1:24 pm
by joel.epsteinBUS31vi
No, I'm testing on my device, not the simulator.
I wonder what else it might be that I'm doing wrong.
I'd be grateful for any other advice.
Joel
Re: Struggling with in-app purchase
Posted: Wed Feb 19, 2014 1:51 pm
by joel.epsteinBUS31vi
And - on further reflection - I don't think it's how I have my in-app purchase set up in iTunes connect, because I never get to a purchase point - just getting the error that I can't connect to the store. Hmmmm....
Re: Struggling with in-app purchase
Posted: Wed Feb 19, 2014 2:07 pm
by LCNeil
Hi Joel,
Now that i think about it, I think I reported a bug that could relate to this issue-
http://quality.runrev.com/show_bug.cgi?id=11767
Although it was tagged as not a bug, the solution was remove any existing accounts from your iOS device (settings--->iTunes&App store) and then re-add your test account.
Keep us informed on how you get on.
Kind Regards,
Neil Roger
--
RunRev Support Team ~
http://www.runrev.com
-
Re: Struggling with in-app purchase
Posted: Wed Feb 19, 2014 3:20 pm
by joel.epsteinBUS31vi
Still struggling. I feel as if I'm probably missing something very basic and would appreciate any other suggestions.
Using:
- LiveCode 6.5.2
- iPhone 4S 7.0.3
I went back to iTunes Connect and deleted all my test users and created a brand new one. I don't know if it's necessary, but I then copied this user's information into the Demo Account fields in my app's listing on iTunes Connect.
I verified again that the in-app purchase is tied to the app, and verified that the in-app purchase ID is the one I'm using in LiveCode.
I rebooted the device, signed out of iTunes.
I then recompiled the app in LiveCode and used xCode to install the app on the device.
I initiated an in-app purchase. I was asked to sign in to iTunes - I used the credentials of my newly created user.
The program paused a bit, then I got the same error: Cannot connect to iTunes Store
Perhaps this description of what I've done will help you see what I've done wrong. I'd be grateful for any guidance.
Joel
Re: Struggling with in-app purchase
Posted: Wed Feb 19, 2014 7:15 pm
by dave.kilroy
Hi Joel
I had a nasty tussle with iTunes Connect and in-app purchases back in October 2013 - what threw me was not any code but iTC's weird user interface (ugh)
After I got things working I posted an explanation of what I did on the Forum here
http://forums.runrev.com/viewtopic.php?f=49&t=17430
I hope it either solves your problem or gives you some new ideas to chase down...
Good luck!
Dave
Re: Struggling with in-app purchase
Posted: Wed Feb 19, 2014 7:53 pm
by joel.epsteinBUS31vi
Dave -
Thanks for this. I had read your post earlier and it has enabled me to get fairly far in this process.
The only difference, however, is what you had to do was actually submit the app and then reject it.
And so now this is the place where I'm at - I've created the listing on iTunes Connect, I've created the in-app purchases, I've linked the in-app purchases to my listing. The status of my in-app purchases are listed as "ready to submit" and the status of my application is "prepare for upload."
Do I need to go ahead and click the "Ready to Upload" button in order to test my in-app purchase procedure? I'm a bit hesitant to do that, because if I do, and there is some other problem, I will have to reject the binary, etc.
Any other clues what I might be doing wrong?
Thanks so much.
Joel
Re: Struggling with in-app purchase
Posted: Wed Feb 19, 2014 9:16 pm
by dave.kilroy
Hi Joel
From my experience it was easy to reject the binary later on if I wanted to - what I did was to practice on a 'hello world' app without risk to my (then) current project. Looking at the troubles you've been having I think it might be worthwhile you doing something similar so you can experiment and test without risking anything.
I fact in my testing I created several versions of the 'hello world' app with in-app purchases which I uploaded and later rejected after I had done the testing I wanted to - usually I would reject a binary within minutes of completing tests and it would vanish from iTC without a problem. After you upload an app you have several days before it goes into the review process (it spends, in my experience, at least two working days in the 'waiting for review' stage). Also you can now set the release date to be controlled by you (can't remember exactly where in the process this is but you do have control) - so that should your 'hello world' app actually make it through the Apple review process you can still kill it off before it hits the App Store.
Kind regards
Dave
Re: Struggling with in-app purchase
Posted: Sat Feb 22, 2014 12:29 am
by joel.epsteinBUS31vi
Hi all -
Thanks for all your input and advice.
Unfortunately, I'm not much of a scientist, and I've let three variables change. Any one of them could be the reason for my in-app purchase procedures suddenly starting to work:
a) the passage of time
b) clicking iTunes Connnect "Ready to Upload" button
c) upgrading to LiveCode to 6.6 (dp1)
Again, I appreciate all the help.
Joel
Re: Struggling with in-app purchase
Posted: Mon Feb 24, 2014 6:05 pm
by splash21
LOL - it's always a bummer when you never get to the bottom of what the problem was - BUT - great that it's all working!
