Packagecom.milkmangames.nativeextensions.android
Classpublic class AndroidIAB
InheritanceAndroidIAB Inheritance flash.events.EventDispatcher

Android In-App Billing



Public Properties
 PropertyDefined By
  androidIAB : AndroidIAB
[static] [read-only] The current instance of the AndroidIAB singleton.
AndroidIAB
Public Methods
 MethodDefined By
  
Do not call this directly.
AndroidIAB
  
[static] Initializes the Android Billing Extension.
AndroidIAB
  
Checks if Android Market billing service is available and running on the running device.
AndroidIAB
  
isSupported():Boolean
[static] Checks if the current platform supports the AndroidIAB extension.
AndroidIAB
  
purchaseItem(itemId:String):void
Sends a request to Android Market to purchase an item with this particular itemID.
AndroidIAB
  
Restores Managed transactions for the user.
AndroidIAB
  
startBillingService(publisherKey:String):void
Starts the billing service, which allows you to make purchases, and listen for changes in the user's purchase inventory.
AndroidIAB
  
Completely shutsdown the billing service.
AndroidIAB
  
Simulates the cancellation of a purchased item, without actually having your app published yet.
AndroidIAB
  
Simulates the refunding of a purchased item, without actually having your app published yet.
AndroidIAB
  
Simulates the successful purchase of an item, without actually having your app published yet.
AndroidIAB
  
Simulates the attempted purchase of an invalid item id, without actually having your app published yet.
AndroidIAB
Events
 Event Summary Defined By
  Dispatched when a purchase has been cancelled (by Google, or by the developer in the control panel)AndroidIAB
  Dispatched when a purchase attempt failsAndroidIAB
  Dispatched when a purchase has been refunded (by the developer, in the Market developer control panel)AndroidIAB
  Dispatched when an item has been successfully purchasedAndroidIAB
  Dispatched when the user cancelled a purchase, by closing the dialog or pressing BackAndroidIAB
  Dispatched if the billing service will not work on this deviceAndroidIAB
  Dispatched when the billing service is ready to useAndroidIAB
  Dispatched When a Transaction Restore failsAndroidIAB
  Dispatched when a restore of managed transactions has completedAndroidIAB
Public Constants
 ConstantDefined By
  TEST_ITEM_ID_CANCELLED : String = android.test.canceled
[static] Special Item ID used for a test of a cancelled item, without actually buying or cancelling anything.
AndroidIAB
  TEST_ITEM_ID_PURCHASED : String = android.test.purchased
[static] Special Item ID used for a test of the successful purchase of an item, without actually buying anything.
AndroidIAB
  TEST_ITEM_ID_REFUNDED : String = android.test.refunded
[static] Special Item ID used for a test of a refunded item, without actually buying or refunding anything.
AndroidIAB
  TEST_ITEM_ID_UNAVAILABLE : String = android.test.item_unavailable
[static] Special Item ID used for a test of an unavailable item, without actually buying anything.
AndroidIAB
  VERSION : String = 1.0.0
[static] Version
AndroidIAB
Property Detail
androidIABproperty
androidIAB:AndroidIAB  [read-only]

The current instance of the AndroidIAB singleton. You must call AndroidIAB.create() before this property is available.


Implementation
    public static function get androidIAB():AndroidIAB
Constructor Detail
AndroidIAB()Constructor
public function AndroidIAB()

Do not call this directly. Use AndroidIAB.create() to Initialize, then you can use AndroidIAB.androidIAB thereafter.

Method Detail
create()method
public static function create():AndroidIAB

Initializes the Android Billing Extension. You should check AndroidIAB.isSupported() first to ensure the platform is Android. AndroidIAB is a Singleton and you may have only one instance. After creation, you may access the instance through the static property AndroidIAB.androidIAB .

Returns
AndroidIAB — initialized instance of AndroidIAB extension interface.

Throws
Error — if AndroidIAB has already been initialized.
isBillingServiceRunning()method 
public function isBillingServiceRunning():Boolean

Checks if Android Market billing service is available and running on the running device.

Returns
Boolean — true if the current device supports Android Market Billing and is running the service.
isSupported()method 
public static function isSupported():Boolean

