Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marchbold/2e508f548f3a7c95c001 to your computer and use it in GitHub Desktop.
Save marchbold/2e508f548f3a7c95c001 to your computer and use it in GitHub Desktop.
Setting up an InAppBilling Service
try
{
InAppBilling.init( APPLICATION_KEY );
if (InAppBilling.isSupported)
{
trace( "InAppBilling.service.version = " + InAppBilling.service.version );
InAppBilling.service.addEventListener( InAppBillingEvent.SETUP_SUCCESS, setup_successHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.SETUP_FAILURE, setup_failureHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.PRODUCTS_LOADED, products_loadedHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.PRODUCTS_FAILED, products_failedHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.INVALID_PRODUCT, product_invalidHandler );
InAppBilling.service.addEventListener( PurchaseEvent.PURCHASE_SUCCESS, purchase_successHandler );
InAppBilling.service.addEventListener( PurchaseEvent.PURCHASE_PURCHASING, purchase_purchasingHandler );
InAppBilling.service.addEventListener( PurchaseEvent.PURCHASE_RESTORED, purchase_restoredHandler );
InAppBilling.service.addEventListener( PurchaseEvent.PURCHASE_CANCELLED, purchase_cancelledHandler );
InAppBilling.service.addEventListener( PurchaseEvent.PURCHASE_FAILED, purchase_failedHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.RESTORE_PURCHASES_SUCCESS, restorePurchases_successHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.RESTORE_PURCHASES_FAILED, restorePurchases_failedHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.CONSUME_SUCCESS, consumePurchase_successHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.CONSUME_FAILED, consumePurchase_failedHandler );
// Set the required service type and call setup
InAppBilling.service.setServiceType( InAppBillingServiceTypes.GOOGLE_PLAY_INAPP_BILLING );
InAppBilling.service.setup( GOOGLE_PLAY_INAPP_BILLING_KEY );
}
else
{
trace( "InAppBilling not supported" );
}
}
catch (e:Error)
{
trace( e );
}
// com.distriqt.InAppBilling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment