feat: expose termsDisplay as a public PaymentSheet configuration option#2322
feat: expose termsDisplay as a public PaymentSheet configuration option#2322yuki-stripe merged 5 commits intomasterfrom
Conversation
| * Example: `{ card: 'never' }` to hide the card mandate disclaimer. | ||
| */ | ||
| termsDisplay?: { | ||
| [key: string]: TermsDisplay; |
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
Can you add a test with an invalid payment method type? ie -
| "termsDisplay" to readableMapOf("card" to "never"), | |
| "termsDisplay" to readableMapOf("foobar" to "never"), |
There was a problem hiding this comment.
done, both on android and ios!
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
src/types/PaymentSheet.ts
Outdated
| * 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. |
There was a problem hiding this comment.
I think the example values ('automatic', 'never') aren't right, it should use the enum?
ee7e8e1 to
78800c1
Compare
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
78800c1 to
30b702c
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
src/types/PaymentSheet.ts
Outdated
| /** | ||
| * 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`. |
There was a problem hiding this comment.
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
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Committed-By-Agent: claude
Summary
termsDisplayoption toPaymentSheet.Configuration, allowing merchants to control whether legal agreements (e.g. card mandate disclaimers) are shown per payment method type'automatic'or'never'(e.g.{ card: 'never' })Changes
TermsDisplayenum and optionaltermsDisplayproperty onSetupParamsBasemapToTermsDisplay()inPaymentElementConfig.kt, wired intoPaymentSheetManager.ktviaconfigurationBuilder.termsDisplay()mapToTermsDisplay(params:)inStripeSdkImpl+PaymentSheet.swift, wired intobuildPaymentSheetConfigurationTest plan
yarn typescriptpassesyarn lintpassesyarn test— 100/100 passyarn test:unit:android— all passyarn test:unit:ios— run on CI{ card: 'never' }— card mandate disclaimer hidden{ card: 'never' }— card mandate disclaimer hiddentermsDisplaynot set) is unchanged