The ProcessPurchase
method of your store listener is called when a purchase completes. Your application should fulfil whatever the user has bought, for example, unlocking local content or sending purchase receipts to a server to update a server-side game model.
A result is returned to indicate whether your Application has finished processing the purchase:
Результат | Description |
---|---|
PurchaseProcessingResult.Complete | The Application has finished processing the purchase and should not be informed of it again. |
PurchaseProcessingResult.Pending | The Application is still processing the purchase and ProcessPurchase will be called again the next time the Application starts, unless the ConfirmPendingPurchase method of IStoreController is called. |
This explicit acknowledgement is designed to ensure that purchases are reliably fulfilled in the event of network outages or application crashes; any purchases that complete whilst the application is offline will be sent to the application on next initialization.
Additionally, Unity IAP keeps transactions open on the underlying store until confirmed as processed, ensuring consumable purchases are not lost even if a user reinstalls your application whilst a consumable purchase is being processed.
Note that this method may be called at any point following a successful initialization. If your application crashes during execution of the ProcessPurchase
handler then it will be invoked again the next time Unity IAP initializes, so you may wish to implement your own additional de-duplication.