Created
April 16, 2015 09:59
-
-
Save marchbold/5f593dfdbd645ab6c4ce to your computer and use it in GitHub Desktop.
Restoring purchases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!