purchase

expect fun purchase(storeProduct: <Error class: unknown class>, onError: (<Error class: unknown class>, userCancelled: Boolean) -> Unit, onSuccess: (<Error class: unknown class>, <Error class: unknown class>) -> Unit, isPersonalizedPrice: Boolean? = null, oldProductId: String? = null, replacementMode: <Error class: unknown class>? = null)

Purchases storeProduct. On the Play Store, if storeProduct represents a subscription, upgrades from the subscription specified by oldProductId and chooses storeProduct's default SubscriptionOption.

The default SubscriptionOption logic:

  • Filters out offers with "rc-ignore-offer" tag

  • Uses SubscriptionOption WITH longest free trial or cheapest first phase

  • Falls back to use base plan

If storeProduct represents a non-subscription, oldProductId and replacementMode will be ignored.

Parameters

storeProduct

The StoreProduct you wish to purchase.

onError

Will be called if the purchase has completed with an error, providing the PurchasesError and a boolean indicating whether the user canceled the purchase.

onSuccess

Will be called if the purchase has completed successfully, providing the StoreTransaction and updated CustomerInfo.

isPersonalizedPrice

Play Store only, ignored otherwise. Optional boolean indicates personalized pricing on products available for purchase in the EU. For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true. See developer.android.com for more info.

oldProductId

Play Store only, ignored otherwise. If this purchase is an upgrade from another product, provide the previous product ID here.

replacementMode

Play Store only, ignored otherwise. The replacement mode to use when upgrading from another product. This field is ignored, unless oldProductId is non-null.


expect fun purchase(packageToPurchase: <Error class: unknown class>, onError: (<Error class: unknown class>, userCancelled: Boolean) -> Unit, onSuccess: (<Error class: unknown class>, <Error class: unknown class>) -> Unit, isPersonalizedPrice: Boolean? = null, oldProductId: String? = null, replacementMode: <Error class: unknown class>? = null)

Purchases packageToPurchase. On the Play Store, if packageToPurchase represents a subscription, upgrades from the subscription specified by oldProductId and chooses the default SubscriptionOption from packageToPurchase.

The default SubscriptionOption logic:

  • Filters out offers with "rc-ignore-offer" tag

  • Uses SubscriptionOption WITH longest free trial or cheapest first phase

  • Falls back to use base plan

If packageToPurchase represents a non-subscription, oldProductId and replacementMode will be ignored.

Parameters

packageToPurchase

The Package you wish to purchase.

onError

Will be called if the purchase has completed with an error, providing the PurchasesError and a boolean indicating whether the user canceled the purchase.

onSuccess

Will be called if the purchase has completed successfully, providing the StoreTransaction and updated CustomerInfo.

isPersonalizedPrice

Play Store only, ignored otherwise. Optional boolean indicates personalized pricing on products available for purchase in the EU. For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true. See developer.android.com for more info.

oldProductId

Play Store only, ignored otherwise. If this purchase is an upgrade from another product, provide the previous product ID here.

replacementMode

Play Store only, ignored otherwise. The replacement mode to use when upgrading from another product. This field is ignored, unless oldProductId is non-null.


expect fun purchase(subscriptionOption: <Error class: unknown class>, onError: (<Error class: unknown class>, userCancelled: Boolean) -> Unit, onSuccess: (<Error class: unknown class>, <Error class: unknown class>) -> Unit, isPersonalizedPrice: Boolean? = null, oldProductId: String? = null, replacementMode: <Error class: unknown class>? = null)

Play Store only. Purchases subscriptionOption.

Parameters

subscriptionOption

The SubscriptionOption you wish to purchase.

onError

Will be called if the purchase has completed with an error, providing the PurchasesError and a boolean indicating whether the user canceled the purchase.

onSuccess

Will be called if the purchase has completed successfully, providing the StoreTransaction and updated CustomerInfo.

isPersonalizedPrice

Play Store only, ignored otherwise. Optional boolean indicates personalized pricing on products available for purchase in the EU. For compliance with EU regulations. User will see "This price has been customize for you" in the purchase dialog when true. See developer.android.com for more info.

oldProductId

Play Store only, ignored otherwise. If this purchase is an upgrade from another product, provide the previous product ID here.

replacementMode

Play Store only, ignored otherwise. The replacement mode to use when upgrading from another product. This field is ignored, unless oldProductId is non-null.


expect fun purchase(storeProduct: <Error class: unknown class>, promotionalOffer: <Error class: unknown class>, onError: (<Error class: unknown class>, userCancelled: Boolean) -> Unit, onSuccess: (<Error class: unknown class>, <Error class: unknown class>) -> Unit)

App Store only. Use this function if you are not using the Offerings system to purchase a StoreProduct with an applied PromotionalOffer. If you are using the Offerings system, use the overload with a Package parameter instead.

Parameters

storeProduct

The StoreProduct you wish to purchase.

promotionalOffer

The PromotionalOffer to apply to this purchase.

onError

Will be called if the purchase has completed with an error, providing the PurchasesError and a boolean indicating whether the user canceled the purchase.

onSuccess

Will be called if the purchase has completed successfully, providing the StoreTransaction and updated CustomerInfo.

See also


expect fun purchase(packageToPurchase: <Error class: unknown class>, promotionalOffer: <Error class: unknown class>, onError: (<Error class: unknown class>, userCancelled: Boolean) -> Unit, onSuccess: (<Error class: unknown class>, <Error class: unknown class>) -> Unit)

App Store only. Purchases packageToPurchase. Call this method when a user has decided to purchase a product with an applied discount. Only call this in direct response to user input. From here Purchases will handle the purchase with StoreKit and call either onSuccess or onError.

Parameters

packageToPurchase

The Package you wish to purchase.

promotionalOffer

The PromotionalOffer to apply to this purchase.

onError

Will be called if the purchase has completed with an error, providing the PurchasesError and a boolean indicating whether the user canceled the purchase.

onSuccess

Will be called if the purchase has completed successfully, providing the StoreTransaction and updated CustomerInfo.

See also