Question

Kotlin Making Purchases. DSK v4.6.1

  • 27 February 2022
  • 3 replies
  • 128 views

Userlevel 1
Badge +5

Hello,

My code below gets the following build errors.

  1. None of the following functions can be called with the arguments supplied.
  1. Cannot infer a type for this parameter. Please specify it explicitly.

I am copying from the Android set up guide and can’t see what I am doing wrong.  Any guidance would be greatly appreciated.

 

 

fun attemptPurchase(inActivity: Activity, forPackage: Package) {    Purchases.sharedInstance.purchasePackage(inActivity, forPackage,        onError = { error, userCancelled -> println("Error ${error.localizedMessage}")        },        onSuccess = { product, customerInfo ->        }    )}

3 replies

Userlevel 1
Badge +5
Using purchasePackageWith works.The setup guide uses Purchases.sharedInstance.purchasePackage but the example on Github uses Purchases.sharedInstance.purchasePackageWith.

What is the difference?

Userlevel 3
Badge +5

Hey @Peter Rule,

That is a great question! I did some looking into and the Kotlin guide show `purchasePackageWith` and the Java guide shows `purchasePackage`.

The `purchasePackage` version take a PurchaseListener (available for Java and Kotlin)

The `purchasePackageWith` version takes on `onError` and `onSuccess` lambda (which is only available in Kotlin).

 

KOTLIN
JAVA

 

Hopefully that helps! But happy to answer any more questions you may have!

Userlevel 1
Badge +5

Thanks @joshdholtz but I still see the above under making purchases in the quickstart guide.

Not a problem for me now though as I’ve got it working with `purchasePackageWith` 

Reply