Skip to content
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

Merged
merged 2 commits into from
Oct 27, 2021
Merged

Add klarna to sdk w/ example #4325

merged 2 commits into from
Oct 27, 2021

Conversation

skyler-stripe
Copy link
Contributor

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

  • Added tests
  • Modified tests
  • Manually verified

Screenshots

output

@Test
fun createPaymentMethod_withKlarna_shouldCreateObject() {
val missingAddressException = assertFailsWith<InvalidRequestException>(
"Address is required to create a klarna payment method"
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

example/res/values/strings.xml Outdated 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)
Copy link
Collaborator

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)

Copy link
Contributor Author

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.

@skyler-stripe skyler-stripe merged commit 51baf1e into master Oct 27, 2021
@skyler-stripe skyler-stripe deleted the klarnaBindings branch October 27, 2021 00:39
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.

None yet

5 participants