Skip to content

feat: expose termsDisplay as a public PaymentSheet configuration option#2322

Merged
yuki-stripe merged 5 commits intomasterfrom
guido/expose-terms-display-config
Mar 2, 2026
Merged

feat: expose termsDisplay as a public PaymentSheet configuration option#2322
yuki-stripe merged 5 commits intomasterfrom
guido/expose-terms-display-config

Conversation

@guido-stripe
Copy link
Contributor

Summary

Changes

  • TypeScript: Added TermsDisplay enum and optional termsDisplay property on SetupParamsBase
  • Android: Added mapToTermsDisplay() in PaymentElementConfig.kt, wired into PaymentSheetManager.kt via configurationBuilder.termsDisplay()
  • iOS: Added mapToTermsDisplay(params:) in StripeSdkImpl+PaymentSheet.swift, wired into buildPaymentSheetConfiguration
  • Tests: 6 new Android unit tests, 5 new iOS unit tests covering null/missing/valid/invalid/empty cases

Test plan

  • yarn typescript passes
  • yarn lint passes
  • yarn test — 100/100 pass
  • yarn test:unit:android — all pass
  • yarn test:unit:ios — run on CI
  • Manual test on iOS with { card: 'never' } — card mandate disclaimer hidden
  • Manual test on Android with { card: 'never' } — card mandate disclaimer hidden
  • Verify default behavior (termsDisplay not set) is unchanged

@guido-stripe guido-stripe requested review from a team as code owners February 24, 2026 14:36
* Example: `{ card: 'never' }` to hide the card mandate disclaimer.
*/
termsDisplay?: {
[key: string]: TermsDisplay;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I investigated if it made sense to use a more-typed argument for key, but it seems that string is generally used and that's what's recommended

fun mapToTermsDisplay_CardNever_ReturnsSingleEntry() {
val params =
readableMapOf(
"termsDisplay" to readableMapOf("card" to "never"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test with an invalid payment method type? ie -

Suggested change
"termsDisplay" to readableMapOf("card" to "never"),
"termsDisplay" to readableMapOf("foobar" to "never"),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, both on android and ios!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see we have tests for the bridging logic, which is good. Do we have any existing tests that use the React Native configuration API that we could add to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to Claude Code, there are no tests for this as it just passes things through and it's only a type interface. I manually checked that it worked as expected for our use case

Comment on lines +103 to +106
* Keys are payment method type strings (e.g. "card"), values are 'automatic' or 'never'.
* If not set, defaults to 'automatic' for all payment method types.
*
* Example: `{ card: 'never' }` to hide the card mandate disclaimer.
Copy link
Collaborator

@yuki-stripe yuki-stripe Feb 24, 2026

Choose a reason for hiding this comment

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

I think the example values ('automatic', 'never') aren't right, it should use the enum?

@guido-stripe guido-stripe force-pushed the guido/expose-terms-display-config branch from ee7e8e1 to 78800c1 Compare February 24, 2026 17:18
guido-stripe and others added 2 commits February 24, 2026 18:19
Add termsDisplay to PaymentSheet.Configuration, allowing merchants to
control whether legal agreements (e.g. card mandate disclaimers) are
shown per payment method type. This replaces the reverted internal
auto-hide approach with an explicit, user-configurable setting that
matches the native iOS and Android Stripe SDK APIs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
Verify that unrecognized payment method type keys (e.g. "foobar") are
skipped and result in nil/null on both Android and iOS.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
@guido-stripe guido-stripe force-pushed the guido/expose-terms-display-config branch from 78800c1 to 30b702c Compare February 24, 2026 17:19
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
/**
* A map of payment method types to their terms display configuration.
* Controls whether legal agreements (e.g. card mandate disclaimers) are shown for each payment method type.
* Keys are payment method type strings (e.g. "card"), values are `TermsDisplay.AUTOMATIC` or `TermsDisplay.NEVER`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's also specify the format of the pm type strings in the docstring - snake case - and call out you can find the full list of values here https://docs.stripe.com/api/payment_methods/object#payment_method_object-type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
@yuki-stripe yuki-stripe merged commit f389510 into master Mar 2, 2026
8 checks passed
@yuki-stripe yuki-stripe deleted the guido/expose-terms-display-config branch March 2, 2026 20:21
guido-stripe added a commit that referenced this pull request Mar 5, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
yuki-stripe pushed a commit that referenced this pull request Mar 9, 2026
Committed-By-Agent: claude

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.

3 participants