purchaseProductWith

fun Purchases.purchaseProductWith(    activity: Activity,     storeProduct: StoreProduct,     onError: (error: PurchasesError, userCancelled: Boolean) -> Unit = ON_PURCHASE_ERROR_STUB,     onSuccess: (purchase: StoreTransaction, customerInfo: CustomerInfo) -> Unit)

Purchase product. If purchasing a subscription, it will choose the default SubscriptionOption.

Parameters

activity

Current activity

storeProduct

The storeProduct of the product you wish to purchase

onSuccess

Will be called after the purchase has completed

onError

Will be called if there was an error with the purchase


fun Purchases.purchaseProductWith(    activity: Activity,     storeProduct: StoreProduct,     upgradeInfo: UpgradeInfo,     onError: (error: PurchasesError, userCancelled: Boolean) -> Unit = ON_PURCHASE_ERROR_STUB,     onSuccess: (purchase: StoreTransaction?, customerInfo: CustomerInfo) -> Unit)

Make a purchase upgrading from a previous sku. If purchasing a subscription, it will choose the default SubscriptionOption.

Parameters

activity

Current activity

storeProduct

The storeProduct of the product you wish to purchase

upgradeInfo

The upgradeInfo you wish to upgrade from, containing the oldSku and the optional prorationMode. Amazon Appstore doesn't support changing products so upgradeInfo is ignored for Amazon purchases.

onSuccess

Will be called after the purchase has completed

onError

Will be called if there was an error with the purchase

Sources

Link copied to clipboard
Link copied to clipboard