Created
March 11, 2024 21:42
-
-
Save LethalMaus/ebbbfa503a72f9c926d6795defacac06 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
| val client: BillingClient = ... | |
| val acknowledgePurchaseResponseListener: AcknowledgePurchaseResponseListener = ... | |
| suspend fun handlePurchase() { | |
| if (purchase.purchaseState === PurchaseState.PURCHASED) { | |
| if (!purchase.isAcknowledged) { | |
| val acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder() | |
| .setPurchaseToken(purchase.purchaseToken) | |
| val ackPurchaseResult = withContext(Dispatchers.IO) { | |
| client.acknowledgePurchase(acknowledgePurchaseParams.build()) | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment