#niccol-bertozzi-129_connection-token-reuse

1 messages ยท Page 1 of 1 (latest)

mortal isleBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1358834440209567985

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

novel stratus
#
@Singleton
class StripeTokenProviderImpl @Inject constructor(
    private val stripePaymentService: StripePaymentService
) : StripeTokenProvider {
    override suspend fun fetchToken(locationId: String): ConnectionTokenProvider {

        val response = stripePaymentService.getConnectionToken(locationId)

        if (response.responseStatus == 1) {
            return object : ConnectionTokenProvider {
                override fun fetchConnectionToken(callback: ConnectionTokenCallback) {
                    callback.onSuccess(response.response.secret)
                }
            }
        } else {
            throw ConnectionTokenException(response.errorMessage)
        }
    }
}

class StripePaymentService @Inject constructor(
    private val stripeApi: StripeApi
) : StripePaymentServiceContract {

    override suspend fun getConnectionToken(locationId: String): StripeConnectionTokenResponse {
        return try {
            stripeApi.getConnectionToken(locationId)
        } catch (e: Exception) {
            StripeConnectionTokenResponse(
                errorMessage = e.message ?: "Errore sconosciuto",
                errorCode = "500",
                responseStatus = 500,
                response = Response("", "", locationId)
            )
        }
    }
}

My server-side do the connection token request, and send me de secret. It's flow correct?

analog notch
#

Hi ๐Ÿ‘‹

That error indicates that your application is attempting to re-use a connection token value

#

You need to generate a new token every time you attempt to connect

novel stratus
#

So i need to call my server-side which do API call every time i try to connect

#

and get secret by fetchConnectionToken.onSucces

lunar nacelle
#

stripe is the best scam ever

mortal isleBOT
#

@lunar nacelle looks like you're in the wrong place, this thread is for someone else's question.

Note that posting inappropriate messages in other people's threads is against the rules. No worries if this was just an honest mistake, but anyone who violates the rules multiple times will be removed from this server.

analog notch
#

@novel stratus correct

novel stratus
#

perfect thk u

analog notch
#

Happy to help ๐Ÿ™‚