Checks if the current platform supports the AndroidIAB extension. Note that this only determines whether the app is running under Android (as opposed to iOS, Windows, etc.), and will NOT tell you whether the particular device has Android Market installed. Use this call before initializing AndroidIAB in order to confirm that you are on Android. (So that you can avoid initializing AndroidIAB on an unsupported platform when building a multi-platform app.) After initialization, you can call AndroidIAB.androidIAB.startBillingService() and wait for the AndroidBillingEvent.SERVICE_READY event to begin making calls. If the particular device can't support the billing service, you'll receive AndroidBillingErrorEvent.SERVICE_NOT_SUPPORTED event instead.

Returns
Boolean — true if AndroidIAB is supported; false otherwise.
purchaseItem()method 
public function purchaseItem(itemId:String):void

Sends a request to Android Market to purchase an item with this particular itemID. The item should be declared inside the 'in-app products' section of the Android Market developer panel. After the transaction attempt is complete, you'll receive either an AndroidBillingEvent or an AndroidBillingErrorEvent, depending on the result: AndroidBillingEvent.PURCHASE_SUCCEEDED will be fired if the item was bought successfully. AndroidBillingEvent.PURCHASE_CANCELLED will be fired if the item purchase has been cancelled. AndroidBillingEvent.PURCHASE_REFUNDED will be called if a refund was issued (by you) for the item. AndroidBillingEvent.PURCHASE_USER_CANCELLED will be fired if the user closed the dialog instead of completing the purchase. AndroidBillingErrorEvent.PURCHASE_FAILED will be fired if a network or other error made the purchase fail.

Parameters

itemId:String — the item id, set in your Android Market developer panel, for this item.


Throws
Error if — the Billing service is not currently running.

See also

restoreManagedTransactions()method 
public function restoreManagedTransactions():void

Restores Managed transactions for the user. A 'managed' transaction is an item that the user buys once and then owns forever, such a level pack. When your application runs, you should store a variable in SharedObject or other persistent cache, indicating whether the app has been run before. If it has never been run before, you should call restoreManagedTransactions() to fire events for any managed item the user has already purchased. This way, if the user has uninstalled your app and reinstalled it, or purchased a new device, you can 'give back' everything they've already purchased. You should not call this -every- time the app is run - only when the app appears to have never been ran before on this particular device. After calling restoreManagedTransactions(), you will receive a AndroidBillingEvent for every item the user has purchased in the past; these could be AndroidBillingEvent.PURCHASE_SUCCEEDED, AndroidBillingEvent.PURCHASE_REFUNDED, or AndroidBillingEvent.PURCHASE_CANCELLED. Each event will have an itemId property to tell you which item it refers to. When all the relevant item events have been fired, you'll receive AndroidBillingEvent.TRANSACTIONS_RESTORED.


Throws
Error if — the Billing service is not currently running.

See also

startBillingService()method 
public function startBillingService(publisherKey:String):void

Starts the billing service, which allows you to make purchases, and listen for changes in the user's purchase inventory. Before calling this, you should be listening for AndroidBillingEvent.SERVICE_READY and AndroidBillingEvent.SERVICE_NOT_SUPPORTED events. When you receive SERVICE_READY, you may begin making purchases and calling the other methods of AndroidIAB. If you receive SERVICE_NOT_SUPPORTED, the device is not capable of handling in-app billing and you will not be able to use it.

Parameters

publisherKey:String — your public key for in-app purchases. You can find this by logging into your Android Market account, and selecting 'Edit Profile'.


Throws
Error if — the billing service is already started.

See also

stopBillingService()method 
public function stopBillingService():void

Completely shutsdown the billing service. You can call this to completely stop receiving notifications of billing state changes.


Throws
Error if — the billing service is not running or has already been stopped.
testPurchaseItemCancelled()method 
public function testPurchaseItemCancelled():void

Simulates the cancellation of a purchased item, without actually having your app published yet. After the purchase UI is completed, you'll receive the AndroidBillingEvent.PURCHASE_CANCELLED event. This is useful for testing your code, without actually having published your application yet, or having to make a purchase with real money for testing.


Throws
Error if — the Billing service is not currently running.

See also

testPurchaseItemRefunded()method 
public function testPurchaseItemRefunded():void

Simulates the refunding of a purchased item, without actually having your app published yet. After the purchase UI is completed, you'll receive the AndroidBillingEvent.PURCHASE_REFUNDED event. This is useful for testing your code, without actually having published your application yet, or having to make a purchase with real money for testing.


Throws
Error if — the Billing service is not currently running.

See also

testPurchaseItemSuccess()method 
public function testPurchaseItemSuccess():void

