Hello, am using the following for reference: Mac OSX Mountain Lion 10.8.4, Ti SDK 3.1.3 GA, iPhone.
I am new in Storekit module and getting error message that the ERROR: "We requesting an invalid product!"
I just followed the storekit procedure indicated in the apps.js. Please advise what's wrong. Was able to: 1) install the storekit into the library folder 2) changed the versions in the xml file consistent with the version of the library folder 3) entered the apple itunes and made sample product codes as instructed in the below
I might have missed a lot from below code that I inserted in apps.js
var tabGroup = Ti.UI.createTabGroup(); var win1 = Ti.UI.createWindow({ title:"MY APP NAME", backgroundColor:'transparent', url:"homePage.js", tabBarHidden:true, navBarHidden:false }); var tab1 = Ti.UI.createTab({ title: "tab1", window: win1 }); var Storekit = require('ti.storekit'); Storekit.receiptVerificationSandbox = (Ti.App.deployType !== 'production'); Storekit.receiptVerificationSharedSecret = "<YOUR STOREKIT SHARED SECRET HERE>"; Storekit.autoFinishTransactions = false; Storekit.bundleVersion = "3.0.0"; // eg. "1.0.0" Storekit.bundleIdentifier = "com.renato.renato"; // eg. "com.appc.storekit" var verifyingReceipts = false; var win = Ti.UI.createWindow({ backgroundColor:'#fff' }); var loading = Ti.UI.createActivityIndicator({ bottom:10, height:50, width:50, backgroundColor:'black', borderRadius:10, style:Ti.UI.iPhone.ActivityIndicatorStyle.BIG }); var loadingCount = 0; function showLoading() { loadingCount += 1; if (loadingCount == 1) { loading.show(); } } function hideLoading() { if (loadingCount > 0) { loadingCount -= 1; if (loadingCount == 0) { loading.hide(); } } } win.add(loading); var tempPurchasedStore = {}; function isIOS7Plus() { if (Titanium.Platform.name == 'iPhone OS') { var version = Titanium.Platform.version.split("."); var major = parseInt(version[0],10); if (major >= 7) { return true; } } return false; } var IOS7 = isIOS7Plus(); function markProductAsPurchased(identifier) { Ti.API.info('Marking as purchased: ' + identifier); tempPurchasedStore[identifier] = true; Ti.App.Properties.setBool('Purchased-' + identifier, true); } function checkIfProductPurchased(identifier) { Ti.API.info('Checking if purchased: ' + identifier); if (tempPurchasedStore[identifier] === undefined) tempPurchasedStore[identifier] = Ti.App.Properties.getBool('Purchased-' + identifier, false); return tempPurchasedStore[identifier]; } function requestProduct(identifier, success) { showLoading(); Storekit.requestProducts([identifier], function (evt) { hideLoading(); if (!evt.success) { alert('ERROR: We failed to talk to Apple!'); } else if (evt.invalid) { alert('ERROR: We requested an invalid product!'); } else { success(evt.products[0]); } }); } Storekit.addEventListener('transactionState', function (evt) { hideLoading(); switch (evt.state) { case Storekit.TRANSACTION_STATE_FAILED: if (evt.cancelled) { alert('Purchase cancelled'); } else { alert('ERROR: Buying failed! ' + evt.message); } evt.transaction && evt.transaction.finish(); break; case Storekit.TRANSACTION_STATE_PURCHASED: if (verifyingReceipts) { if (IOS7) { // iOS 7 Plus receipt validation is just as secure as pre iOS 7 receipt verification, but is done entirely on the device. var msg = Storekit.validateReceipt() ? 'Receipt is Valid!' : 'Receipt is Invalid.'; alert(msg); } else { // Pre iOS 7 receipt verification Storekit.verifyReceipt(evt, function (e) { if (e.success) { if (e.valid) { alert('Thanks! Receipt Verified'); markProductAsPurchased(evt.productIdentifier); } else { alert('Sorry. Receipt is invalid'); } } else { alert(e.message); } }); } } else { alert('Thanks!'); markProductAsPurchased(evt.productIdentifier); } if (evt.downloads) { Storekit.startDownloads({ downloads: evt.downloads }); } else { // Do not finish the transaction here if you wish to start the download associated with it. // The transaction should be finished when the download is complete. // Finishing a transaction before the download is finished will cancel the download. evt.transaction && evt.transaction.finish(); } break; case Storekit.TRANSACTION_STATE_PURCHASING: Ti.API.info('Purchasing ' + evt.productIdentifier); break; case Storekit.TRANSACTION_STATE_RESTORED: Ti.API.info('Restored ' + evt.productIdentifier); if (evt.downloads) { Ti.API.info('Downloads available for restored product'); } evt.transaction && evt.transaction.finish(); break; } }); tabGroup.addTab(tab1); tabGroup.open();