Skip to content

Fix: Link display params serialization#2407

Merged
remonh87 merged 1 commit into
flutter-stripe:mainfrom
najeira:fix/link-display-json-name2
May 8, 2026
Merged

Fix: Link display params serialization#2407
remonh87 merged 1 commit into
flutter-stripe:mainfrom
najeira:fix/link-display-json-name2

Conversation

@najeira

@najeira najeira commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

LinkDisplayParams were serialized using the Dart field names linkDisplayParams and linkDisplay, while the native iOS and Android PaymentSheet implementations expect link and display.

Add JsonKey annotations to match the native payload fields.

With this change, LinkDisplayParams is passed to the native PaymentSheet implementations using the expected fields, for example LinkDisplayParams(linkDisplay: LinkDisplay.never) is serialized as link.display = "never" and is correctly applied. automatic is the default behavior, so it continues to behave the same as before.


  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you developed the feature on the latest stable version of Flutter?
  • Do all checks pass?

melos run format:
I ran melos run format, but it reformatted unrelated sections in existing files. I did not include those unrelated formatting changes in this PR.

melos run analyze:
Warnings are reported in flutter_stripe and flutter_stripe_web, but there are no issues in stripe_platform_interface, which is the package modified in this PR.

melos run unittest:
The modified package, stripe_platform_interface, passed all tests, including the added initPaymentSheet serialization test.

The overall Melos command did not fully pass because other packages do not have runnable Flutter tests:

  • stripe_android: Test directory "test" not found.
  • flutter_stripe: No tests were found.
  • stripe_ios: No tests were found.

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

I used Codex to investigate the bug. I also ran build_runner and the relevant Melos commands myself, and manually reviewed the results.

The only code change was adding annotations, which I fully understand.

I ran my app with the corrected version included and manually verified all three cases myself: unset linkDisplayParams, using LinkDisplay.automatic, and using LinkDisplay.never.

To add to that, I am not an English speaker, so I use AI translation for translating and proofreading my texts.


Summary by CodeRabbit

  • Bug Fixes
    • Corrected JSON serialization for Link payment configuration parameters to ensure proper transmission of payment sheet settings.

LinkDisplayParams were serialized using the Dart field names
`linkDisplayParams` and `linkDisplay`, while the native iOS and Android
PaymentSheet implementations expect `link` and `display`.

Add JsonKey annotations to match the native payload fields.
@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

JSON serialization key mappings for Link configuration were adjusted in payment sheet models: linkDisplayParams now maps to the link JSON key, and linkDisplay maps to the display JSON key. Related generated code and tests were updated accordingly.

Changes

Cohort / File(s) Summary
Link Configuration JSON Serialization
packages/stripe_platform_interface/lib/src/models/payment_sheet.dart, payment_sheet.freezed.dart, payment_sheet.g.dart
Updated JSON key mappings for Link-related fields: SetupPaymentSheetParameters.linkDisplayParams → JSON key "link", and LinkDisplayParams.linkDisplay → JSON key "display". Generated code and serialization helpers updated to reflect the new mappings.
Test Coverage for Link Configuration
packages/stripe_platform_interface/test/method_channel_stripe_test.dart
Extended initPaymentSheet test setup to inject methodChannelMock, added linkDisplayParams with LinkDisplay.never to test input, and introduced validation that serialized params correctly include link: { display: 'never' }.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • remonh87

Poem

🐰 A rabbit hops through JSON keys so bright,
Remapping link and display just right,
No features new, just structure refined,
The serialization's perfectly aligned! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing JSON serialization field names for Link display parameters to match native platform expectations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@najeira

najeira commented Apr 29, 2026

Copy link
Copy Markdown
Contributor Author

Fixes #2398

@najeira najeira changed the title Fix Link display params serialization Fix: Link display params serialization Apr 29, 2026
@remonh87

Copy link
Copy Markdown
Member

Thanks

@remonh87 remonh87 modified the milestones: v12.5, 202605-release Apr 30, 2026
@remonh87 remonh87 merged commit 8b8d0eb into flutter-stripe:main May 8, 2026
3 of 6 checks passed
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