#hassan-shahzad_code

1 messages Ā· Page 1 of 1 (latest)

austere willowBOT
#

šŸ‘‹ 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/1441059408942465167

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

azure zenith
#

hi there!

#

I don't really undersand. what are you trying to do, and what is the issue you see?

spare gyro
#

Hi, i am trying to do stripe subscption through android pos nfc. my code for single payment is working fine. but when i triy this code which is for subscription then it is failing on frontend side even before showing paymentIntent. i would like to know what is wrong with my backend code

austere willowBOT
azure zenith
#

what's the error message you see?

spare gyro
#

this if (!paymentSuccess || confirmedPI == null) {
result.error("PAYMENT_FAILED", "PaymentIntent failed or canceled", null)
return@collectAndConfirmPaymentIntent
}

tall tusk
#

hi there, taking over for my colleague who had to step away. do you have an ID for the failed Payment Intent? it should look like pi_2134

spare gyro
#

pi_3SVYMpJinHQ71v5x1Z8leFXu

tall tusk
spare gyro
spare gyro
#

yes

tall tusk
#

can you share the part of your code where you're calling collectPaymentMethod()?

spare gyro
#

private fun processPayment(
clientSecretPI: String?,
result: MethodChannel.Result
) {
val terminal = Terminal.getInstance()
val reader = terminal.connectedReader

    if (reader == null) {
        result.error("NO_READER", "No connected reader available", null)
        return
    }
    
    if (clientSecretPI.isNullOrEmpty()) {
        result.error("MISSING_ARGS", "clientSecretPI is required", null)
        return
    }

    // Step 1ļøāƒ£: Process the initial one-time payment
    terminal.retrievePaymentIntent(clientSecretPI, object : PaymentIntentCallback {
        override fun onSuccess(paymentIntent: PaymentIntent) {
            collectAndConfirmPaymentIntent(terminal, paymentIntent) { paymentSuccess, confirmedPI ->
                if (!paymentSuccess || confirmedPI == null) {
                    result.error("PAYMENT_FAILED", "PaymentIntent failed or canceled", null)
                    return@collectAndConfirmPaymentIntent
                }

                // āœ… One-time payment only (no SetupIntent)
                val reply = mapOf(
                    "status" to "Payment Successful",
                    "transactionId" to confirmedPI.id
                )
                result.success(reply)
            }
        }

        override fun onFailure(e: TerminalException) {
            result.error("PAYMENT_INTENT_RETRIEVE_ERROR", e.message, null)
        }
    })
}
tall tusk
#

ok, can you confirm that terminal.retrievePaymentIntent() is retrieving the Payment Intent correctly? I would try adding logs to determine this