Titanium in-app purchase with ti.storekit - product not found
Asked Answered
A

1

7

I have my in-app product all set up for purchase in iTunes Connect via ti.storekit:

enter image description here

My Appcelerator 4.0 app compiles and deploys to my device (dev profile). The ti.storekit is linked to my app and it compiles. It also seems to execute correctly, in terms of no unhandled exceptions. But it is telling me that it can't find my In-App purchase product. I have tried handing "15 Keys" and also "15Keys" to ti.storekit. I wasn't sure which one it wanted (Reference Name or Product ID) - but anyway neither works.

Here's the documentation I've been following.

And here is the function in ti.storekit that produces the error message:

function requestProduct(identifier, success)
{
    Storekit.requestProducts([identifier], function (evt) {
        if (!evt.success) {
            alert('ERROR: We failed to talk to Apple!');
        }
        else if (evt.invalid) {
            alert('ERROR: Invalid product: ' + identifier);
        }
        else {
            success(evt.products[0]);
        }
    });
}

The "else if" line is being executed: alert('ERROR: Invalid product: ' + identifier); What am I doing wrong? Should I be handing it the Reference Name (15 Keys) or the Product ID (15Keys)? And since I have tried both and neither works, how can I troubleshoot this? What am I doing wrong?

EDIT:

I am unclear on 3 things:

1- Should I go into Settings on my ipad and log in to itunes/store with my TEST USER apple sandbox account? I'm unable to do this because it keeps requiring me to enter a credit card. Test credit cards I've used in the past (on other non-iOS systems), such as 4111111111111111 do not work, and I cannot continue and sign in. Not even sure if I'm supposed to do this. If so, what CC credentials can I use? Should I use a REAL CC for this? Based on everything I'm reading in other articles and posts, it says to never link a test account to a CC number...then WHY won't apple let me log in my test user to my apple device (inside Settings) without entering a credit card?

2- I'm not following the steps in https://github.com/appcelerator-modules/ti.storekit/blob/master/ios/example/app.js EXACTLY, because in my app there is nothing to download, nothing to host, etc. In my app, users can buy keys, which are just digital entities in my app -- nothing to download. So I have removed all code/steps that have anything to do with downloading/hosting.

3- Version 1.0.0 of my app is awaiting review in the app store. This version has no ti.storekit and no in-app purchase. Nothing. BUT I'm working on a newer version with all the storekit and in-app purchase stuff in my latest appcelerator 4.0 project. Shouldn't this work in my dev environment, on my connected ipad, in a dev build? The fact that I have 1.0.0 awaiting review, with no storekit stuff, should have nothing to do with my new version in my dev account with storekit, right? Also I am puzzled by this message:

enter image description here

Do I need to submit a new build to Apple before my DEV storekit stuff will work? If so, this seems very strange, as though an app-store release candidate is connected with stuff I have in development in my local environment. Is this message indicating why my dev storekit stuff won't work? My in-app purchase product seems correctly configured, but shouldn't I be able to connect with this in dev/sandbox regardless of the 1.0 app (no storekit) awaiting review in the app store?

Thanks everyone for your help...I must be missing some critical step I'm not seeing.

Axillary answered 1/6, 2015 at 4:16 Comment(2)
Did you check if you use the Sandbox for testing?Hafler
I have a sandbox user (created on iTunes Connect), but how do I "point" my app at the sandbox?Axillary
H
4

Did you check if you use the Sandbox for testing? https://github.com/appcelerator-modules/ti.storekit/blob/master/ios/example/app.js#L86

And are you aware that you have to sign out of your existing App Store account to test? https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnectInAppPurchase_Guide/Chapters/TestingInAppPurchases.html

You have to use the Product ID (15Keys).

Hafler answered 2/6, 2015 at 6:36 Comment(10)
evt.products will contain all IAP's, so for testing purposes you can just console.log the entire list ;)Towner
Fokke, thanks for trying to help. It's unclear to me how to point at the apple sandbox, but I did include those 2 lines of code with "sandbox" and "sharedsecret". Also, I'm not sure what you mean about signing out of my app store account. In the app, it doesn't even get as far as asking me for my apple credentials, and I'm logged in as a different apple user anyway. Rene: evt.products has a length of zero. What could the problem be?Axillary
One more question: does the binary I submit to Apple have to contain the in-app storekit code? I would think I can test my app store stuff before submitting to apple for final App Store release.Axillary
@SweatCoder mm, if it returns empty then either it's not using the sandbox or you haven't configured the products correctly in iTunes Connect. And yes, of course the version you send to Apple has to have the module or it won't work. But you can test it doing an Ad Hoc built.Hafler
How do I know if I'm using the sandbox? The 2 sandbox lines of code relate to downloads, which is non-applicable for me. I have a sandbox test account, but I don't get far enough even to be prompted for credentials.Axillary
Only if you install the app from the App Store you are not in the sandbox and your problem seems to be that it cannot find your products.Hafler
I'm installing the app via connected device, and compiling from appcelerator -- not from app store. What else can I try?Axillary
I think you need to do an ad hoc build in order to use in app billing. Distribute that via TestFlight or something like InstallrApp.comHafler
Isn't that the same as compiling my app to a device, like my ipad connected to my macbook? That is what I did.Axillary
Success! I had already followed the above steps and done everything correctly. This morning when I tried again, it just worked. I hadn't changed any code. I believe that my product setup in itunes connect hadn't been fully approved or whatever. I had to sign all these docs and click I Agree in a few places and I think something wasn't completely greenlighted or etc. Only took 2 weeks...Axillary

© 2022 - 2024 — McMap. All rights reserved.