I have developed an app using Ionic Native In-App Purchases and submitted it to the Google Play Store as an Alpha release.
I could view the available purchase options:
this.iap.getProducts(this.PRODUCT_IDS).then((products: any[]) => {
...
});
I then set up a test user to test in-app purchases. I tried to make a purchase:
this.iap.buy(item.productId).then((data) => {
return this.iap.consume(data.productType, data.receipt, data.signature);
}).then(() => {
...
}).catch((err) => {
this.loading.dismiss().then(() => {
this.doAlert('Error: ' + JSON.stringify(err));
});
});
And ever since, when I try to make other purchases to test the app, I get the following when trying to get the available purchases:
Error retrieving Sku details
I have read that this error may be caused by a pending order that needs to be canceled, but I cannot find where to do so (I have looked at "Order Management", but there are no orders).
This is working perfectly on iOS, so I know my code is correct, and also on Android I could view the available purchases before I did the test purchase.
I have also read that I should wait 14 days for Google to remove test orders, but it's been 16 days today, and I still get the error.
I have also since released my app as Beta in the Play Store, but I still get the same error.
I think I found the problem, I just add the play store key in the manifest.json file inside src/ folder of the Ionic 2 project.
{ "play_store_key": "<Base64-encoded public key from the Google Play Store>" }
I hope this will help your problem too.
Related
On trying to migrate Google billing integration from version 4 to 5, I'm getting an error 'Client does not support ProductDetails' on calling queryProductDetailsAsync.
List<QueryProductDetailsParams.Product> productList = List.of(QueryProductDetailsParams.Product.newBuilder()
.setProductId("ppgapp1")
.setProductType(BillingClient.ProductType.SUBS)
.build());
QueryProductDetailsParams params = QueryProductDetailsParams.newBuilder()
.setProductList(productList)
.build();
billingClient.queryProductDetailsAsync(params, listener);
Are there any changes needed to be made on the console on migration?
And how long it'll take to complete review on submitting to closed or internal test track for Google billing integration?
I face same issue when my emulator PlayStore application version is too old (in my case it is 23.0.21...)
Update PlayStore application to newer version will solve the problem (30.9.0...)
Here is how to update the Play Store app
If you want to guide user to update the PlayStore app, you can do like
billingClient.queryProductDetailsAsync(productParams) { billingResult, productDetails ->
if (billingResult.responseCode == BillingClient.BillingResponseCode.FEATURE_NOT_SUPPORTED) {
Log.e("TAG", "Feature not supported ")
runOnUiThread {
Toast.makeText(this#MainActivity, "Please update PlayStore app", Toast.LENGTH_LONG).show()
// or AlertDialog or any error message
}
return#queryProductDetailsAsync
}
...
}
I had experienced the same problem. I couldn't find any information on why the problem is occurring. You can use it after checking whether the ProductDetail feature is supported.
BillingResult billingResult = billingClient.isFeatureSupported( BillingClient.FeatureType.PRODUCT_DETAILS );
if ( billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK ) {
// use billingClient.queryProductDetailsAsync()
}
Getting this error when I use google play version 21.2.12-21. When I use the 31.2.29-21 version of google play on another device, the item can be successfully queried. I can't use the 5.0 version of the billing library because it affects the user's payment
Issue resolved
Issue was occuring on one device and not occuring on another device with latest library.
Upon debuging I used old library on device where issue was occuring. And it was working fine on old library.
So after alot of trouble shoot I do following to resolve issue on that device with latest library code.
On device where issue is occurred
Do following
Update device OS update if there is any. In my case there was security patch update. Notification was there to update.
update play store if already not updated
Then clear data storage of play store app under setting of play store app. Then force stop play store app and then open play store app
uninstall and reinstall the android app again
After that my app shows product details as well as purchase pop up with latest billing library.
Thank you
I had to reinstall the app for the Billing client to recognize the supported product ID. I imagine that simply purged some stale cache behind the scenes.
I have an app with a subscription in Google Play.
When the user starts the app, I need to know if the user has an active subscription. This would seem an obvious thing to do, but from searching and trying to implement it, it seems impossible?
I am using Google's newer billing 2/3, following Google's tutorials,
class BillingManager implements PurchasesUpdatedListener
...
public void checkAsync() {
Log.e(TAG, "checkAsync");
billingClient.queryPurchaseHistoryAsync(BillingClient.SkuType.SUBS, new PurchaseHistoryResponseListener() {
#Override
public void onPurchaseHistoryResponse(BillingResult billingResult, List<PurchaseHistoryRecord> list) {
Log.e(TAG, "checkCached result: " + list);
if (list == null) {
return;
}
for (PurchaseHistoryRecord ps : list) {
//System.out.println("PAYMENT: " + ps.getSku() + " : " + ps.getPurchaseTime());
}
}
});
}
public void checkCached() {
Log.e(TAG, "checkCached");
List<Purchase> result = billingClient.queryPurchases(BillingClient.SkuType.SUBS).getPurchasesList();
Log.e(TAG, "checkCached result: " + result);
if (result == null) {
return;
}
for (Purchase purchase : result) {
handlePurchase(purchase);
}
}
This is how I think you're supposed to get a user's purchases. But it does not work at all, both calls return null always. It only returns the correct purchases when you reinstall the app or clear the data.
So how exactly is an app supposed to do this?
Purchasing works for the app once I enter internal testing, and download it through the Google Play link. (before that subscriptions do not work at all).
*** updated
So to further clarify:
I am using a valid test user, and subscriptions are working correctly. My question is on the what the API queryPurchases() or queryPurchaseHistoryAsync() are suppose to do.
What I am seeing, is that these only return purchases that have not be processed by the app. They seem to store that the purchase was processed in the apps data.
After the purchase these return null, after the app restarts these return null.
If I clear the app datam or reinstall the app then they return the purchase (once), then again null after restart.
From what I see, these are only useful to detect when a user reinstalls your app, or installs on a different phone. They cannot be used to determine the status of a subscription.
So my question is,
1 - is this something that just does not work in internal testing and will magically work differently when the app is release?
2 - is there a different API that your suppose to use to check the status of a subscription?
3 - are you suppose to manage subscriptions yourself in your app by storing a user preference/cookie when you acknowledge the subscription the first time so you know when the subscription expires?
You need "licenced testers". They would allow you to "sideload" your app on devices, even for debug builds. My interpretation of sideload in this case would cover installing from Android Studio build tools as well as adb install .... and other methods that don't involve the play store.
https://developer.android.com/google/play/billing/test
Ordinarily, the Google Play Billing API is blocked for apps that aren't signed and uploaded to Google Play. License testers can bypass this check, meaning you can sideload apps for testing, even for apps using debug builds with debug signatures without the need to upload to the new version of your app. Note that the package name must match that of the app that is configured for Google Play, and the Google account must be a license tester for the Google Play Console account.
I also don't see how you're using startConnection. Until that's completed successfully I wouldn't be sure you have the latest data. I wouldn't be surprised if that makes you get stale values. I would check that carefully to make sure there's no silent errors happening, by both looking at onBillingSetupFinished and onBillingServiceDisconnected. And for the time being avoid trusting queryPurchases():
https://medium.com/#NandagopalR/integrating-google-play-billing-into-an-android-application-b6eb6af176a7
The queryPurchases() method uses a cache of the Google Play Store app without initiating a network request. If you need to check the most recent purchase made by the user for each product ID, you can use queryPurchaseHistoryAsync(), passing the purchase type and a PurchaseHistoryResponseListener to handle the query result.
By the way what's the value of isReady() right before queryPurchaseHistoryAsync, and what's the value of BillingResult::getDebugMessage and BillingResult::getResponseCode?
Also, use isFeatureSupported, though it seems it's not like your problem is coming from here. But I'd advise not testing with subscriptions until you get all the moving parts working: https://developer.android.com/reference/com/android/billingclient/api/BillingClient#isFeatureSupported(java.lang.String)
Okay, figured it out, was my mistake.
I was calling queryPurchases() in my main activity onCreate(), but the BillingClient was not ready yet.
I moved it to onBillingSetupFinished() and it now returns the correct purchases.
Everything is now working as expected. You get the active subscriptions when you call queryPurchases() after an app restart.
I keep getting this response"BILLING_RESPONSE_RESULT_DEVELOPER_ERROR" when testing my in-app Subscription.
I generated signed apk of my app in release mode and uploaded on google play for alpha testing. I followed this tutorial
https://codelabs.developers.google.com/codelabs/play-billing-codelab/#0
It is working fine when testing for static response for "android.test.purchased" product. but giving above response when testing my Subscriptions.
this is the code where i getting this response
mBillingClient.startConnection(new BillingClientStateListener() {
#Override
public void onBillingSetupFinished(#BillingClient.BillingResponse int billingResponse) {
if (billingResponse == BillingClient.BillingResponse.OK) {
Log.i(TAG, "onBillingSetupFinished() response: " + billingResponse);
if (executeOnSuccess != null) {
executeOnSuccess.run();
}
} else {
Log.w(TAG, "onBillingSetupFinished() error code: " + billingResponse);
}
}
#Override
public void onBillingServiceDisconnected() {
Log.w(TAG, "onBillingServiceDisconnected()");
}
});
also, when i uploaded my apk, google asked if i want to opt-in for "Let Google manage and protect your app signing key (recommended)" so i did...
I read some solutions for my problem but all these involve one step that is "App signing" but i can't do anything there now:
https://ibb.co/d71LvCK.
i created test user too, and got link to download my app. i'm testing my app with same user. (of course different than my play store account)
Please help, thanks :)
Clear you Google Play Store app cache in settings, took me a while to figure it out
The docs say:
BILLING_RESPONSE_RESULT_DEVELOPER_ERROR: Invalid arguments provided to the API. This error can also indicate that the application was not correctly signed or properly set up for Google Play Billing, or does not have the necessary permissions in its manifest
So this indicates that some error is being made when calling the API.
Possible errors:
using the developer account instead of a separate tester gmail account (you said you aren't doing this)
Are you definitely testing with the APK from the Play store alpha channel, not the one built from your IDE? If Play is signing your app which it is, then you need to test with the one downloaded from the Alpha channel on the Play store using the Google Play app to install, not from the one signed by your IDE
I've found similar questions to this one and followed the advice without much success.
I'm writing my first app and I'm adding inapp purchases.
When 'mHelper.launchPurchaseFlow' is called the app displays the message box 'Error, Authentication is required. You need to sign in to your Google account'
I am signed in. I tried removing the account and reinstating it. i tried creating a new account and using it instead. I tried the app on two different tablets with the same result.
Here is a sample of my code. The purchase item is set up in my google developer console. My code calls 'buy_two_stars' only after mHelper.startSetup() returns a success.
The value in the purchaseprogress variable indicates it never gets past the buy_two_stars() function:
public void buy_two_stars()
{
mHelper.launchPurchaseFlow(this,"item_stars",1001,purchasedit,"");
PurchaseProgress=0;
}
IabHelper.OnIabPurchaseFinishedListener purchasedit=new IabHelper.OnIabPurchaseFinishedListener() {
#Override
public void onIabPurchaseFinished(IabResult result, Purchase info)
{
if(result.isFailure())
{
PurchaseProgress=-1;
}
else if(info.getSku().equals("item_stars") )
{
purchaseditem=info;
mHelper.consumeAsync(info,consumerfunc);
PurchaseProgress=1;
}
}
};
IabHelper.OnConsumeFinishedListener consumerfunc=new IabHelper.OnConsumeFinishedListener()
{
#Override
public void onConsumeFinished(Purchase purchase, IabResult result) {
if(result.isFailure())
{
PurchaseProgress=-1;
}
else
{
PurchaseProgress=0;
}
}
};
many thanks.
Have you published your app yet?
According to Google documentation:
"Draft Apps are No Longer Supported
Previously, you could publish a "draft" version of your app for testing. This functionality is no longer supported. Instead, there are two ways you can test how a pre-release app functions on the Google Play store:
You can publish an app to the alpha or beta distribution channels. This makes the app available on the Google Play store, but only to the testers you put on a "whitelist".
In a few cases, you can test Google Play functionality with an unpublished app. For example, you can test an unpublished app's in-app billing support by using static responses, special reserved product IDs that always return a specific result (like "purchased" or "refunded")."
Source: http://developer.android.com/google/play/billing/billing_testing.html#draft_apps
So to test with real product IDs, I'm afraid you need to publish the app.
I was having the same problem and I didn't see anything outstanding in your code. I bet you did the same as me. Uploaded your APK to alpha, beta, or production and then tried to make it work. You must PUBLISH it in the top right corner. Then wait about 12 hours for it to become fully functional.
Meanwhile there is a new tab in the Play Console called "License Testing"
... it looks about like that:
When I call IabHelper.QueryInventoryFinishedListener, It does not return any item info like
the following.
D/IabHelper(2233): Calling getPurchases with continuation token: null
D/IabHelper(2233): Owned items response: 0
D/IabHelper(2233): Continuation token: null
D/IabHelper(2233): Querying SKU details.
D/IabHelper(2233): queryPrices: nothing to do because there are no SKUs.
D/IabHelper(2233): Ending async operation: refresh inventory
I uploaded the singed apk onto GP and installed the same apk(same version and singed) in my device by using 'adb install release.apk' command.
Also I set up items on 'In-app Products' and Gmail accounts with testing access.
I wait several hours but it still says 'queryPrices: nothing to do because there are no SKUs.'.
I used 'in app billing' with another apk before,and It was fine.
I don't know why it doesn't work this time..
Sorry for my bad English.
Thanks for your time!
Just in case you stumble upon this try to:
Upload an apk file in alpha testing or beta testing tab (but do not upload an apk file in production tab if the app should not yet be available to the public)
Supply all the required information (screenshots, add test users, create and activate the in app products)
Set the app to released.
A few hours later Google Play should return the SKUs and there details.