Simulates the successful purchase of an item, without actually having your app published yet. After the purchase UI is completed, you'll receive the AndroidBillingEvent.PURCHASE_SUCCEEDED event. This is useful for testing your code, without actually having published your application yet, or having to make a purchase with real money for testing.


Throws
Error if — the Billing service is not currently running.

See also

testPurchaseItemUnavailable()method 
public function testPurchaseItemUnavailable():void

Simulates the attempted purchase of an invalid item id, without actually having your app published yet. After the purchase UI is completed, you'll receive the AndroidBillingErrorEvent.PURCHASE_FAILED event. This is useful for testing your code, without actually having published your application yet, or having to make a purchase with real money for testing.


Throws
Error if — the Billing service is not currently running.

See also

Event Detail
PURCHASE_CANCELLED Event
Event Object Type: com.milkmangames.nativeextensions.android.events.AndroidBillingEvent

Dispatched when a purchase has been cancelled (by Google, or by the developer in the control panel)

PURCHASE_FAILED Event  
Event Object Type: com.milkmangames.nativeextensions.android.events.AndroidBillingErrorEvent

Dispatched when a purchase attempt fails

PURCHASE_REFUNDED Event  
Event Object Type: com.milkmangames.nativeextensions.android.events.AndroidBillingEvent

Dispatched when a purchase has been refunded (by the developer, in the Market developer control panel)

PURCHASE_SUCCEEDED Event  
Event Object Type: com.milkmangames.nativeextensions.android.events.AndroidBillingEvent

Dispatched when an item has been successfully purchased

PURCHASE_USER_CANCELLED Event  
Event Object Type: com.milkmangames.nativeextensions.android.events.AndroidBillingEvent

Dispatched when the user cancelled a purchase, by closing the dialog or pressing Back

SERVICE_NOT_SUPPORTED Event  
Event Object Type: com.milkmangames.nativeextensions.android.events.AndroidBillingEvent

Dispatched if the billing service will not work on this device

SERVICE_READY Event  
Event Object Type: com.milkmangames.nativeextensions.android.events.AndroidBillingEvent

Dispatched when the billing service is ready to use

TRANSACTION_RESTORE_FAILED Event  
Event Object Type: com.milkmangames.nativeextensions.android.events.AndroidBillingErrorEvent

Dispatched When a Transaction Restore fails

TRANSACTIONS_RESTORED Event  
Event Object Type: com.milkmangames.nativeextensions.android.events.AndroidBillingEvent

Dispatched when a restore of managed transactions has completed

Constant Detail
TEST_ITEM_ID_CANCELLEDConstant
public static const TEST_ITEM_ID_CANCELLED:String = android.test.canceled

Special Item ID used for a test of a cancelled item, without actually buying or cancelling anything. After calling testPurchaseItemCancelled(), the AndroidBillingEvent fired will include this as the .itemID property.

See also

com.milkmangames.nativeextensions.android.AndroidIAB.testPurchaseItemCancelled()
TEST_ITEM_ID_PURCHASEDConstant 
public static const TEST_ITEM_ID_PURCHASED:String = android.test.purchased

Special Item ID used for a test of the successful purchase of an item, without actually buying anything. After calling testPurchaseItemSuccess(), the AndroidBillingEvent fired will include this as the .itemID property.

See also

com.milkmangames.nativeextensions.android.AndroidIAB.testPurchaseItemSuccess()
TEST_ITEM_ID_REFUNDEDConstant 
public static const TEST_ITEM_ID_REFUNDED:String = android.test.refunded

Special Item ID used for a test of a refunded item, without actually buying or refunding anything. After calling testPurchaseItemRefunded(), the AndroidBillingEvent fired will include this as the .itemID property.

See also

com.milkmangames.nativeextensions.android.AndroidIAB.testPurchaseItemRefunded()
TEST_ITEM_ID_UNAVAILABLEConstant 
public static const TEST_ITEM_ID_UNAVAILABLE:String = android.test.item_unavailable

Special Item ID used for a test of an unavailable item, without actually buying anything. 'Unavailable' means the itemID doesn't exist in your Android Market Publisher control panel. After calling testPurchaseItemUnavailable(), the AndroidBillingEvent fired will include this as the .itemID property.

See also

com.milkmangames.nativeextensions.android.AndroidIAB.testPurchaseItemUnavailable()
VERSIONConstant 
public static const VERSION:String = 1.0.0

Version