Created
March 11, 2024 21:42
-
-
Save LethalMaus/ac577bacd3421eac82177f4dc6b83ec7 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
| // An activity reference from which the billing flow will be launched. | |
| val activity : Activity = ...; | |
| val productDetailsParamsList = listOf( | |
| BillingFlowParams.ProductDetailsParams.newBuilder() | |
| // retrieve a value for "productDetails" by calling queryProductDetailsAsync() | |
| .setProductDetails(productDetails) | |
| // For One-time product, "setOfferToken" method shouldn't be called. | |
| // For subscriptions, to get an offer token, call ProductDetails.subscriptionOfferDetails() | |
| // for a list of offers that are available to the user | |
| .setOfferToken(selectedOfferToken) | |
| .build() | |
| ) | |
| val billingFlowParams = BillingFlowParams.newBuilder() | |
| .setProductDetailsParamsList(productDetailsParamsList) | |
| .build() | |
| // Launch the billing flow | |
| val billingResult = billingClient.launchBillingFlow(activity, billingFlowParams) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment