Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android In-App Billing v3: Not receiving signatures

I'm working on a In App Store on my app, I used AndroidBillingLibrary by robotmedia, when I purchase android.test.purchased using the library the response is OK, all the data I need is in there.

The problem is, when I switched to Android In-App Billing v3 this is all received from the response, no signatures.

{"packageName":"com.my.sampleapp","orderId":"transactionId.android.test.purchased","productId":"android.test.purchased","developerPayload":"","purchaseTime":0,"purchaseState":0,"purchaseToken":"inapp:com.my.sampleapp:android.test.purchased"}

I followed exactly this sample https://developer.android.com/training/in-app-billing/preparing-iab-app.html#GetSample but there's no signatures. I even run the given sample app by Google but no luck.

I put my Base64-encoded RSA public key correctly in mHelper = new IabHelper(this, myPublicKey);

and this is my purchase code mHelper.launchPurchaseFlow(this, itempackage, 10001, mPurchaseFinishedListener);

OnIabPurchaseFinishedListener mPurchaseFinishedListener = new OnIabPurchaseFinishedListener() {
        public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
            Log.i("Billing", "purchasing: " + result.getMessage());

            if (result.isFailure()) {
                Log.i("Billing", "Error purchasing: " + result);
                return;
            } else if (purchase.getSku().equals("android.test.purchased")) {
                Log.i("Billing - signature", purchase.getSignature());
                consumeItems();
            } else {
                Log.i("Billing", "Error purchasing: " + result);
            }
        }
    };

Somehow my mPurchaseFinishedListener is not receiving anything after the purchase but the protected void onActivityResult(int requestCode, int resultCode, Intent data) is receiving something but there's no signature.

Any solutions to this? It's weird that v2 is receiving signatures and v3 is not.

like image 983
NaviRamyle Avatar asked Jan 11 '13 05:01

NaviRamyle


2 Answers

You don't get signatures for the test IDs, android.test.purchased, etc.

You'll receive signatures with real purchases.

like image 105
Rawkode Avatar answered Nov 16 '22 04:11

Rawkode


As was said by Rawkode, you no longer get signatures for test purchases (android.test.*). I took the dive and uploaded my app to the market place (just didn't publish it) using my real products.

Low and behold signatures started to be returned! I recommend amending any server side validation you are using to skip the signature check when the data contains an android.test.* item id.

like image 39
melodiouscode Avatar answered Nov 16 '22 04:11

melodiouscode