Skip to content

Implement PaymentMethodCreateParams.createTwint() function#12253

Merged
samer-stripe merged 2 commits intomasterfrom
lime-twint
Jan 21, 2026
Merged

Implement PaymentMethodCreateParams.createTwint() function#12253
samer-stripe merged 2 commits intomasterfrom
lime-twint

Conversation

@samer-stripe
Copy link
Collaborator

@samer-stripe samer-stripe commented Jan 20, 2026

Summary

Pulled internally from #12247 by @igorescodro

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.

igorescodro and others added 2 commits January 20, 2026 17:45
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.
@samer-stripe samer-stripe changed the title Lime twint Implement PaymentMethodCreateParams.createTwint() function Jan 20, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 20, 2026

Diffuse output:

OLD: paymentsheet-example-release-master.apk (signature: V1, V2)
NEW: paymentsheet-example-release-pr.apk (signature: V1, V2)

          │            compressed             │         uncompressed         
          ├─────────────┬─────────────┬───────┼───────────┬───────────┬──────
 APK      │ old         │ new         │ diff  │ old       │ new       │ diff 
──────────┼─────────────┼─────────────┼───────┼───────────┼───────────┼──────
      dex │     4.9 MiB │     4.9 MiB │ +14 B │    11 MiB │    11 MiB │  0 B 
     arsc │     3.6 MiB │     3.6 MiB │   0 B │   3.6 MiB │   3.6 MiB │  0 B 
 manifest │     5.7 KiB │     5.7 KiB │   0 B │  30.2 KiB │  30.2 KiB │  0 B 
      res │ 1,005.4 KiB │ 1,005.4 KiB │   0 B │   1.7 MiB │   1.7 MiB │  0 B 
   native │   949.9 KiB │   949.9 KiB │   0 B │   2.5 MiB │   2.5 MiB │  0 B 
    asset │    26.2 KiB │    26.2 KiB │   0 B │  46.7 KiB │  46.7 KiB │  0 B 
    other │   205.4 KiB │   205.4 KiB │  -9 B │ 405.7 KiB │ 405.7 KiB │  0 B 
──────────┼─────────────┼─────────────┼───────┼───────────┼───────────┼──────
    total │    10.6 MiB │    10.6 MiB │  +5 B │  19.2 MiB │  19.2 MiB │  0 B 

         │         raw          │          unique           
         ├───────┬───────┬──────┼───────┬───────┬───────────
 DEX     │ old   │ new   │ diff │ old   │ new   │ diff      
─────────┼───────┼───────┼──────┼───────┼───────┼───────────
   files │     2 │     2 │    0 │       │       │           
 strings │ 58694 │ 58694 │    0 │ 52217 │ 52217 │ 0 (+2 -2) 
   types │ 20682 │ 20682 │    0 │ 17469 │ 17469 │ 0 (+0 -0) 
 classes │ 14697 │ 14697 │    0 │ 14697 │ 14697 │ 0 (+0 -0) 
 methods │ 78343 │ 78343 │    0 │ 73357 │ 73357 │ 0 (+0 -0) 
  fields │ 51366 │ 51366 │    0 │ 49019 │ 49019 │ 0 (+0 -0) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  325 │  325 │  0   
 entries │ 6948 │ 6948 │  0
APK
    compressed    │   uncompressed   │                        
───────────┬──────┼───────────┬──────┤                        
 size      │ diff │ size      │ diff │ path                   
───────────┼──────┼───────────┼──────┼────────────────────────
   4.1 MiB │ +7 B │   9.2 MiB │  0 B │ ∆ classes.dex          
 812.4 KiB │ +7 B │   1.8 MiB │  0 B │ ∆ classes2.dex         
  54.4 KiB │ -4 B │ 127.3 KiB │  0 B │ ∆ META-INF/MANIFEST.MF 
   1.2 KiB │ -3 B │   1.2 KiB │  0 B │ ∆ META-INF/CERT.RSA    
  57.6 KiB │ -2 B │ 127.4 KiB │  0 B │ ∆ META-INF/CERT.SF     
───────────┼──────┼───────────┼──────┼────────────────────────
     5 MiB │ +5 B │  11.2 MiB │  0 B │ (total)
DEX
STRINGS:

   old   │ new   │ diff      
  ───────┼───────┼───────────
   52217 │ 52217 │ 0 (+2 -2) 
  
  + r8-map-id-933fb5aa4411c2cf5d09e16885428c823cd2b317e72ad9d3308aa27ff1b20310
  + ~~R8{"backend":"dex","compilation-mode":"release","has-checksums":false,"min-api":21,"pg-map-id":"933fb5aa4411c2cf5d09e16885428c823cd2b317e72ad9d3308aa27ff1b20310","r8-mode":"full","version":"8.13.17"}
  
  - r8-map-id-d1f644a862edecf63afdd2099cd46625b24b14982d3f71efad3f3fc74dfcd5ce
  - ~~R8{"backend":"dex","compilation-mode":"release","has-checksums":false,"min-api":21,"pg-map-id":"d1f644a862edecf63afdd2099cd46625b24b14982d3f71efad3f3fc74dfcd5ce","r8-mode":"full","version":"8.13.17"}

@samer-stripe samer-stripe marked this pull request as ready for review January 21, 2026 05:23
@samer-stripe samer-stripe requested review from a team as code owners January 21, 2026 05:23
@igorescodro
Copy link
Contributor

igorescodro commented Jan 21, 2026

Thanks for prioritizing this PR and handling the additional changes. I really appreciate it.

@samer-stripe samer-stripe merged commit 95c70fe into master Jan 21, 2026
22 checks passed
@samer-stripe samer-stripe deleted the lime-twint branch January 21, 2026 18:05
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.

3 participants