Skip to content

Add image to embedded payment option display data#2032

Merged
porter-stripe merged 6 commits into
masterfrom
porter/image-po-embedded
Aug 18, 2025
Merged

Add image to embedded payment option display data#2032
porter-stripe merged 6 commits into
masterfrom
porter/image-po-embedded

Conversation

@porter-stripe

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

Copy link
Copy Markdown
Collaborator

Summary

  • Add image to payment option display data
  • This was already implemented on iOS.
CleanShot 2025-08-04 at 09 42 06

Motivation

  • GA RN

Testing

  • Manual

@porter-stripe porter-stripe marked this pull request as ready for review August 4, 2025 17:19
// Direct access to imageLoader and call it synchronously with timeout
val imageBase64 =
try {
val imageLoaderField = this@toWritableMap.javaClass.getDeclaredField("imageLoader")

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.

This might not work if the merchant uses progaurd/R8.

That being said, I'm not convinced this is the right approach to begin with!

What are you trying to do 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.

Trying to access the imageLoader, which is private, any chance we can make it like RESTRICT_TO ilb?

@porter-stripe porter-stripe enabled auto-merge (squash) August 18, 2025 18:09
try {
// Load synchronously with 5 second timeout
val drawable =
kotlinx.coroutines.runBlocking {

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.

What thread does this happen on?

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.

Looks like it is running on the main thread which isn't great! However, it is consistent with the iOS native lib 🙈.

I pushed up a change to run it on a different thread than main, however my Android threading knowledge is limited so lmk what you think. Verified it still works too.

// Load synchronously with 5 second timeout
val drawable =
kotlinx.coroutines.runBlocking {
withTimeout(5000L) {

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 there a way to fallback if something fails?

@porter-stripe porter-stripe Aug 18, 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.

We could fallback, but I think we'd need to bundle some resource in the RN SDK. My preference would be that the imageLoader resolves with some default/placeholder image if loading fails to keep the logic out of the RN SDK. Unsure what "generic" payment method icon we could use. My immediate reaction is a card icon, but that may be inaccurate for most payment method types.

@porter-stripe porter-stripe merged commit 6a68304 into master Aug 18, 2025
13 of 14 checks passed
@porter-stripe porter-stripe deleted the porter/image-po-embedded branch August 18, 2025 20:13
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