question

asheranan avatar image
asheranan asked anne165hernadez edited

Unable to create customer through merchant app android sdk

Hello, I've been trying to create a customer using the methods the android sdk for clover provides, first I setup the customer connector and then try to create a customer but it doesn't seem to do anything. What am I supposed to be doing? Any help would be appreciated. The code I've used is below.

fun connectCustomer() {
customerConnector = CustomerConnector(getApplication(), cloverAccount, onCustomerServiceListener)
customerConnector?.connect()
}

private val onCustomerServiceListener = object : ServiceConnector.OnServiceConnectedListener {
override fun onServiceConnected(connector: ServiceConnector<out IInterface>?) {
createCustomer()
}
override fun onServiceDisconnected(connector: ServiceConnector<out IInterface>?) {
}
}

fun createCustomer(){
viewModelScope.launch {
customerConnector?.createCustomer("Name", "Name", false)
}
}

Clover Android SDK
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

anne165hernadez avatar image anne165hernadez commented ·

Hello!

It looks like you’re on the right track, but you might need to add some checks and error handling. Ensure your app has the necessary permissions, and verify that customerConnector is not null before calling createCustomer. Also, make sure the service is properly connected. Here’s a simplified version of your code:


Kotlin


fun connectCustomer() {

customerConnector = CustomerConnector(getApplication(), cloverAccount, onCustomerServiceListener)

customerConnector?.connect()

}


private val onCustomerServiceListener = object : ServiceConnector.OnServiceConnectedListener {

override fun onServiceConnected(connector: ServiceConnector<out IInterface>?) {

createCustomer()

}


override fun onServiceDisconnected(connector: ServiceConnector<out IInterface>?) {}

}


fun createCustomer() {

viewModelScope.launch {

try {

customerConnector?.let {

it.createCustomer("Name", "Name", false)

} ?: Log.e("CustomerConnector", "CustomerConnector is null")

} catch (e: Exception) {

Log.e("CreateCustomer", "Error creating customer", e)

}

}

}


This version includes null checks and error handling to help you troubleshoot any issues.

summit health patient portal login

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community