Skip to content

Add mandate text to payment option#2035

Merged
porter-stripe merged 12 commits into
masterfrom
porter/mandate-text
Aug 19, 2025
Merged

Add mandate text to payment option#2035
porter-stripe merged 12 commits into
masterfrom
porter/mandate-text

Conversation

@porter-stripe

@porter-stripe porter-stripe commented Aug 5, 2025

Copy link
Copy Markdown
Collaborator

Summary

  • Adds the ability for merchants to display the mandate themselves in their app
  • We vend an HTML string that can be rendered, ensuring links can be tapped.

Motivation

https://docs.google.com/document/d/1OaY8oTGsO2dPS7HhZTCKB-tLoCN2m_S1ag0kJ83eD_E/edit?tab=t.0#heading=h.570u4leviueu

Documentation

  • Doc changes to follow after the next deploy

@porter-stripe porter-stripe marked this pull request as ready for review August 19, 2025 16:28
putString("image", imageBase64)
}

fun AnnotatedString.toHtmlString(): String {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it possible to add unit tests for something like this?

@porter-stripe porter-stripe Aug 19, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think it may be possible! However I'm on the fence as we'd be unit testing two system APIs (toSpannable and toHtml). I suppose we could test that toSpannable and toHtml preserve the attributes we care about. If we think there's value (maybe some Android quirk I'm overlooking) I'm happy to add some unit tests as I think it's feasible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's probably a good idea to write a unit test that ensures we're preserving links from the original, as well as a simple text based example.

)
Assert.assertTrue(
"Result should contain link text",
result.contains("Terms of Service"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd expect this to assert there's an a href in here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for probing, during my tests manually I can see the links being preserved but during tests there are some cases not handled. Going to beef up the implementation of toHtml.

@porter-stripe porter-stripe Aug 19, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

After testing more and throwing more test cases at the spannable API, it turns out it drops some stuff like links. So I think the best path forward is to recreate a basic HTML string based on the attributes in the string, took some inspiration from here and help from Claude 🙈 Added more tests this time around.

@jaynewstrom-stripe jaynewstrom-stripe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for digging in! The tests make me feel better!

@porter-stripe porter-stripe enabled auto-merge (squash) August 19, 2025 21:15
@porter-stripe porter-stripe merged commit 347bb51 into master Aug 19, 2025
35 of 38 checks passed
@porter-stripe porter-stripe deleted the porter/mandate-text branch August 19, 2025 21:47
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