Created
March 11, 2024 21:42
-
-
Save LethalMaus/55f0f3308d4e581eff6086bfd0063f30 to your computer and use it in GitHub Desktop.
monetization.kt
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
| suspend fun handlePurchase(purchase: Purchase) { | |
| // Purchase retrieved from BillingClient#queryPurchasesAsync or your PurchasesUpdatedListener. | |
| val purchase : Purchase = ...; | |
| // Verify the purchase. | |
| // Ensure entitlement was not already granted for this purchaseToken. | |
| // Grant entitlement to the user. | |
| val consumeParams = | |
| ConsumeParams.newBuilder() | |
| .setPurchaseToken(purchase.getPurchaseToken()) | |
| .build() | |
| val consumeResult = withContext(Dispatchers.IO) { | |
| client.consumePurchase(consumeParams) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment