cordova-plugin-inapppurchase
cordova-plugin-inapppurchase copied to clipboard
Restore Purchases on Android Problems
I'm testing in the Alpha stage currently on the Google Play Store. However I receive an error "Error retrieving purchase details" whenever I run restorePurchases(). I'm not running this emulated and have my account properly added as a tester.
Some Notes
- I'm able to purchase the subscription through .subscribe(product_id)
- If I try to re-purchase an already active subscription I get the expected error messages.
- If I try to run restorePurchases() I get the aforementioned error. ("Error retrieving purchase details").
- I have the app set as an alpha release and my account added as a licensed tester.
- I have the subscription product "Active" in the play store
- this bug only occurs on android.
Steps to reproduce
I do have a question here, do I need to call getProducts before restorePurchases? I have a build where I've done that and that build gets the error "Error retrieving SKU details".
this._iap
.restorePurchases()
.then(data => {
if(data) {
console.log('/////: subscription was purchased');
this._user.subscription.status = true;
}
})
.catch(reject => {
console.log('///// init error on restorePurchases');
console.log(reject);
this._user.subscription.status = false;
resolve('error on subscription');
});
Console output
06-20 09:43:03.193 3810 3810 I chromium: [INFO:CONSOLE(14523)] "///// init error on restorePurchases", source: file:///android_asset/www/build/main.js (14523)
06-20 09:43:03.194 3810 3810 I chromium: [INFO:CONSOLE(14524)] "Error retrieving purchase details", source: file:///android_asset/www/build/main.js (14524)
Type of product you are working with consumable/non-consumable/subscription
- subscription
Version of cordova
Cordova CLI: 6.5.0
Ionic Framework Version: 2.3.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4
ios-deploy version: 1.9.0
ios-sim version: 5.0.13
OS: macOS Sierra
Node Version: v7.2.1
Xcode version: Xcode 8.3.3 Build version 8E3004b
Version of iOS/Android
Android 7.0 T-Mobile LG G5
Any news on this issue? I have exactly the same problem but with a managed product.
global packages:
@ionic/cli-utils : 1.4.0
Cordova CLI : 6.5.0
Ionic CLI : 3.4.0
local packages:
@ionic/app-scripts : 1.3.0
@ionic/cli-plugin-cordova : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms : android 6.1.2
Ionic Framework : ionic-angular 3.0.1
System:
Node : v6.10.2
OS : Windows 10
Xcode : not installed
ios-deploy : not installed
ios-sim : not installed
npm : 3.10.10
Any news on this?
Sorry I meant to do a follow up and unfortunately I have no news.
The methods to test out subscriptions on both the iTunes and Play Store are woefully limited (for android you send a static product ID, and they give you the expected response back).
The furthest I've gotten is the "Error retrieving SKU details" message and haven't gotten farther.
I stopped relying on the test purchases due to so many reported issues I read and I started doing real purchases (minimum price) with a test account. I then found out the playstore key on my manifest was not the correct one provided on the developer console, fixed it and now it works.
The problem may be caused by so many things, I recommend you to check the checklist on this thread: https://stackoverflow.com/questions/11068686/this-version-of-the-application-is-not-configured-for-billing-through-google-pla even though the problem is not the same, the requirements for any successful testing are very well explained there.
Also, the accepted answer in that thread helped me tons! Good luck :)
I'll definitely check this out.
I have been very meticulous in making sure that each of these steps has been carried out:
Prerequisites:
- AndroidManifest must include "com.android.vending.BILLING" permission.
- APK is built in release mode.
- APK is signed with the release certificate(s).
- APK is uploaded to alpha/beta distribution channel (previously - as a draft) to the developer console at least once. (takes some time ~2h-24h).
- IAB products are published and their status set to active.
- Test account(s) is added in developer console.
Testing requirements:
- Test APK has the same versionCode as the one uploaded to developer console.
- Test APK is signed with the same certificate(s) as the one uploaded to dev.console.
- Test account (not developer) - is the main account on the device.
- Test account is opted-in as a tester and it's linked to a valid payment method.
I know that all of these are set properly. I still get the SKU issue. I might need to move up to testing with real payment but this isn't exactly a plan that I'd like to run with if I'm going to be putting in multiple refund requests because of testing.
@thatONEjustin Well, I think I´ve seen cases where the test purchases go successful, you can keep trying that.
In case you decide to test with real purchases, the refunding turned out to be quite simple and fast (just don´t wait too much time -days- to do it): https://support.google.com/googleplay/answer/2479637?hl=en Check the steps on "Option 2: Request a refund on the Google Play website" Hope it helps :)
So one of the issues here is tied to receipt validation.
I'm only getting to this point now since there's no specific outline that receipt validation needs to be run on subscriptions.
The solution presented in the documentation for this plugin only point towards local validation (receipt is validated on the local device).
- Apple's recommendation is to do remote server to apple server.
- https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Introduction.html
- Android's recommendation is nebulous
- https://developer.android.com/google/play/developer-api.html
Not sure if this can be closed just yet as I'm now configuring all the proper validation of receipts but at least 1 step closer to a solution here.
Just wish that subscription purchasing workflow was better outlined in the documentation. Ionic's original docs specified that subscriptions didn't need receipt validation.
Hi there,
well you certainly can use the library in your code without the receipt validation. It just means that your billing process is less secure. There are apps out there (for rooted Android devices), that fake the InAppPayment and if you don't validate it you cannot be sure that the real purchase really happened.
Both Apple and Google suggest that you implement the validation on your own server - it guarentees that your customer really paid the amount.
If you don't care about the few users that "pirate" your app, you can leave out the validation.
I've had problems all over the spectrum with this whole flow, even though it lets me complete the purchase once. This issue was related: https://github.com/AlexDisler/cordova-plugin-inapppurchase/issues/41
and this was my final solution: https://stackoverflow.com/questions/44941508/error-retrieving-sku-details
The documentation says:
"You must create a manifest.json in your project's www folder with your Android Billing Key:"
This is not correct. Instead you should add it to the manifest.json you find in the "src" folder.
This fixed the problem for me.
https://github.com/AlexDisler/cordova-plugin-inapppurchase/blob/master/README.md