Question

Kotlin | Making Purchase SDK 6.0.0

  • 30 September 2023
  • 1 reply
  • 47 views

Badge +1

I can see in docs how to make Purchases with Kotlin like this:

Purchases.sharedInstance.purchaseWith(
PurchaseParams.Builder(this, aPackage).build(),
onError = { error, userCancelled -> /* No purchase */ },
onSuccess = { storeTransaction, customerInfo ->
if (customerInfo.entitlements["my_entitlement_identifier"]?.isActive == true) {
// Unlock that great "pro" content
}
}
)

But how can I can the attribute of (aPackage) on line.2? Please answer with code if possible.

N.B: I have a 1 monthly subscription and I need to make when click on a button it directly opens Google default Paywall to make the purchase. So any other way to achieve this threw RevenueCat is appreciated.


1 reply

Userlevel 6
Badge +8

Hey @Aziz.cs,

Do you mean how do you get the `aPackage` object? You’ll want to configure Offerings in our dashboard, then fetch them as described here: https://www.revenuecat.com/docs/displaying-products#fetching-offerings

Offerings contain packages which you can forward to the purchase method. You can read more about configuration Offerings here: https://www.revenuecat.com/docs/entitlements#offerings

Reply