In app billing issue

2020-04-14 19:02发布

问题:

I am trying to implement in app purchasing and have had problems for days. When a user attempts to make a purchase it is successful but the app is giving an odd error that apparently dates back to os build honeycomb which prevents users from receiving the purchase until they click the buy button again.

Steps:

Make purchase

Purchase successful

No consumable given

Click purchase button again

Consumable given

Here is the error I am getting when the consumable isn't given:

Log Tag: Finsky

Log Message [1] 1.run: missing delivery data for inapp:com.mybillingproblem:one_chip

PID/TID: 26927

Code:

public void oneChip(String noVal) {
    Log.v("oneChip", "Calling launch purchase flow");
    bp.purchase(this, itemOne);
    Log.v("oneChip", "made it through launch purchase flow");
}

    bp = new BillingProcessor(this, base64EncodedPublicKey,
            new BillingProcessor.IBillingHandler() {

                @Override
                public void onBillingInitialized() {
                    Log.v("chip", "billing initialized");
                    readyToPurchase = true;
                }

                @Override
                public void onProductPurchased(String productId,
                        TransactionDetails details) {
                    Log.v("chip", productId + " purchased");
                    if (bp.consumePurchase(productId)) {
                        if (productId == "itemOne"
                                || productId == "one_chip")
                            ChipUpdate.updateChipCount(2500);
                    }
                }

                @Override
                public void onBillingError(int errorCode, Throwable error) {
                    Log.v("chip", "Error code: " + errorCode);
                    Log.v("chip", "Error: " + error);
                }

                @Override
                public void onPurchaseHistoryRestored() {
                    for (String sku : bp.listOwnedProducts())
                        Log.v("chip", "Owned Managed Product: " + sku);
                    for (String sku : bp.listOwnedSubscriptions())
                        Log.v("chip", "Owned Subscription: " + sku);
                }

            });

Note: I am using the in app billing v3 jar. I don't think this is the issue though as it has come recommended and seems to be a commonly used wrapper.

Thanks!

回答1:

How does your Activity's onActivityResult() look like? Do you have one? Usually you pass the the result to to IabHelper's handleActivityResult

like so:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    // Pass on the activity result to the iab helper for handling
    if (!mHelper.handleActivityResult(requestCode, resultCode, data))
    {
      // not handled, so handle it ourselves (here's where you'd
      // perform any handling of activity results not related to in-app
      // billing...
      super.onActivityResult(requestCode, resultCode, data);
    }
}