//cardID: Received with getConsumerDetails API.
//tokenRequestor: User selected.
fun pushCardToTokenRequestor(d1Task: D1Task, cardID: String, tokenRequestor: TokenRequestor) {
val appURL = "d1demoapp://com.thalesgroup.gemalto.d1.validation/PushToSchemeResult" // The issuer app's custom URL that the token requester calls back upon completion of digitization flow.
val tcsAccepted = true
val callback: D1Task.Callback<String> = object : D1Task.Callback<String> {
override fun onSuccess(pushUrl: String) {
// Launches the token requester application.
getActivity().startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(pushUrl)))
}
override fun onError(exception: D1Exception) {
// Refer to D1 SDK Integration – Error Management section.
}
}
// For Click to Pay, the Mastercard tokenRequestor.id attribute value is 50123197928.
d1Task.addDigitalCardToScheme(
cardID,
tokenRequestor,
appURL,
tcsAccepted,
callback
)
}