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

iOS 10.2.1 breaks purchase

Open pietrot opened this issue 8 years ago • 45 comments

New users are no longer able to purchase a product. In our case, a subscription. The apple popup does not appear. Interesting enough, the plugin is still able to fetch products.

If you need further info, don't hesitate to contact me.

This is super critical.

Your code / steps to reproduce

            if (window.inAppPurchase) {
                window.inAppPurchase.buy(product_id).then(function(data) {
                    Utils.log(JSON.stringify(data));
                    // Important: Unlike in-app products, subscriptions cannot be consumed.
                    //Utils.log('consuming transaction-id: ' + data.transactionId);
                    //deferred.resolve(window.inAppPurchase.consume(data.type, data.receipt, data.signature));
                    deferred.resolve();
                }).catch(function (error) {
                    Utils.log(JSON.stringify(error), 'error');
                    deferred.reject(error)
                });
            } else {
                deferred.resolve(true);
            }

Console output


Type of product you are working with consumable/non-consumable/subscription

Subscription

Version of cordova

6.5.0

Version of iOS/Android

iOS 10.2.1 (confirmed working in previous versions)

pietrot avatar Feb 21 '17 12:02 pietrot

Hmm... Sandbox users are able to complete the purchase.

pietrot avatar Feb 21 '17 13:02 pietrot

My guess is that the problem is the rmstore include. Looking at the rmstore github page there are lots of issues with it. Having same issues, all works fine in test (Sandbox / TestFlight), but as soon as it goes live, the people that did the TestFLight have the same issues. Since the iOS update I get on a daily basis complaints that they get charged and not receiving the IAP update (non-consumable in my case).

Seoptics avatar Feb 23 '17 08:02 Seoptics

In your case, from what I understand, they get charged for the purchase regardless if the popup is triggered. If so, interesting...

This is becoming super critical as my client has just received a negative review.

Any thoughts on how we can fix this?

Again, the IAP popup is not displayed when selecting a product (in my case subscription) for purchase. Production fails for users with ios 10.2.1. Sandbox and previous versions work perfectly.

pietrot avatar Feb 24 '17 19:02 pietrot

Hi there, I think we are seeing a similar issue in our app. Everything worked fine in the sandbox environment; i.e., TestFlight with an ad-hoc provisioning profile, but as soon we went live in the App Store, our callbacks were never being called after a subscription purchase. We could see from navigating to the App Store manage subscription URL that the subscription was being created in the App Store correctly, but our JS callbacks were never being called.

