checkout / frames-android

Frames Android: making native card payments simple
https://www.checkout.com/docs/integrate/sdks/android-sdk
MIT License
47 stars 32 forks source link

Validation error message translation #182

Closed mzohrab closed 1 year ago

mzohrab commented 1 year ago

Hello Checkout Team, We are trying to localise checkout form, but validation error messages still stay as default. Is there anyway to set custom validation error message on PaymentFormComponentBuilder? Currently com.checkout.frames.style.theme.PaymentFormComponentBuilder does not contain any method to set validation error messages.

image

Thank you a lot!

maxim-nosov-cko commented 1 year ago

Hi @mzohrab

There are a few ways how it can be achieved:

  1. Override string resources in your project.
  2. Generate PaymentFormStyle with a theme, as you have done, PaymentFormStyleProvider.provide(CustomPaymentFormTheme.providePaymentFormTheme()) and after it, each field style can be updated in a more detailed way. F.e. to change the error message for card number you need: PaymentFormStyle.paymentDetailsStyle.cardNumberStyle.inputStyle.errorMessageStyle.textId. The InputComponentStyle and TextLabelStyle are immutable, .copy() function should help with it.
  3. Create a fully custom style.