onepf / OpenIAB

Open In-App Billing for Google Play, SlideMe, Amazon Store, Nokia Store, Samsung Apps, Yandex.Store, Appland, Aptoide, AppMall and Fortumo.
http://onepf.org/openiab/
Apache License 2.0
473 stars 172 forks source link

Canceling an in-app purchase of amazon app store results in error 6 instead of IABHELPER_USER_CANCELLED #507

Closed Juweii closed 8 years ago

Juweii commented 8 years ago

Hello! I think i have found an error in implementation of the amazon app store in app purchase. In the OnIabPurchaseFinishedListener i have the following code:

        if (result.isFailure()) {
            if (result.getResponse() != IabHelper.IABHELPER_USER_CANCELLED) {
                alert(String.format(getResources().getString(R.string.purchase_failed), result.getMessage()));
            }

            return;
        }

The alert shouldn't appear if the user just cancel the in-app purchase - but it shows error 6 (Error) instead of -1005 (IABHELPER_USER_CANCELLED).

Testes on android with openiab 0.9.8.7 + amazon in-app-purchasing 2.0.61.

Any chance to check for cancellation of the purchase?

With best regards, Juergen

RomanZhilich commented 8 years ago

Amazon SDK just doesn't report reason for error, there's nothing to be done until they fix it.

Juweii commented 8 years ago

Oh ok, thank you. Can you give me a fast if-code to check for the used market (if (market == AMAZON)) so i could change the output for amazon users to a more universal error message.

Thank you! Juergen

RomanZhilich commented 8 years ago

Unfortunately there's no API for that. There are some historical reasons but it's not really relevant anymore. Easiest way for you would be to use reflection to access appstore variable.

As a more general solution I'd recommend checking out https://github.com/onepf/OPFIab . There you can use BillingResponse#getProviderName() to check billing provider.

Juweii commented 8 years ago

Ok, i will check this. Thank you!