distriqt / airnativeextensions

DEPRECATED: Original repository of the distriqt native extensions and is no longer maintained. Please see our site for the latest ANEs
https://airnativeextensions.com
2 stars 0 forks source link

In App Billing Problem #90

Closed Zagrava closed 10 years ago

Zagrava commented 10 years ago

This bug [http://distriqt.uservoice.com/forums/199650-general/suggestions/5507879-in-app-billing-problem] apparently partially corrected. Here is listing of the application example. I'd like to have a working version for testing In App Billing.

TestInAppBilling.as - example

// private static const TEST_PRODUCT_ID : String = "com.distriqt.test.background1"; // private static const TEST_PRODUCT_ID : String = "com.distriqt.test.subscription1";

    private static const TEST_PRODUCT_ID    : String = "android.test.purchased";

// private static const TEST_PRODUCT_ID : String = "android.test.canceled"; // private static const TEST_PRODUCT_ID : String = "android.test.refunded"; // private static const TEST_PRODUCT_ID : String = "android.test.item_unavailable";

part 1 :: run app ::

InAppBilling.isSupported: true InAppBilling.service.version: 2.6.Android.1.6 click screen to start test click InAppBilling setup success InAppBilling getting products: android.test.purchased InAppBilling products loaded received:android.test.purchased

InAppBilling restore success

CLICK TO PURCHASE: android.test.purchased click InAppBilling makePurchase(android.test.purchased) true InAppBilling purchase failed [-1003] :: response:unknown

part 2 :: stop app ::

part 3 :: next run pp ::

InAppBilling.isSupported: true InAppBilling.service.version: 2.6.Android.1.6 click screen to start test click InAppBilling setup success InAppBilling getting products: android.test.purchased InAppBilling products loaded received:android.test.purchased InAppBilling purchase success android.test.purchased:transaction:purchased:::: transactionId.android.test.purchased

InAppBilling restore success

CLICK TO PURCHASE: android.test.purchased click InAppBilling makePurchase(android.test.purchased) true InAppBilling purchase failed [7] :: response:item:already:owned

marchbold commented 10 years ago

Hi,

What seems to be the problem? Looks like you are successfully purchasing an item and then restoring it but not consuming the purchase before you attempt to purchase again? This results in the error "already owned"

A consumable needs to be consumed before it can be purchased again.

Regards, Michael

Zagrava commented 10 years ago

Hi. After the purchase is called purchase_failedHandler, and not expected purchase_successHandler (by logs part1 CLICK TO PURCHASE: android.test.purchased click InAppBilling makePurchase (android.test.purchased) true InAppBilling purchase failed [-1003] :: response: unknown ) example source code has not been edited, used as it is. Maybe something I do not understand?

marchbold commented 10 years ago

Hi,

If I understand your situation this is occurring because you cannot purchase a consumable product twice until it has been consumed. i.e. you need to call something like the following:

InAppBilling.service.consumePurchase( new Purchase("com.distriqt.test.exampleProduct") );

There's more information about this in the documentation:

http://docs.airnativeextensions.com/inappbilling/docs/com/distriqt/extension/inappbilling/InAppBilling.html

The example code isn't a complete functional application for your case. It's just used to demonstrate the concepts here as there are many different products and ways to use them.

marchbold commented 10 years ago

Right,

So the [-1003] error is the IABHELPER_VERIFICATION_FAILED error, meaning the purchase could not be verified. This is unfortunately the case with the android test transactions.

I'll look to add a workaround in a future release, but you can just as easily do this in your testing, ignoring the 1003 error while in debug mode, treating it as a success. Or you should look into creating your own product ids and a test account as described here:

http://developer.android.com/training/in-app-billing/test-iab-app.html

Cheers