-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add klarna to sdk w/ example #4325
Conversation
@Test | ||
fun createPaymentMethod_withKlarna_shouldCreateObject() { | ||
val missingAddressException = assertFailsWith<InvalidRequestException>( | ||
"Address is required to create a klarna payment method" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where are these messages from? is it possible to build them programmatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These messages come from the Stripe api's error messages, we parse the response. So there's not really any way to generate them programatically. I was following the after pay example here. I don't think there's a much cleaner way.
payments-core/src/test/java/com/stripe/android/PaymentMethodEndToEndTest.kt
Show resolved
Hide resolved
@@ -33,6 +34,10 @@ internal class StripeIntentViewModel( | |||
customerId?.let { | |||
mapOf("customer_id" to it) | |||
}.orEmpty() | |||
).plus( | |||
supportedPaymentMethods?.let { | |||
mapOf("supported_payment_methods" to it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder should we exhaust this to customize all possible params provided by the toy server(not needed in this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. It might be good to just have them all there in case we need them in the future. Unfortunately, it's not super well documented. That's why I only added this one for now.
Summary
Add Klarna as a payment method and make an example activity that confirms it.
Add optional param to our Base intent example to pass
SupportedPaymentMethods
so the example backend returns the requested payment methods with the payment intent.Motivation
Eventually we'll add support to this for payment sheet, so we should also have it in the SDK bindings just to be complete. Right now Klarna only requires an email and a country code. They're planning on removing that email requirement, so I will add the custom country selector in the future and for now it's hardcoded.
Testing
Screenshots