Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed transaction keeps replaying over and over #49

Open
PyCoder040 opened this issue Oct 26, 2011 · 2 comments
Open

Failed transaction keeps replaying over and over #49

PyCoder040 opened this issue Oct 26, 2011 · 2 comments

Comments

@PyCoder040
Copy link

I made the mistake of not using my public key when trying to execute a purchase of a non-managed, non-test product id. Obviously this failed; no big deal - this is the expected behavior. I have since fixed my code to use my public key. Now, test product-id's purchase just fine. But each time I purchase a test product id, I get TWO onPurchasedStateChanged. One is the successful transaction for the intended purchase, but the second is a CANCELLED state for the previously failed non-mananged non-test product ID that I tried to buy without using my public key.

I have since cleared data, and uninstalled my app, as well as clearing data on the Market app. Upon reinstalling my app, and re-agreeing to the Market app showing me its TOS, I start my app, do a test purchase and low and behold that failed buy is STILL generating CANCELLED states for onPurchasedStateChanged. I have rebooted the phone and cleared data until Im about to scream. Where is the bad purchase attempt coming from? I KNOW my app is not trying to do a buy with the offending product id.

Please help!

@PyCoder040
Copy link
Author

Oh I forgot to mention.... At one point, I did successfully buy my non-test product ID using a test account. I then cancelled the order in my google marketplace. Is this where my unwanted CANCELLED response is coming from? If so, how do I "acknowledge" it so it goes away?

@dhendo
Copy link

dhendo commented Jan 25, 2012

I was seeing this, and figured out the issue...

If you get failed purchase / refund notifications, they are not, by default, acknowledged to google by the billing library - so google will re-send them.

If you look in BillingReceiver:

    ArrayList<String> confirmations = new ArrayList<String>();
        for (Transaction p : purchases) {
            if (p.notificationId != null && automaticConfirmations.contains(p.productId)) {
                confirmations.add(p.notificationId);
            } else {
                // TODO: Discriminate between purchases, cancellations and
                // refunds.
                addManualConfirmation(p.productId, p.notificationId);
            }
            storeTransaction(context, p);
            notifyPurchaseStateChange(p.productId, p.purchaseState);
        }

I changed this to:

ArrayList<String> confirmations = new ArrayList<String>();
        for (Transaction p : purchases) {
            if (p.notificationId != null && automaticConfirmations.contains(p.productId)) {
                confirmations.add(p.notificationId);
            } else {

                // TODO: Discriminate between purchases, cancellations and
                // refunds.

                if (p.notificationId != null) {
                    // This is probably a cancellation / refund - go ahead
                    // and confirm it anyway
                    confirmations.add(p.notificationId);
                }
                // addManualConfirmation(p.productId, p.notificationId);
            }
            storeTransaction(context, p);
            notifyPurchaseStateChange(p.productId, p.purchaseState);
        }

This does mean that no action is taken when a cancellation / refund occurs, but the impact of that will vary by application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants