Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save marchbold/5f593dfdbd645ab6c4ce to your computer and use it in GitHub Desktop.

Select an option

Save marchbold/5f593dfdbd645ab6c4ce to your computer and use it in GitHub Desktop.
Restoring purchases
// The service must be setup and a list of products retrieved.
// Make sure you have the following listeners
InAppBilling.service.addEventListener( PurchaseEvent.PURCHASE_RESTORED, purchase_restoredHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.RESTORE_PURCHASES_SUCCESS, restorePurchases_successHandler );
InAppBilling.service.addEventListener( InAppBillingEvent.RESTORE_PURCHASES_FAILED, restorePurchases_failedHandler );
InAppBilling.service.restorePurchases();
...
private function purchase_restoredHandler( event:PurchaseEvent ):void
{
var purchase:Purchase = Purchase(event.data[0]);
// The originalPurchase property will contain all the
// information on the original transaction allowing
// you to restore the user's product
addPurchaseToInventory( purchase.originalPurchase );
InAppBilling.service.finishPurchase( purchase );
// Again you could hold on to this purchase and check it against
// your application server before calling finishPurchase
}
//
// RESTORE PURCHASE EVENTS
//
private function restorePurchases_successHandler( event:InAppBillingEvent ):void
{
// Called when all purchases have been restored
trace( "restore success" );
}
private function restorePurchases_failedHandler( event:InAppBillingEvent ):void
{
// Called if there was an error restoring purchases
trace( "restore failed" );
}
// com.distriqt.InAppBilling
@Mintonist

Copy link
Copy Markdown

Please, answer will PurchaseEvent.PURCHASE_RESTORED or PurchaseEvent.PURCHASE_SUCCESS or both events dispatch after InAppBilling.service.restorePurchases() call. In documentation I read, that I can work only with PurchaseEvent.PURCHASE_SUCCESS. Does It happen only for notconsume purchase?

Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment