j

    Jason Inbody

    1 year ago
    public void onBraintreeSubmit(View v) {
      DropInRequest dropInRequest = new DropInRequest()
        .tokenizationKey("sandbox_************");
      startActivityForResult(dropInRequest.getIntent(this), REQUEST_CODE);
    }
    this part in kotlin makes sense
    val dropInRequest = DropInRequest()
        .tokenizationKey("sandbox_************")
    but how does startActivityForResult translate to jetpack compose? I assume this launches the drop in UI and braintree does the rest
    j

    Jason Inbody

    1 year ago
    val dropInHintLauncher = rememberLauncherForActivityResult(
        contract = ActivityResultContracts.StartIntentSenderForResult()
    ) {
        print("pause here")
    }
    val dropInIntent = dropInRequest.getIntent(context)
    dropInHintLauncher.launch(
        IntentSenderRequest.Builder()
    )
    got that far. trying to figure out how to launch it next with intent sender request
    val dropInIntent = dropInRequest.getIntent(context)
    dropInHintLauncher.launch(
        IntentSenderRequest.Builder(dropInIntent)
    )
    but Builder wants PendingIntent or IntentSender
    Well it won't let me pass this function as a Composable function to a clickable method...
    @Composable
    fun launchDropInUi(context: Context, user: FinUser){
        val customerToken = user.userData["customerToken"] as String
        val dropInRequest = DropInRequest()
            .clientToken(customerToken)
    
        val dropInHintLauncher = rememberLauncherForActivityResult(
            contract = ActivityResultContracts.StartIntentSenderForResult()
        ) {
            print("pause here")
        }
        val dropInIntent = dropInRequest.getIntent(context)
        val dropInPendingIntent = PendingIntent.getBroadcast(
            context, tag, dropInIntent,
            PendingIntent.FLAG_UPDATE_CURRENT
        )
        dropInHintLauncher.launch(
            IntentSenderRequest.Builder(dropInPendingIntent).build()
        )
    }
    Woohoo! got it!