cordova-plugin-purchase icon indicating copy to clipboard operation
cordova-plugin-purchase copied to clipboard

[IOS] store.ready() event not firing - store.order() not working - IOS 15

Open cosmicdust471 opened this issue 3 years ago • 8 comments

System info

Cordova 10.0.0 Device: iPhone 12 Pro Max iOS 15 Plugin Version: ^10.6.1

Expected behavior

I'm expecting that after registering the products, events and calling store.refresh() I would get the store.ready() event fired and that calling store.order('product') would bring up the purchase window.

Observed behavior

The store.ready() event is never fired after store.refresh() is called. Calling store.order('product') produces no output.

Steps to reproduce

	store.verbosity = 'DEBUG';
        store.validator = 'https://validator.fovea.cc...';
        /*OR*/ store.validator = function (product, callback) {callback(true);};
	store.register({
		id: 'product',
		type: store.PAID_SUBSCRIPTION
	});
	store.when('product').owned(function(product){
		console.log('IAP owned',product);
	});
	store.when('product').cancelled(function(product){
		console.log('IAP cancelled',product);
	});
	store.when('product').verified(function(product) {
		console.log('IAP verified',product);
		product.finish();
	});
	store.when('product').approved(function(product){
		console.log('IAP approved',product);
		product.verify();
	});
	store.ready(function() {
		console.log('IAP store ready');
	});
	store.error(function(error) {
                 console.error(error);
        });
        store.refresh();

Logs

DEBUG: state: product -> registered 
DEBUG: ios -> product product registered and owned 
DEBUG: store.trigger -> triggering action refreshed
DEBUG: ios -> initializing storekit
< {cancelled: function, failed: function, completed: function, finished: function}
INFO: ios -> storekit ready (cordova.js, line 1413)
DEBUG: ios -> loading products (cordova.js, line 1413)

cosmicdust471 avatar Nov 07 '21 04:11 cosmicdust471

I have the same problem, can anyone help us?

Arthurferrera avatar Nov 08 '21 21:11 Arthurferrera

I think this is the same issue as https://github.com/j3k0/cordova-plugin-purchase/issues/1248. Having the same problem here.

jscssphtml avatar Nov 09 '21 08:11 jscssphtml

This is an issue I too am experiencing - only on live/production version unfortunately, testflight works as expected.

howlermonkey avatar Nov 20 '21 11:11 howlermonkey

I am having same issue, where testflight works fine and order button does not work on live/production. What I have noticed is that if I click the button leave it sitting for 3 to 4 minutes then it starts working, not sure what is causing it but hard to debug when testflight works and production is showing issue

sftayyaba avatar Nov 22 '21 18:11 sftayyaba

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.

stale[bot] avatar Apr 18 '22 18:04 stale[bot]

same problem

Gautammer avatar Aug 17 '22 18:08 Gautammer

Same problem

Losses avatar Aug 26 '22 11:08 Losses

Context

I was having this issue since I upgraded the plugin from 7.4.3 to 10.x : no purchase (consumable or non-renewing) made on production app in Apple Store, for almost a year.

The problem is also related to #1155, #1248 at least.

It concerns a lack of validator implementation (my case).

Problem

What was working after plugin upgrade :

  • IAP on Android in dev App
  • IAP on Android in production App
  • IAP on iOS in dev (sandbox) App after the first installation from xCode

What was not working after plugin upgrade :

  • IAP on iOS in dev App without reinstalling after a 1st purchase
  • IAP on iOS in production App

What parts of the API doc lead me to think my initial user code (see below) should work after the plugin upgrade :

Some unthoughtful users will try to use fake "purchases" to access features they should normally pay for. If that's a concern, you should implement receipt validation, ideally server side validation.

and

Anecdotally, non-renewing subscriptions are easier to implement and test than auto-renewing subscriptions, because you don't need to deal with receipt validation or wait hours for test subscriptions to expire

To my understanding, implementing a validator was not mandatory. In fact, since a purchase of my IAProduct has to be valid on Apple, Android and Web platforms, I had already created a sort of master-validator. So I thought I don't need to use/write a platform specific one.

Solution

// old user-code (compatible till IAP plugin 7.4.3), found in the API doc: 

store.when("product").approved(function(p) {
    p.finish();
});

// in conjunction with the default plugin code:

store.validator = null;

does not work and has to be replaced by:

// new user code for IAP plugin 10.x+

store.when("product").approved(function(p) {
    p.verify();
});
store.when("product").verified(function(p) {
    if ( p.type != 'application' ) {
        p.finish();
    }
});

// in conjunction with a user "fake"`validator` :

store.validator = function(product, callback) {
    callback( true, product );    // always success!
}

Hope it helps !

vinceoralim avatar Dec 15 '22 14:12 vinceoralim