Skip to content

Implement PaymentMethodCreateParams.createTwint() function #12247

Closed
igorescodro wants to merge 4 commits intostripe:masterfrom
igorescodro:master
Closed

Implement PaymentMethodCreateParams.createTwint() function #12247
igorescodro wants to merge 4 commits intostripe:masterfrom
igorescodro:master

Conversation

@igorescodro
Copy link
Contributor

@igorescodro igorescodro commented Jan 20, 2026

Summary

Adding createTwint() function inside PaymentMethodCreateParams, allowing the payment provider to be confirmed by the Android app using PaymentLauncher.confirm(). Test and example classes were created to cover this new implementation.

Motivation

In the current Android SDK, it's not possible to use ConfirmPaymentIntentParams with TWINT, like with other payment methods such as PayPal, CashApp, NolPay, etc. We discussed with the Stripe Support and they informed us that there is no support yet. The goal of this PR is to speed up the inclusion of this new functionality.

Trying to create it with the existing APIs, will result in a StripeError.

fun confirmTwintPayment() {
  val paymentLauncher = PaymentLauncher.create(
    fragment = this,
    publishableKey = publishableKey // Switzerland Stripe Key,
    callback = { /* handle payment result */ }
  )

  val paymentIntentParams = ConfirmPaymentIntentParams.create(
    clientSecret = clientSecret, // Provided by the backend
    paymentMethodType = PaymentMethod.Type.Twint,
  )

  // callback returns `PaymentResult.Failed`
  paymentLauncher.confirm(paymentIntentParams)
}
StripeError(
    type = "invalid_request_error", 
    message = "You cannot confirm this PaymentIntent because it's missing a payment method. You can either update the PaymentIntent with a payment method and then confirm it again, or confirm it again directly with a payment method or ConfirmationToken.", 
    code = "payment_intent_unexpected_state", 
    param = null, 
    declineCode = null, 
    charge = null, 
    docUrl = "https://stripe.com/docs/error-codes/payment-intent-unexpected-state", 
    extraFields = null
)

This new API, allows to use TWINT:

fun confirmTwintPayment() {
  val paymentLauncher = PaymentLauncher.create(
    fragment = this,
    publishableKey = publishableKey // Switzerland Stripe Key,
    callback = { /* handle payment result */ }
  )

  val twintParams = PaymentMethodCreateParams.createTwint()

  val paymentIntentParams = ConfirmPaymentIntentParams.createWithPaymentMethodCreateParams(
      paymentMethodCreateParams = twintParams,
      clientSecret = clientSecret, // Provided by the backend
  )

  // confirmation UX open and callback returns `PaymentResult.Success` when approved
  paymentLauncher.confirm(paymentIntentParams)
}

Testing

  • Added tests
  • Modified tests
  • Manually verified

Changelog

  • [Added] PaymentMethodCreateParams.createTwint() function.

Adding `createTwint()` function inside `PaymentMethodCreateParams`,
allowing the payment provider to be confirmed by the Android app using
`PaymentLauncher.confirm()`. Test and example classes were created to
cover this new implementation.
@cla-assistant
Copy link

cla-assistant bot commented Jan 20, 2026

CLA assistant check
All committers have signed the CLA.

"pk_test_51JtgfQKG6vc7r7YCU0qQNOkDaaHrEgeHgGKrJMNfuWwaKgXMLzPUA1f8ZlCNPonIROLOnzpUnJK1C1xFH3M3Mz8X00Q6O4GfUt"

const val TWINT_PUBLISHABLE_KEY =
"add-stripe-pk-here-for-tests"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need a Stripe generated test key for TWINT here. Could you please provide one?

@samer-stripe
Copy link
Collaborator

Thanks for adding this! I opened a separate PR that pulls the branch here so that our checks pass properly. Closing this one in favor of that one but retained the commit.

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

Successfully merging this pull request may close these issues.

2 participants