在应用程序内结算工作不更新后 - 谷歌商店应用程序、商店、工作

2023-09-12 23:57:26 作者:橡皮糖

我已经实现应用内计费我的应用程序 - 以及最近的谷歌已经更新了,previously我测试用android.test.purchased,这是工作的罚款(购买完全版和还原完整版)。

I have implemented In-App billing in my app - and very recently google has updated it,previously i was testing the in-app billing with "android.test.purchased" and it was working fine (Buy full Version and Restore full version).

现在我把更改的类从这里 https://$c$c.google.com/p/marketbilling/source/detail?r=7bc191a004483a1034b758e1df0bda062088d840

Now i took the changed classes from here https://code.google.com/p/marketbilling/source/detail?r=7bc191a004483a1034b758e1df0bda062088d840

之后,我不能够测试应用程序它给在logcat中IabHelper以下错误:在应用内计费误差:购买签名验证失败SKU android.test.purchased

After that i am not able to test the app it gives the following error in the Logcat "IabHelper: In-app billing error: Purchase signature verification FAILED for sku android.test.purchased ".

我已经检查了我的钥匙,包名,并且也应用版本都是正确的,有任何一个面对这个问题?

I have checked with my key, package name and also app version all is proper, has any one faced this issue?

请帮我这个。

推荐答案

这是因为在已经变化,在新修复的安全类verifyPurchase()方法。让我来告诉你什么是确切的问题是:

This is because of the verifyPurchase() method in the Security class that has been change in the new fixes. Let me show you what is the exact problem is:

安全类的变化

OLD code

 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;
    }

新的code

public static boolean verifyPurchase(String base64PublicKey,
            String signedData, String signature) {

    if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey)
                || TextUtils.isEmpty(signature)) {
        Log.e(TAG, "Purchase verification failed: missing data.");
            return false;
    }

    PublicKey key = Security.generatePublicKey(base64PublicKey);
    return Security.verify(key, signedData, signature);

}

据我已经搜查,从新code测试,

According to what I have searched and tested from New code,

为什么会发生,因为当我们使用的是像android.test.purchased虚拟产品,我们不会得到任何签名。因此,在旧code这是工作好,因为我们是返回true,即使签名不给,并为新的code,我们返回false。

Why it happens because we will not get any signature while we are using dummy product like "android.test.purchased". So in the old code it is working good because we were return true even if signature is not given and for the New code we are returning false.

有关签名的详细信息无效或link1和链接2

more information about the signature data null or blank from link1 and link2

所以,我建议你刚刚更换,而不是新的code法老code方法verifyPurchase()。

So I suggest you just replace old code method verifyPurchase() instead of New Code method.

我觉得可能是新的code将正常工作为真正的产品,但不是在虚拟的产品。但我却为真正的产品还没有测试过。

I think may be New Code will work fine for the real product but not in the dummy product. But yet I have not tested for the real product.

让我寻找更多关于这一点,所以他们改变了code,什么是背后的目的。

Let me search more about this, why they changed code and what is the purpose behind that.

编辑:

BuildConfig.DEBUG也会给你的测试购买的解决方案。

BuildConfig.DEBUG will also give you the solution for the test purchases.

在verifyPurchase我改变了返回false 来:

In the verifyPurchase I changed return false to:

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

但你应该知道只有在使用这个测试场景的。

but you should be aware to use this only in test scenario's.

这将返回true,如果你有一个调试版本,并签名数据丢失。由于BuildConfig.DEBUG将是虚假的生产版本,这应该是确定。但更好的是消除这种code一切都调试后。

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

我已经编辑了一些code在verifyPurchase()方法,下面的检查:

I have edited some code in the verifyPurchase() method, check it below:

public static boolean verifyPurchase(String base64PublicKey,
        String signedData, String signature) {

    if (signedData == null) {
        Log.e(TAG, "data is null");
        return false;
    }

    if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey)
            || TextUtils.isEmpty(signature)) {
        Log.e(TAG, "Purchase verification failed: missing data.");
        if (BuildConfig.DEBUG) {
            Log.d("DeBUG", ">>>"+BuildConfig.DEBUG);
            return true;
        }
        return false;
    }

    PublicKey key = Security.generatePublicKey(base64PublicKey);
    return Security.verify(key, signedData, signature);
}

我从 GVS的答案 android在应用内结算的购买验证失败。

希望这是对你有帮助。

 
精彩推荐
图片推荐