#ubby-terminal-picreation
1 messages · Page 1 of 1 (latest)
@devout sandal do you have an example PaymentIntent id? I think the way you created it is incorrect and that's the issue. If you can share your code otherwise just for the PaymentIntent creation I can help
ubby-terminal-picreation
this is the code I have
private fun requestPayment() {
val stripeData = viewModel.stripeData.value
clientSecret = stripeData?.paymentIntent?.clientSecret!!
Terminal.getInstance().retrievePaymentIntent(clientSecret, object: PaymentIntentCallback {
override fun onSuccess(paymentIntent: PaymentIntent) {
// Placeholder for collecting a payment method with paymentIntent
Log.d("CartActivty", "payment intent: $paymentIntent")
collectPaymentMethod(paymentIntent)
}
override fun onFailure(exception: TerminalException) {
// Placeholder for handling exception
}
})
}
private fun collectPaymentMethod(paymentIntent: PaymentIntent) {
val cancelable = Terminal.getInstance().collectPaymentMethod(paymentIntent,
object : PaymentIntentCallback {
override fun onSuccess(paymentIntent: PaymentIntent) {
processTerminalPayment(paymentIntent)
}
override fun onFailure(exception: TerminalException) {
// Placeholder for handling exception during payment method collection
// You might want to display an error to the user or try again.
}
})
}
fun processTerminalPayment (paymentIntent: PaymentIntent) {
Terminal.getInstance().processPayment(paymentIntent, object : PaymentIntentCallback {
override fun onSuccess(paymentIntent: PaymentIntent) {
// Placeholder for notifying your backend to capture paymentIntent.id
viewModel.logCheckoutEvent()
}
override fun onFailure(exception: TerminalException) {
// Placeholder for handling the exception
}
})
}
none of this is relevant yet
Where do you create the PaymentIntent. The thing that calls https://stripe.com/docs/api/payment_intents/create
PaymentIntent(id=pi_3NaLK6IcwltjZIut0g8HI8QC, amount=60, amountCapturable=0, amountReceived=0, application=null, applicationFeeAmount=0, canceledAt=0, cancellationReason=null, captureMethod=automatic, charges=null, clientSecret=pi_3NaLK6IcwltjZIut0g8HI8QC_secret_9EVWHXO2UFtYsbzO7aZUHQ0ER, confirmationMethod=automatic, created=1690906886, currency=cad, customer=null, description=null, invoice=null, lastPaymentError=null, livemode=true, metadata={}, onBehalfOf=null, paymentMethodUnion=null, receiptEmail=null, review=null, setupFutureUsage=null, statementDescriptor=null, status=REQUIRES_PAYMENT_METHOD, transferGroup=null, amountDetails=AmountDetails(tip=Tip(amount=null)), amountTip=null, statementDescriptorSuffix=null, paymentMethodOptions=null, stripeAccountId=null)
this is the node code that creates it
if (countryId == 1) {
let paymentIntentData;
if (isKiosk) {
paymentIntentData = {
amount: req.body.amount,
currency: 'cad',
customer: ephemeralRes.customer_id,
payment_method_types: ['card_present'],
capture_method: 'manual',
};
is that what you meant?
yes! and that code you just shared is not what was used to create that PaymentIntent and that's your issue
Look at https://dashboard.stripe.com/logs/req_1opwbDCqGN2bBn which is that API request you made to create the PaymentIntent you shared above. That one does not have payment_method_types: ['card_present'], instead it has automatic_payment_methods: { enabled: "true", },
that's the bug you have
okay thank you !!