I found this particular thread in the Apple dev forums (https://forums.developer.apple.com/thread/20194). that might be related.

I've just started auditing the code in this plugin and have forked it. I do see some issues where this plugin does NOT follow Apple's guidelines for how to correctly write In-App Purchase code (for example you MUST start observing the queue as soon as possible after app startup). There also seem to be an issue where the setKeepCallbackAsBool: selector should probably be called earlier, outside of the success transaction block. I'm going to play around with the code and make sure that I also do the right thing in my own JS code (add a callback handler as soon as possible after the app launches). I think given that I feel there might be some things about this code that don't fit with what I've learned about Apple's best practices, and there are people complaining about other issues on Apple's end, I think people need to be aware that they could be left high and dry with IAP and this plugin. Especially pernicious is the fact that things seem to work fine when using an adhoc provisioning profile (sandbox) vs production.

ed-at-work avatar Mar 07 '17 18:03 ed-at-work

Another architectural problem with this plugin seems to be that it allows RMStore to call finishTransaction: before executing the callback, which isn't really the recommended way to do things as far as I can tell.

ed-at-work avatar Mar 07 '17 23:03 ed-at-work

Guys, please write the resolve of the problem if you can resolve it. It's so helpful information.

centrual avatar Mar 08 '17 20:03 centrual

Very insightful! Thank you @ed-at-work for auditing the codebase. Yes, it would be great to get some feedback from the repo collaborators.

pietrot avatar Mar 08 '17 21:03 pietrot

Any update on this? A lot of my customers are complaining they are not getting access after buying. I had to implement a "promo code" work around that I validate them on my end, but then they still can never restore the purchase.

Has anyone used the other Ionic In-App Purchase plugin https://github.com/j3k0/cordova-plugin-purchase? It looks a little more complicated but they are at least updating it often still.

csumrell avatar Mar 09 '17 17:03 csumrell

I'll try to look into it in the next few days.

@pietrot were you able to reproduce it locally?

@Seoptics does it only happen with 10.2.1 in your case as well or does it affect older versions?

AlexDisler avatar Mar 09 '17 18:03 AlexDisler

For the record, I looked at that other plugin as well (j3k0) and it has some issues also. For example it seems via its public API to make a refreshReceipt request even just when you want to get a list of product Ids from the App Store, which causes the App Store login prompt to be shown to users. That's definitely against Apple's guidelines and is poor UX. So I won't be using that one either.

Right now I think I may end up writing my own plugin. Hopefully I can convince my employer to make it open source when it's done in a couple of days. It will probably be iOS only at first.

ed-at-work avatar Mar 09 '17 20:03 ed-at-work

@ed-at-work j3k0 updated the plugin 1 week ago. Did you checked with latest update? I asking because i currently changing my plugin to j3k0's plugin.

centrual avatar Mar 09 '17 20:03 centrual

@centrual what I can see its only the MicroPrices, an Android only thing. All problems what I can read here are iOS related.

@AlexDisler Yes, started with iOS 9.x.x. Tested then on different iOS till the last one, all failed with the same problem. Buy again and the users get a message they already own it, but then nothing happens, on restore nothing is restored. See issue #113 for more info.

Seoptics avatar Mar 09 '17 21:03 Seoptics

@AlexDisler yes, non-consumable, I know only once. But users get charged but the code never leaves the .buy() function, cause the first thing that should happen in the .then() of the .catch() is to hide the ionicLoading ($ionicLoading.hide()), never happens... but with the 'but again' I mean you can check that the user owns it and the message from iOS 'restore for free' never happens, nor the restore function restores the purchase.

Seoptics avatar Mar 09 '17 21:03 Seoptics

Twice (as most recent as today) I've had users purchase a subscription, and then never receive a callback on purchase response. I implement some additional logging to pull down receipts in the mean time so that I can manually create the purchase when this situation arises, but it's really bad for the user as they (officially) have paid for the subscription but have to call in to get things manually activated.

Let me know if you guys need some help, definitely willing to jump in here as it's more urgent than not.

Cheers -Mark

markshust avatar Mar 14 '17 14:03 markshust

I also received complaints from some users who did not have their in-app product activated after their purchase. When they try to restore their purchases they get a message indicating that they cannot connect to the iTunes store. These users had iOS 10.2.1, except one on iOS 10.3 (beta). Then I guess the problem will persist on this upcoming version of iOS.

Hope someone can find a solution soon, they would be a real hero !

Amaury.

nilebma avatar Mar 14 '17 15:03 nilebma

Hi there, no new infos on this? It is a serious problem with an app in the store... I don t have enough experience to maintain this project unfortunately.

matthieu80 avatar Mar 17 '17 09:03 matthieu80

This is still not working in iOS 10.3 live release.

@AlexDisler for us who are in production with this plugin: Do you plan to fix this within the next few days or would you recommend we switch to cordova-plugin-purchase?

A quick reply would be 👍 .

kristfal avatar Mar 31 '17 11:03 kristfal

This project is no longer maintained... as stated on the front page.

The plugin you mentioned had the same problems, that was the reason I switched to this one. But last time i ised it was 6 months ago. Looking at the changes the issue is not fixed.

Seoptics avatar Mar 31 '17 12:03 Seoptics

Hey @kristfal. On Mar 9, 2017 the author committed an updated to the README: This project is no longer maintained

We can most likely assume that it will not be fixed by the author.

The problem may also be with the rmstore dependency.

pietrot avatar Mar 31 '17 12:03 pietrot

Curious: has anyone tried to fork and come up with a solution?

pietrot avatar Mar 31 '17 12:03 pietrot

No, but as gar as i tested, this plugin worked fine, but the rmstore had many issues for me. Looking at the rmstore github page it has sooo many issues, also same as I have. My solution was make all free for the time being till there is a plugin that is updated to the today standards.

Seoptics avatar Mar 31 '17 12:03 Seoptics

What is worrisome is the fact that robotmedia/RMStore has not been updated for quite a while. The majority of purchase plugins require this dependency.

@kristfal What is your issue exactly? I am assuming there is no way for you to adopt @Seoptics solution in the meantime.

pietrot avatar Mar 31 '17 12:03 pietrot

Has anyone used https://github.com/j3k0/cordova-plugin-purchase ? This looks solid and was recommended by this package author.

markshust avatar Mar 31 '17 12:03 markshust

@markoshust Awesome! It would be great to get some insights in using this plugin. I have not used it yet.

pietrot avatar Mar 31 '17 12:03 pietrot

@markohust, that plugin had the same issues, for me with non-consumables.

People het charged, but that and thus plugin never activate the IAP. Can read my issues here, made some topics. One with a 'work-around' solition. But that solution is nog 100% waterproof.

Seoptics avatar Mar 31 '17 12:03 Seoptics

@pietrot Thanks for the info. I'm currently migrating to the cordova-plugin-purchase repo and will request an expedited review from Apple once the migration is complete. I am aware of the shortcomings of that plugin (ugly API and requesting reciepts on store.refresh ), but it is better than a non-working plugin.

It is a shame this plugin died, as the API and ease of use was very nice.

I'll keep you posted on the transition. Hopefully it will be a couple of hours to complete the migration and verify that it works on iOS and Android.

kristfal avatar Mar 31 '17 12:03 kristfal

I'm not working on this plugin anymore because I'm busy with other obligations and I no longer use cordova, but just a few notes:

  • This plugin doesn't have almost any logic itself and is just a thin wrapper around RMStore. If someone will work to try and figure out the problem, I'd suggest to first try to find if the issue is with the js that calls RMStore or with RMStore (could be either).
  • There were no updates to this plugin for a while. I'm not sure what could have caused it to stop working in newer ios versions or if it had this issue from the beginning. Also, you mentioned it only happens in production and not in sandbox. It will be hard to find the issue if there's no way to reproduce it locally on the device.
  • As for a recommendation - instead of using cordova, I started using a wkwebview directly and it works great for me, however it does require using swift also. I use StoreKit for in app purchases and didn't see any issues.
  • I used cordova-plugin-purchase before using this plugin and it worked for me. I made this plugin because I personally wanted a promises based API and to use a popular library like RMStore.

If anyone is interested in being added as a maintainer to this repo and on npm let me know and I'll add you. Sorry I couldn't be more of a help.

AlexDisler avatar Mar 31 '17 16:03 AlexDisler

@AlexDisler and the rest of you:

I implemented cordova-plugin–purchase, only to find it didn't work against the AppStore sandbox either. It seems like there is a range ongoing issues with the AppStore sandbox that prevents new purchases from working. The same issue is affecting this plugin in the sandbox environment which is what I was stuck with earlier.

With that root cause identified, we decided to spend a bit of cash in the AppStore 🎉 to test this plugin in our live app. We're able to subscribe via TouchID and password on iOS10.3 and iOS10.2.1 for accounts with both existing purchases and brand new accounts without any previous purchases. We did not experience any issues at all.

Our tests were rather limited, and I wouldn't call them conclusive, but so far – I'd say this plugin is working with iOS10.2.X and newer.

If we could get a new maintainer for this repo (I'm not a seasoned iOS dev and don't have much to contribute with), then that would be really great because the foundation is solid. The JS API is far easier to work with than cordova-plugin-purchase and the project seems cleaner.

I'd recommend you guys all go test your purchases in the live environment and return your findings here. I'd be happy to share our JS implementation if anyone of you would like to see that as well.

kristfal avatar Mar 31 '17 18:03 kristfal

Uh.. Just wanted to start implementing in app purchases into my app and found the non maintained notice... Is there any known alternative for cordova apps which are still working on android and ios?

Screeze avatar Apr 01 '17 14:04 Screeze

FYI, this ticker is a bit of a misnomer. The plugin still works. It seems very occasionally, the success response after IAP purchase doesn't get delivered, but from what I can tell this plugin is just a wrapper for RMStore, probably where the "bug" lies.

Diagnosing occasional bugs is the hardest thing ever. We need to be able to replicate and simulate the bug routinely in order for it to be fixed.

markshust avatar Apr 01 '17 14:04 markshust