Closed nnylip closed 6 years ago
I found an issue with my code, here is revised: $(document).ready(function() { document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() { initStore(); }
});
// cordova plugin add cc.fovea.cordova.purchase initStore = function() {
if (!window.store) {
log('Store not available');
return;
}
else console.log('store is running') var platform = device.platform.toLowerCase(); document.getElementsByTagName('body')[0].className = platform;
// Enable maximum logging level
store.verbosity = store.DEBUG;
// Enable remote receipt validation
//store.validator = "https://api.fovea.cc:1982/check-purchase";
// Inform the store of your products
//console.log('registerProducts');
log('registering') store.register({ id: 'lplcoins', // id without package name! com.lpl.lplcoins alias: 'lplcoins', type: store.PAID_SUBSCRIPTION }); log('done registering')
// When any product gets updated, refresh the HTML.
store.when("lplcoins").updated(function (p) {
log("updated subscription"+p.id);
log('updated: ' + p.price);
//app.renderIAP(p);
});
store.when("lplcoins").approved(function(p) {
log("approved subscription");
p.verify();
});
store.when("lplcoins").verified(function(p) {
log("subscription verified"+p.id);
p.finish();
});
store.when("lplcoins").unverified(function(p) {
log("subscription unverified"+p.id);
});
store.when("lplcoins").updated(function(p) {
//if (true) {
if (p.owned) {
document.getElementById('subscriber-info').innerHTML = 'You are a lucky subscriber!';
}
else {
document.getElementById('subscriber-info').innerHTML = 'You are not subscribed';
}
});
// Log all errors
store.error(function(error) {
log('ERROR ' + error.code + ': ' + error.message);
});
// When purchase of an extra life is approved,
// deliver it... by displaying logs in the console.
store.when("lplcoins").approved(function (order) {
log("You got an EXTRA LIFE!");
order.finish();
});
// When purchase of the full version is approved,
// show some logs and finish the transaction.
store.when("lplcoins").approved(function (order) {
log('You just unlocked the FULL VERSION!');
order.finish();
});
// The play button can only be accessed when the user
// owns the full version.
store.when("lplcoins").updated(function (product) {
document.getElementById("access-full-version-button").style.display =
product.owned ? "block" : "none";
});
// When the store is ready (i.e. all products are loaded and in their "final"
// state), we hide the "loading" indicator.
//
// Note that the "ready" function will be called immediately if the store
// is already ready.
store.ready(function() {
var el = document.getElementById("loading-indicator");
if (el) el.style.display = 'none';
});
// When store is ready, activate the "refresh" button;
store.ready(function() {
log('store is ready')
var el = document.getElementById('refresh-button');
if (el) {
el.style.display = 'block';
el.onclick = function(ev) {
log('register pressed')
store.refresh();
};
}
});
console.log('refresh');
store.refresh();
}; log = function(arg) { try { if (typeof arg !== 'string') arg = JSON.stringify(arg); console.log('
$("#talog").append( arg+'\n' );
$("#talog").each(function () {
this.style.height = (this.scrollHeight+10)+'px';
});
//document.getElementById('log').innerHTML += '<div>' + arg + '</div>';
} catch (e) {}
};
Now getting this output in xcode: 2015-11-20 13:11:00.383 lplcoins[5679:1858727] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/FA8F504F-8688-45A8-8E10-CF058258EA5C/Library/Cookies/Cookies.binarycookies 2015-11-20 13:11:00.669 lplcoins[5679:1858727] Apache Cordova native platform version 3.9.2 is starting. 2015-11-20 13:11:00.672 lplcoins[5679:1858727] Multi-tasking -> Device: YES, App: YES 2015-11-20 13:11:00.680 lplcoins[5679:1858727] Unlimited access to network resources 2015-11-20 13:11:00.689 lplcoins[5679:1858727]
Started backup to iCloud! Please be careful. Your application might be rejected by Apple if you store too much data. For more information please read "iOS Data Storage Guidelines" at: https://developer.apple.com/icloud/documentation/data-storage/ To disable web storage backup to iCloud, set the BackupWebStorage preference to "local" in the Cordova config.xml file
2015-11-20 13:11:00.895 lplcoins[5679:1858727] [CDVTimer][file] 66.745996ms 2015-11-20 13:11:00.896 lplcoins[5679:1858727] [CDVTimer][TotalPluginStartup] 67.312002ms 2015-11-20 13:11:01.340 lplcoins[5679:1858727] Resetting plugins due to page load. 2015-11-20 13:11:01.897 lplcoins[5679:1858727] Finished load of: file:///private/var/mobile/Containers/Bundle/Application/6B3A71E9-AC0A-40FC-86F1-78C8548606A4/lplcoins.app/www/index.html 2015-11-20 13:11:02.141 lplcoins[5679:1858727] THREAD WARNING: ['InAppPurchase'] took '15.644287' ms. Plugin should use a background thread. 2015-11-20 13:11:02.143 lplcoins[5679:1858727] store is running 2015-11-20 13:11:02.143 lplcoins[5679:1858727]
Output is saying the product is invalid. QUESTION: is a completed contract required to be able to test the in-app purchase (to query a valid product)?
Did you find solution for product not valid?
Thanks for the reply. This is currently still happening. However, it may be caused by the apple itunes connect agreements not being in place. I am waiting for apple to approve everything. If you are involved with the plugin dev or documentation it would be good to add something about the legal stuff being in place before the store responds correctly. Assuming this is true, it took a lot of digging to find this out. I will try again when it gets approved and let you know. - Lou
On 12/02/2015 05:38 AM, benny wrote:
Did you find solution for product not valid?
— Reply to this email directly or view it on GitHub https://github.com/j3k0/cordova-plugin-purchase/issues/346#issuecomment-161253919.
Benny - I am receiving the following exception while testing with the plugin:
On AppDelegate line: Getting a Thread 1: EXC_BAD_ACCESS (code=1, address=...)
int main(int argc, char* argv[]) { @autoreleasepool { int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate"); return retVal; } }
Also, I am still confused about how the sequence of a non-renewing subscription works. This is my current understanding:
. user downloads in-app purchase enabled app
. user attempts to use the app, app detects it is not subscribed and opens a web view with apple url: https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/manageSubscriptions
(question, how does itunes know which app is be charged?)
. user pays and app is enabled.
. after some period of time (1 year in our case), app detects it is no longer subscribed and then opens the url mentioned above.
Thanks - Lou
On 12/02/2015 05:38 AM, benny wrote:
Did you find solution for product not valid?
— Reply to this email directly or view it on GitHub https://github.com/j3k0/cordova-plugin-purchase/issues/346#issuecomment-161253919.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I'm attempting to use the cc.fovea.cordova.purchase plugin with cordova. Plugin installed using: cordova plugin add cc.fovea.cordova.purchase cordova version: 5.3.3 plugin version: cc.fovea.cordova.purchase 4.0.0 "Purchase" Using a slimmed down version of the example, code: $(document).ready(function() { document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() { initStore(); }
});
// cordova plugin add cc.fovea.cordova.purchase initStore = function() {
else console.log('store is running') var platform = device.platform.toLowerCase(); document.getElementsByTagName('body')[0].className = platform;
log('registering') store.register({ id: 'lplcoins', // id without package name! com.lpl.lplcoins alias: 'lplcoins', type: store.PAID_SUBSCRIPTION }); log('done registering')
}; log = function(arg) { try { if (typeof arg !== 'string') arg = JSON.stringify(arg); console.log('
};
I'm getting this output in xcode: 2015-11-20 09:31:48.179 lplcoins[5535:1825275] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/74E27E88-3756-424A-BB5B-D888C474FE3F/Library/Cookies/Cookies.binarycookies 2015-11-20 09:31:48.463 lplcoins[5535:1825275] Apache Cordova native platform version 3.9.2 is starting. 2015-11-20 09:31:48.466 lplcoins[5535:1825275] Multi-tasking -> Device: YES, App: YES 2015-11-20 09:31:48.475 lplcoins[5535:1825275] Unlimited access to network resources 2015-11-20 09:31:48.483 lplcoins[5535:1825275]
Started backup to iCloud! Please be careful. Your application might be rejected by Apple if you store too much data. For more information please read "iOS Data Storage Guidelines" at: https://developer.apple.com/icloud/documentation/data-storage/ To disable web storage backup to iCloud, set the BackupWebStorage preference to "local" in the Cordova config.xml file
2015-11-20 09:31:48.685 lplcoins[5535:1825275] [CDVTimer][file] 64.508021ms 2015-11-20 09:31:48.685 lplcoins[5535:1825275] [CDVTimer][TotalPluginStartup] 65.097988ms 2015-11-20 09:31:49.143 lplcoins[5535:1825275] Resetting plugins due to page load. 2015-11-20 09:31:49.697 lplcoins[5535:1825275] Finished load of: file:///private/var/mobile/Containers/Bundle/Application/25116158-BB61-4E20-BB5F-D97783C53A42/lplcoins.app/www/index.html 2015-11-20 09:31:49.961 lplcoins[5535:1825275] THREAD WARNING: ['InAppPurchase'] took '17.277832' ms. Plugin should use a background thread. 2015-11-20 09:31:49.963 lplcoins[5535:1825275] store is running 2015-11-20 09:31:49.963 lplcoins[5535:1825275]
Any and all help appreciated, (been working on this for days!)