BILLING_RESPONSE_RESULT_DEVELOPER_ERROR - android

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

Related

How to check if the user has an active subscription in Android, Google Play?

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.

Unity - Can't SignIn in Google Play Games with my App

I have published an app to Google Play and I would like to add a leaderboard to it now.
I followed some tutorials about it (on GitHub) but I still can't sign in:
void SignIn()
{
Social.localUser.Authenticate ((bool success) =>
{
if(success)
GameObject.Find("UI_TXT_NAME").GetComponent<Text>().text = Social.localUser.userName;
else
{
GameObject.Find("UI_TXT_NAME").GetComponent<Text>().text = "Inconnu";
Debug.Log("Fail to authenticate");
}
});
}
When I build and run my app on my Android Phone, this code always ends in the "else{}" statement.
Yet, after trying to Sign In, I can see the green pop-up frame from Google Play Games but authentication doesn't seem to work.
And of course I can't show the Leaderboard.
I found lots of thread on various forums about this issue but none of the answers works with me.
I do have downloaded the latest Android packages (yesterday).
I have no errors nor error messages.
I do have registered my app and copied the resources in the unity Window->Google Play Games->Setup->Android Setup.
I do have created the leaderboard in Google Play.
I do have allowed my two mail addresses to test my apps.
I must be missing something...
Subsidiary question: Is it possible to Sign In Google Play Games in Unity play mode or do I have to run it on my mobile phone every time?
To authenticate on Android you must initialize Google Play Games(not necessary for iOS).
The code necessary for GPG initialization (Android only):
PlayGamesClientConfiguration config = new
PlayGamesClientConfiguration.Builder()
.Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.Activate();
PlayGamesPlatform.DebugLogEnabled = true;
And then signing in (Android and iOS):
void SignIn()
{
Social.localUser.Authenticate ((bool success) =>
{
if(success)
GameObject.Find("UI_TXT_NAME").GetComponent<Text>().text =
Social.localUser.userName;
else
{
GameObject.Find("UI_TXT_NAME").GetComponent<Text>().text = "Inconnu";
Debug.Log("Fail to authenticate");
}
});
}
It now works (almost) properly. The solution seemed to be downloading the App from the Google Store and not "build and run" it... I thought I had done it before but today it worked...
Now it is the
Social.ReportScore (lScore, "Cgklwq6hv_sUEAIQAA", (bool success)...)
that doesn't work. Yet success ends with "true" but my leaderboard stays empty...

Error retrieving Sku details

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.

in-app billing android return authentication is required when try to subscribe to product

This is my first time to deal with In-App Billing in android
1) I am using API v3
2) I have upload alpha version of my app to be able to test then
3) I have created a subscribe product
4) This is my code to subscribe in the product
mSubscribeButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
try {
Bundle subscribeIntentBundle = mService.getBuyIntent(3, getPackageName(), "my_product_id", "subs", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
PendingIntent pendingIntent = subscribeIntentBundle.getParcelable("BUY_INTENT");
if (subscribeIntentBundle.getInt("RESPONSE_CODE") == 0) {
startIntentSenderForResult(pendingIntent.getIntentSender(), 4002, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
} else {
Toast.makeText(MainActivity.this, "Error Code: " + subscribeIntentBundle.getInt("RESPONSE_CODE"), Toast.LENGTH_SHORT).show();
}
} catch (RemoteException e) {
e.printStackTrace();
} catch (SendIntentException e) {
e.printStackTrace();
}
}
});
5) I am getting the following error
I have tried to use different devices and all have the same error, I am also logged in with my Google account and can open Google Play Store and view my apps
I have tried also to clear data of Google Play Store from app manager
Can anyone help please ??
I have the same issue previously. Go to your google developer console and make sure your app is PUBLISHED to any version(alpha, beta or prod). Then, the In app purchase will work :)
Got same problem with dreadful message:
Authentication is required. You need to sign in to your Google Account.
There were two problems for me:
I tried to buy a product in my code with identifier "com.argonnetech.wordswriting.noads" but the in app product configured in Google Play Developer (GPD) console was named simply "noads"
After changing the name of the in app product in GPD console, I had to switch it to "Active" mode
The it worked. The error message is misleading, an error like "in app item doesn't exist would be better".
Android Developer testing for in-app purchase account should following this keys.
Base64EncodedPublicKey
// Testing base64EncodedPublicKey
public static final String base64EncodedPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCg" +
"KCAQEAhNe2XQ70DceAwE6uyYJGK1dIBbZcPdlER/9EEzylr6RDU6tnGj0Tk7kceN03GKvRf/ucT+ERLL3O" +
"aHR22PXRXLZ17NZ81x6oS2vGmLyXBnjrU/I+asl8cNuLGySaoCdXxPAV+A9g6OG13dk+KY9i0O1roGpFH" +
"fsAFyKCgSqR0PMJZ1bS+wFFBYf3M4IxgBcxuuZKDmR+MztCgm5N4zc6w2CwFZn3mXeDoTg15mWDU3sZO" +
"WeRwFeynhV+FCYdDp8DpAkLk1b5IiXYFQ53wxCh/GxiKqBB6uQMmAixFjAcZV1QWfcBABae9vxiV5" +
"VAEJvOOnhPxnaT9HYadW0pQ/UbJwIDAQAB";
And item purchased key like that
ITEM_PURCHASED
// Testing ITEM_PURCHASED
public static final String ITEM_PURCHASED = "android.test.purchased";
And Starting put this code onCreate() to initialization IabHelper class for
in-app purchase,
IabHelper helper = new IabHelper(this, Constants.base64EncodedPublicKey);
helper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
Log.d("#InAppStartSetup#", "In-app Billing setup failed: " + result);
} else {
Log.d("#InAppStartSetup#", "In-app Billing setup successful.");
}
}
});
And finally purchased time on this code handle over here,
helper.launchPurchaseFlow(YOUR_ACTIVITY, Constants.ITEM_PURCHASED,
YOUR_REQUEST_CODE, mPurchaseFinishedListener, "");
Thank You Guys...
The documentation on developer.android.com seems to be outdated.
If you want to test your in-app billing without publishing it, you have to create a google group and add an alpha list of testers. See here:
https://support.google.com/googleplay/android-developer/answer/3131213?hl=en
UPDATE
As of mid 2015, this is no longer necessary. You have several new options for testing in the google play developers console.
Most of the above solutions work, but for those still having this issue, try this:
In Android Studio sign your app with the release key (This will create a signed app-release.apk file)
Then MAKE SURE you install it on your physical device using adb install path/to/your/app-release.apk (NOT through the Alpha/Beta)
Testing Your In-app Billing Application
In my case the versionCode, versionName, and applicationId were out of sync with the current version of the app on the developer console. I changed these in the build.gradle file. They were different because I rewrote the app in android studio from eclipse. After this, in app billing worked.
Below works for me:
Upload draft application as alpha or beta with some version code.
Login on device with account which has active subscription.
Install signed application on this device with same version as in alpha/beta release.

Error, Authentication is required

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:

Categories

Resources