Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't go back to my app in S700 terminal after a payment in example code. #468

Open
josevsq1 opened this issue Jun 7, 2024 · 0 comments

Comments

@josevsq1
Copy link

josevsq1 commented Jun 7, 2024

Summary

After everything is successful, I go to the payment screen, my card is read, I see the big green tick icon and I hear the successful sound, nothing else happens. I keep stuck in the colorful background of the stripe terminal device without being able to do anything else. If I want to run the app again I have to run it again from android studio.

Code to reproduce

I'm trying to run this example on a stripe terminal S700 dev kit: https://github.com/stripe-samples/terminal-apps-on-devices

I haven't modified anything in the code except to hardcoding my connected account id, location id and terminal id. Also I changed the currency.

suspend fun createPaymentIntent(createPaymentIntentParams: Map<String, String>): Result<PaymentIntentCreationResponse> =
        runCatching {
            val newMap = createPaymentIntentParams.toMutableMap()
            newMap["connected_account_id"] = "my_acc_id"
            newMap["terminal_id"] = "my_term_id"
            newMap["location_id"] = "my_loc_id"
            val response = service.createPaymentIntent(newMap.toMap())
            response ?: error("Failed to create PaymentIntent")
        }

Also I have changed this private val config = DiscoveryConfiguration.HandoffDiscoveryConfiguration() to private val config = DiscoveryConfiguration.InternetDiscoveryConfiguration()

Other than that, the code remains untouched.

I want to insist that everything looks right in the logcat and after debugging. The problem starts after I should be receiving a paymentIntent after the payment has been correctly processed. I even receive the intent here but then nothing happens.

    fun createPaymentIntent(
        createPaymentParams: CreatePaymentParams,
        onFailure: (FailureMessage) -> Unit
    ) {
        viewModelScope.launch {
            createAndProcessPaymentIntent(createPaymentParams.toMap())
                .fold(
                    onSuccess = { paymentIntent ->
                        _currentPaymentIntent.update { paymentIntent } // the intent is received here
                    },
                    onFailure = {
                        val failureMessage = if (it is TerminalException) {
                            it.errorMessage
                        } else {
                            it.message ?: "Failed to collect payment"
                        }.let(::FailureMessage)
                        onFailure(failureMessage)
                    }
                )
        }
    }

The intent has the proper status REQUIRES_CAPTURE but it's never collected in the fragment. If I replace: launchAndRepeatWithViewLifecycle with viewLifecycleOwner.lifecycleScope.launch in the fragment, the intent is even collected and

findNavController().navigate(
                        InputFragmentDirections.actionInputFragmentToReceiptFragment(
                            paymentIntentID = it.id.orEmpty(),
                            amount = it.amount.toInt()
                        ),
                        navOptions()
                    )

is run to navigate to the next fragment where the app flow should continue, but nothing happens. No crashes, no nothing.

Android version

I can't see android version in the device but I think it's android 10. The updater version is 2.23.3.0

Impacted devices (Android devices or readers)

Only my S700 dev kit

SDK version

3.3.0 but I've also tried 3.6.0 and the problem remains the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant