I am currently trying to configure my app for in app purchase, but it just won't work. Every time I try to start the purchase flow it says "This version of the applications is not configured for billing through Google Play". I am quite sure that I walked through al necessary steps to make it work. I also tested SKU-Id "android.test.purchased", which works fine.
base64EncodedPublicKey is def. correct and exactly teh same like the code from the developer console
I did not forget <uses-permission android:name="com.android.vending.BILLING" /> in my manifest
I have applied the google account that I am using on my testing device as a tester account in the developer console
I am using the exactly same APK on my device an in the developer console. I installed it on my device via adb -d install
So any ideas what I could have done wrong?
This is my code:
(onCreate)
base64EncodedPublicKey
iabHelper = new IabHelper(this, base64EncodedPublicKey);
iabHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
#Override
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
// Oh noes, there was a problem.
Log.d(PURCHASE_TAG, "Problem setting up In-app Billing: " + result);
} else if (result.isSuccess()){
// Hooray, IAB is fully set up!
Log.d(PURCHASE_TAG, "Setup completed: " + result);
iabHelper.queryInventoryAsync(true, null, queryFinishedListener);
}
}
});
(onActivityResult)
if (iabHelper.handleActivityResult(requestCode, resultCode, data)) {
Log.d("TAG", "onActivityResult handled by IABUtil.");
return;
}
(Button click for starting burchase flow)
if(isPremium){
saveImageToGallery(imageState.image);
} else if (iabHelper != null) {
iabHelper.flagEndAsync();
purchaseItem(SKU_TEST);
(purchaseItem())
private void purchaseItem(String sku) {
iabHelper.launchPurchaseFlow(this, sku, 10001,
purchaseFinishedListener);
}
(listeners)
IabHelper.QueryInventoryFinishedListener
queryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory)
{
if (result.isFailure()) {
// handle error
return;
} else if (result.isSuccess()){
Log.d("$$$$$$$$$$$$$$$", "" + result);
}
}
};
IabHelper.OnIabPurchaseFinishedListener purchaseFinishedListener
= new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase)
{
if (result.isFailure()) {
Log.d("ERROR_TAG", "Error purchasing: " + result);
return;
}
else if (purchase.getSku().equals(SKU_TEST)) {
// give user access to premium content and update the UI
isPremium = purchase.getSku().equals(SKU_TEST);
}
}
};
I think you should check the key store you signed your apk. You must use same key store for apk that has uploaded to Google Play and test.
I hade the same problem, I fixed it by:
Go to play store developer console
Settings > Manage Testers, then add your another test email, not the one you use in publishing apps.
Again under Developer Console, Account Details (scroll down) > License Testing and add the emails of your users who will test your
app.
On your device, login in play store with one of the test emails 3 you allowed.
Launch you app and make in app purchase. There should be fixed.
more https://developer.android.com/google/play/billing/billing_testing.html
Summary:
Related
I'm testing google's in-app billing. I follow the instruction of google in-app billing training, using the IabHelper.
I setup the IabHelper successfully.
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d("GooglePay", "Setup finished.");
if (!result.isSuccess()) {
// Oh no, there was a problem.
Log.d("GooglePay", "Problem setting up in-app billing: " + result);
return;
}
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null) return;
mBroadcastReceiver = new IabBroadcastReceiver(GooglePayPlugin.this);
IntentFilter broadcastFilter = new IntentFilter(IabBroadcastReceiver.ACTION);
mActivity.registerReceiver(mBroadcastReceiver, broadcastFilter);
}
});
Then, I call the purchase API of IabHelper.
try {
mHelper.launchPurchaseFlow(mActivity, productID, RC_REQUEST,
mPurchaseFinishedListener, payload);
} catch (IabAsyncInProgressException e) {
Log.d("GooglePay", "Error launching purchase flow. Another async operation in progress.");
}
But, I always got a popup windows says: "从服务器检索信息时出错。[DF-DFERH-01]", as the following picture.
The logcat information is in attated.
Please check with your code with following steps:
STEP: 1
check sdk manager with sdk tool is updated with Google Play Billing Library and Google play services
STEP: 2
Create an Android project and add billing permission to your Android project’s manifest file.
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.INTERNET" />
STEP: 3
Adding the AIDL file to your project
1.By right click on you app-level folder>> Folder>> AIDL folder
2.Example for in app billing create directory or folder or package –> com.android.vending.billing
3.Then copy paste file in this package
After doing all this you will get error in other InApp billing
supportive classes like IabHelper for importing that
InAppBillingService.aidl, to resolve it go to build.gradle and
readjust your directory for com.android.vending.billing which is not
correct format at the time of com.android.vending.billing directory or
package creation
like:
sourceSets { main { aidl.srcDirs = [‘src/main/aidl‘] } }
STEP: 3
Update dependencies in build.gradle file
STEP: 4
Initiate a Connection with Google Play
(Make sure base64EncodedPublicKey is right for your product)
(Base64EncodedPublicKey means your license key from google play console)
/************Setting Up Google Play Billing in the Application***************/
mHelper = new IabHelper(this, base64EncodedPublicKey);
// enable debug logging (for a production application, you should set this to false).
// mHelper.enableDebugLogging(true);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(#NonNull IabResult result) {
if (!result.isSuccess()) {
Log.d(TAG, "In-app Billing setup failed: " + result);
complain("In-app Billing setup failed:: " + result);
} else {
Log.d(TAG, "In-app Billing is set up OK");
}
}
});
/************Setting Up Google Play Billing in the Application***************/
STEP: 5
For testing purpose use following item_sku:
static final String ITEM_SKU = "android.test.purchased";
static final int RC_REQUEST = 10001;
in case of live use live ProductID which are you creating.
STEP: 6
Implementing onActivityResult Method for handling result
#Override
protected void onActivityResult(int requestCode, int resultCode,Intent data)
{
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
}
Implementing OnIabPurchaseFinishedListener
Implementing QueryInventoryFinishedListener
Implementing OnConsumeFinishedListener
STEP: 7
make sure your device having updated Google play services
STEP: 8
calling the purchase API of IabHelper.
mHelper.launchPurchaseFlow(mActivity, ITEM_SKU,
RC_REQUEST,mPurchaseFinishedListener, mPayload);
STEP: 9
For More please reference with following link:
https://developer.android.com/google/play/billing/billing_integrate.html#billing-permission
https://developer.android.com/google/play/billing/billing_library.html#connecting
I hope this will help you.
I solved this issue eventually, put my answer here, hope it help those who met the same problem like me.
mHelper.launchPurchaseFlow(mActivity, productID, RC_REQUEST,
mPurchaseFinishedListener, payload);
The "payLoad" parameter is too long, I set the payload to empty string, then the problem is sloved, no more df-dferh-01.
It's nothing to do with the VPN, nothing to do with the google library, just because the payload is too long for google play service interface.
In my case the issue was setting wrong SubscriptionUpdateParams. If you use subscriptions, you probably have a code that sets OldSkuPurchaseToken. If you set wrong data there, you get this error.
I am trying to verify whether product is purchased or not from store.
For that I have used the below code :
mHelper.queryInventoryAsync(mGotInventoryListener);
And call back is as mentioned below :
IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished.");
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null) return;
// Is it a failure?
**if (result.isFailure()) { // This fails in our case**
complain("Failed to query inventory: " + result);
return;
}
}
};
But every time I am getting same error as shown in below attached screen.
I have tried with below mentioned steps but failed to get success.
"base64EncodedPublicKey" verified from our google play account where app is launched in alpha testing mode
Application is signed with release keystore
"base64EncodedPublicKey" - copied to notepad first and then copy to java file (read somewhere in blogs for this solution) , but that has not work for me.
Can anybody suggest for the same. Please let me know if I need to add something in order to solve this issue?
Are you trying to purchase android.test.purchased or another item? If you are using android.test.purchased, check this answer, it should answer your question: Android in app purchase: Signature verification failed
Found the solution :)
There was an issue with registering a broadcast receiver.
Plese find below code of startSetup method which is registering broadcast receiver that was missing from the following snippet.
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
// Oh noes, there was a problem.
Log.d(TAG, "Problem setting up In-app Billing: " + result);
} mBroadcastReceiver = new IabBroadcastReceiver(MainActivity.this);
IntentFilter broadcastFilter = new IntentFilter(IabBroadcastReceiver.ACTION);
registerReceiver(mBroadcastReceiver, broadcastFilter);
// Hooray, IAB is fully set up! }});
I am trying to test In App purchases for my android app:
I already read the android developer sites about testing and I already have worked successfully with the play stores build in test/fake product-items like android.test.purchased, android.test.canceled ...
Now I would like to test In App purchases with my own real products. Therefore I have specified my own products in the Google Play Store Developer Console.I also have added test account in LICENSE TESTING then I have published the app in beta. the version number and build number of the app publish in beta is the same to the app that I install on android device for testing.
I have compare base64EncodedPublicKey and is the same to Base64-encoded RSA public key to the app in the console.
Android device that I am using to purchase the item. I have reset the google play to have only one account that is the account that has been added already for testing in Android console. And I have added the test account to for the beta app that i have published. then I have download the app to my device.
My question is: i have already make everything as I read the android guideline and some tutorial. but why when I click button to buy the item, I have this error: This version of the application is not configured for billing through google play. check the help center for more information.
I have publish my app nearly two weak ago. but i still got this error.
Here is my code:
#Override
protected void onStart() {
super.onStart();
//Toast.makeText(DetailActivity.this, "On Start", Toast.LENGTH_SHORT).show();
String base64EncodedPublicKey ="";
mHelper = new IabHelper(this, base64EncodedPublicKey);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
#Override
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
Log.d(TAG, "In-app Billing setup failed: " + result);
Toast.makeText(DetailActivity.this, "Fail", Toast.LENGTH_SHORT).show();
} else {
Log.d(TAG, "In-app Billing is set up OK");
Toast.makeText(DetailActivity.this, "Success", Toast.LENGTH_SHORT).show();
}
}
});
}
#Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data)
{
if (!mHelper.handleActivityResult(requestCode,resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
}
public void buyMethod(View v){
//mHelper.launchPurchaseFlow(this, ITEM_SKU, 10001, mPurchaseFinishedListener, "storyone");
mHelper.queryInventoryAsync(mGotInventoryListener);
}
//make purchase payment
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener
= new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase)
{
if (result.isFailure()) {
Log.d(TAG, "Error purchasing: " + result);
Toast.makeText(DetailActivity.this, "Buy Fail", Toast.LENGTH_SHORT).show();
return;
}
else if (purchase.getSku().equals(ITEM_SKU)) {
//
Toast.makeText(DetailActivity.this, "Buy Success", Toast.LENGTH_SHORT).show();
}
}
};
//check use has already make payment
IabHelper.QueryInventoryFinishedListener mGotInventoryListener
= new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {
if (result.isFailure()) {
// handle error here
}
else {
// does the user have the premium upgrade?
boolean mIsPremium = inventory.hasPurchase(ITEM_SKU);
if (mIsPremium){
Toast.makeText(DetailActivity.this, "You already buy this product", Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(DetailActivity.this, "Not Yet buy this product", Toast.LENGTH_SHORT).show();
mHelper.launchPurchaseFlow(DetailActivity.this, ITEM_SKU, 10001, mPurchaseFinishedListener, "storyone");
}
// update UI accordingly
}
}
};
#Override
public void onDestroy() {
super.onDestroy();
if (mHelper != null) mHelper.dispose();
mHelper = null;
}
You have to be a tester for this app, so you have to be listed in the beta test (or join the Google+ group for the test) AND have to enable the beta test for your account by going to the link given in Google Play developer console.
Furthermore, your application has to be signed with the same certificate as the one in the Play Store beta test, so try it with the same apk that you uploaded to Google Play (e.g. not a debug version, but the release version you uploaded).
Complete list of things required.
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.
Original answer here
I am working on my first android app. I really learned a lot on stack overflow. But I with my current problem I did not find a solution yet.
I tried to implement "in app purchase". I did the following things:
1) In the developer console I uploaded a signed apk in alpha and beta test. I also added a test user to the account and for testing I am using that account. Additionally I added some "In app products(managed)" with the status active.
2) Like described on http://developer.android.com/training/in-app-billing/index.html I downloaded the necessary lib field, copied code from the example project TrivialDrive and followed all the steps which result to the coding:
// called when the app is started
public void setupConnectionToGooglePlay(final Context context) {
this.context = context;
mHelper = new IabHelper(context, base64EncodedPublicKey);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
// Oh no, there was a problem. --> no error message shown to
// the user!
Toast.makeText(context, "No connection to google:" + result, Toast.LENGTH_LONG).show();
} else {
Toast.makeText(context, "connection to google:" + result, Toast.LENGTH_LONG).show();
// If connection is established:
get List of all in App Purchase products
getListOfInAppPurchaseProducts();
}
}
});
}
When executing this part of code I get the result, that the connection was established successfully. Hence the method getListOfInAppPurchaseProducts() is called.
private void getListOfInAppPurchaseProducts() {
IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
if (result.isFailure()) {
// no error message is shown to the user
Toast.makeText(context, "Query not successful", Toast.LENGTH_LONG).show();
} else {
String message = result.getMessage();
boolean isSuccess = result.isSuccess();
// no success message is shown to the user
List<String> skus = inventory.getAllOwnedSkus();
Map<String,SkuDetails> map = inventory.getSKUMap();
int size = map.size();
Toast.makeText(
context,
"Message: " + message + "Query successful. Mapsize:" + size, Toast.LENGTH_LONG).show();
WMGooglePlayConnection.this.inventory = inventory;
}
}
};
ArrayList<String> list = new ArrayList<String>();
list.add("test");
list.add("test2");
mHelper.queryInventoryAsync(true, list, mQueryFinishedListener);
}
Unfortunately the returned inventory does not contain any SKU Details (even the query is successful). I checked the following:
productIds
status of the product ids (active)
base64EncodedPublicKey
For testing I used a real device (Samsung ACE 2). I copied the apk file directly to the device (not downloaded from google play). Can this be a problem?
Is it somehow possible to get the SKU Details also with the emulator?
Do you have any idea what I can check?
It would be really nice if someone could help me...
I just ran into this as well. Our in app billing stuff broke right around when Google Play Service 4.4 went out. A week or two back I think.
To get your in app billing products to show up now you'll have to publish your Alpha builds but have them only visible to people on your tester list/group.
After one publishes the app then testers can download it from the Google Play Store with a link similar to this.
https://play.google.com/apps/testing/
I hope this helps.
Since one year I develop android apps. I thought it’s time now to do the next step and implement the billing system. Before I implement this new feature in my main app I thought it’s better to test it.
Last week i developed a test app the same app (with v3 billing system) like my main app (without v3 billing system). I published it and installed on my Samsung Note via Google Play. I was being able to buy and to subscribe. And it worked well.
So I deactivated the test app, copied the whole billing methods in my main app, changed the Base64 coded public RSA key and published it.
After installation and start, the app crashed every time. And the reason is only the billing system because the recent version works without the billing system well. Of course I could replace my main app with a new app which do the same like my main app, but I would lose all my user, my statistics and comments until now.
Do you know why my app cannot install the billing system with the RSA key?
Which other reasons could be responsible for this Situation?
what happens in onCreate:
mHelper = new IabHelper(this, base64EncodedPublicKey);
// enable debug logging (for a production application, you should set this to false).
mHelper.enableDebugLogging(false);
// Start setup. This is asynchronous and the specified listener
// will be called once setup completes.
Log.d(TAG, "Starting setup.");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");
if (!result.isSuccess()) {
// Oh noes, there was a problem.
complain("Problem setting up in-app billing: " + result);
return;
}
// Hooray, IAB is fully set up. Now, let's get an inventory of stuff we own.
Log.d(TAG, "Setup successful. Querying inventory.");
mHelper.queryInventoryAsync(mGotInventoryListener);
}
});
and what happens in line 960:
public IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished .");
if (result.isFailure()) {
complain("Failed to query inventory: " + result);
return;
}
Log.d(TAG, "Query inventory was successful.");
// Purchase premium monthly
Purchase purchase = inventory.getPurchase(Constants.PREMIUM);
if(purchase.getPurchaseState() == Purchase.PURCHASED_SUCCESSFULLY && verifyDeveloperPayload(purchase)){
isPremium = true;
}else{
isPremium = false;
updatePremium(purchase.getPurchaseState());
}
Log.d(TAG, "User " + (isPremium ? "HAS" : "DOES NOT HAVE") + " premium surebets for 32 days.");
Log.d(TAG, "Initial inventory query finished; enabling main UI.");
}
};