Android in the application purchase confirmation billing failed

i ', having no problems with the implementation of billing in the application for Android. I receive a signature confirmation for the purchase. The first time I was tough, it was a base64 key, but I checked it many times and I still get an error, and then after I looked at the Security.java file and found this method that I edited for getting information about what was wrong:

public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) { if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey) || TextUtils.isEmpty(signature)) { if(TextUtils.isEmpty(signedData)) Log.d(TAG, "SIGNED DATA EMPTY"); if(TextUtils.isEmpty(base64PublicKey)) Log.d(TAG, "KEY IS EMPTY"); if(TextUtils.isEmpty(signature)) Log.d(TAG, "SIGNATURE IS EMPTY"); Log.e(TAG, "Purchase verification failed: missing data."); return false; } PublicKey key = Security.generatePublicKey(base64PublicKey); return Security.verify(key, signedData, signature); } 

And I get the "signature is empty." Even after I have completed the following steps: -Register apk with the release key, download it as a draft -install it on the device using "adb -d install app.apk"

I am testing real purchases. Thank.

Change the flow of purchases in order, I get an error when calling queryInventoryAsync

+21
android billing in-app-billing in-app-purchase android-billing
Nov 01 '13 at 17:29
source share
4 answers

Replace the verifyPurchase() method below. Use the old code below, the google developer is trying to resolve this error in the near future, but before you update your code, you must select the code below.

  public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) { if (signedData == null) { Log.e(TAG, "data is null"); return false; } boolean verified = false; if (!TextUtils.isEmpty(signature)) { PublicKey key = Security.generatePublicKey(base64PublicKey); verified = Security.verify(key, signedData, signature); if (!verified) { Log.w(TAG, "signature does not match data."); return false; } } return true; } 

check this link for more information:

Application billing does not work after upgrade - Google Store

Use an attempt to replace the OLD CODE method of verifyPurchase() in your project. But this should only happen when you are trying to purchase test products. Let me know about buying real products also after using this code.

Edit:

Why is this happening because we will not receive any signature while we use a dummy product, for example "android.test.purchased". Therefore, in the old code, it works well, because we returned even if the signature is not specified, and for the new code we return false.

more information about signature data, empty or empty, from link1 and link2

Therefore, I suggest that you simply replace the old verifyPurchase() code method instead of the New Code method.

I think New Code will work fine for a real product, but not in a dummy product. But so far I have not tested the real product.

or

use the GvS answer for the test, it is also a good solution for the new code.

Hope this solves your problem.

+35
Nov 06 '13 at 6:44
source share

You can use the test SKU for testing, as described here . It:

  • android.test.purchased
  • android.test.canceled
  • android.test.refunded
  • android.test.item_unavailable

These purchases will be successful (at least android.test.purchased) even in a test and debug scenario without having to cancel the purchase.

In the verifyPurchase field, I changed return false to:

  Log.e(TAG, "Purchase verification failed: missing data."); if (BuildConfig.DEBUG) { return true; } return false; 

but you should know that use this only in a test case.

This will return true if you have a debug build and no signature data. Since BuildConfig.DEBUG will be false in the assembly, this should be OK. But it is better to remove this code after everything is debugged.

+40
Nov 01 '13 at 21:12
source share

Make sure you are logged in with the right user on your phone or, for example, add your google account as a test user in the developer console.

http://developer.android.com/google/play/billing/billing_testing.html#billing-testing-static :

In some cases, reserved items may return signed static responses, which allows you to test the signature verification in your application. Reserved items only return signed responses if the user running the application has a developer or test account.

+1
Sep 17 '14 at 16:38
source share

set the return value to true

 public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) { return true; } 

after tesing discard change

0
Jan 22 '15 at 7:26
source share



All Articles