PaymentCardDetailsMultiLineView

class PaymentCardDetailsMultiLineView @JvmOverloads constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : ConstraintLayout, CardValidCallback, CardInputListener

Convenience view for collecting card details from a user. Card fields are separated into multiple input fields


Important:

User-entered ard details are intentionally restricted for PCI compliance


Styling/Branding

This class can be styled in the following ways:

  1. Override general-purpose resource values

  2. Override resource values specific to PaymentCardDetailsMultiLineView

  3. Override styles specific to PaymentCardDetailsMultiLineView


Override general-purpose resource values

Overriding general-purpose resource values is the easiest way to control the look/feel of the views in the Olo Pay SDK. Changing these values (listed below) will apply to not just PaymentCardDetailsMultiLineView, but also PaymentCardDetailsSingleLineView, and in a limited way, PaymentCardDetailsForm. To override the resources, simply define resources in your app with the same names listed below


Dimen Resources

olopay_textsize
olopay_errortext_textsize

Color Resources

olopay_hintcolor
olopay_edittext_textcolor
olopay_errortext_textcolor

Override resource values specific to PaymentCardDetailsMultiLineView

Overriding the resource values listed below provides for more flexibility, but they apply ONLY to PaymentCardDetailsMultiLineView. The default values for these resources are defined in terms of the general-purpose resources listed in the previous section. Overriding these values take precedence over values defined by the general-purpose resources.


Dimen Resources

olopay_paymentcarddetailsmultilineview_edittext_floatinglabeltextsize
olopay_paymentcarddetailsmultilineview_errortext_textsize

Color Resources

olopay_paymentcarddetailsmultilineview_edittext_hintcolor
olopay_paymentcarddetailsmultilineview_edittext_floatinghintcolor
olopay_paymentcarddetailsmultilineview_edittext_errorcolor
olopay_paymentcarddetailsmultilineview_errortext_textcolor

Override styles specific to PaymentCardDetailsMultiLineView

This is the most difficult option for customization but also allows for the most flexibility. One potential use case for overriding styles would be to change the font (though there are other means of doing that via application-wide themes, etc)


When overriding styles, note the following:

  • The style names MUST match what is listed below. You can choose a different parent but it should be a similar type of parent

  • Some resource values are not defined by the styles that can be overridden so when taking this approach you may need to override resource values as well

  • The styles listed below use some of the properties from above (see code below for which ones)

  • Overridden styles take precedence... if you override a style that is using one of the resource values from above, you will need to define it in your style

  • Because these are custom controls with custom behavior, not all standard Android style attributes will have an effect on the control


The styles that can be defined that will be applied to this view are listed here:

<style name="OloPay.PaymentCardDetailsMultiLineView.ErrorText.TextAppearance" parent="TextAppearance.AppCompat">
<item name="android:textColor">@color/olopay_paymentcarddetailsmultilineview_edittext_errorcolor</item>
<item name="android:textSize">@dimen/olopay_paymentcarddetailsmultilineview_errortext_textsize</item>
<!-- Provide other customizations here -->
</style>

<style name="OloPay.PaymentCardDetailsMultiLineView.TextInputLayout.HintTextAppearance" parent="TextAppearance.AppCompat">
<item name="android:textColor">@color/olopay_paymentcarddetailsmultilineview_edittext_floatinghintcolor</item>
<item name="android:textSize">@dimen/olopay_paymentcarddetailsmultilineview_edittext_floatinglabeltextsize</item>
<!-- Provide other customizations here -->
</style>

Constructors

PaymentCardDetailsMultiLineView
Link copied to clipboard
fun PaymentCardDetailsMultiLineView(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0)

Creates a new instance of PaymentCardDetailsMultiLineView

Types

Companion
Link copied to clipboard
object Companion

Properties

cardInputListener
Link copied to clipboard
var cardInputListener: CardInputListener? = null

Set this to receive callbacks about card input events for this control

displayErrors
Link copied to clipboard
var displayErrors: Boolean

Whether or not to display built-in error messages

errorMessage
Link copied to clipboard
val errorMessage: String

Get the error message that is displayed if displayErrors is true. If displayErrors is false, this can be used to display errors in your app with your own UI (e.g. in a dialog)

fieldStates
Link copied to clipboard
val fieldStates: Map<CardField, ICardFieldState>

Provides a snapshot of the current state of each card field

hasErrorMessage
Link copied to clipboard
val hasErrorMessage: Boolean

true if there is an error message that can be shown.

isValid
Link copied to clipboard
val isValid: Boolean

true if all fields are complete and valid, otherwise false

paymentMethodParams
Link copied to clipboard
val paymentMethodParams: IPaymentMethodParams?

Get an IPaymentMethodParams instance that can be used to create an IPaymentMethod instance. If the form is not valid this will return null.

postalCodeEnabled
Link copied to clipboard
var postalCodeEnabled: Boolean

Whether or not the postal code is enabled. It is enabled by default. Disabling the postal code field is discouraged because it could impact authorization success rates

postalCodeRequired
Link copied to clipboard
var postalCodeRequired: Boolean

If both postalCodeEnabled and postalCodeRequired are true, then postal code is a required field. If postalCodeEnabled is false, this value is ignored

usZipCodeRequired
Link copied to clipboard
var usZipCodeRequired: Boolean

If both postalCodeEnabled and usZipCodeRequired are true, then postal code is a required field and must be a 5-digit US zip code. If postalCodeEnabled is false, this value is ignored

Functions

clearFields
Link copied to clipboard
fun clearFields()

Clears all text fields in the control

isEnabled
Link copied to clipboard
open override fun isEnabled(): Boolean

True if the form is enabled and can accept user input, false otherwise

setCardHint
Link copied to clipboard
fun setCardHint(hint: String): Unit?

Sets the hint for the card number

setCardNumber
Link copied to clipboard
fun setCardNumber(number: String?): Unit?

Sets the card number. Does not change field focus

setCvc
Link copied to clipboard
fun setCvc(cvc: String?): Unit?

Set the CVC value for the card. The maximum length is assumed to be 3, unless the brand of the card has already been set (by setting the card number)

setCvcLabel
Link copied to clipboard
fun setCvcLabel(label: String?): Unit?

Set the CVC field label

setEnabled
Link copied to clipboard
open override fun setEnabled(enabled: Boolean)

Enables or disables the control

setExpirationDate
Link copied to clipboard
fun setExpirationDate(@IntRange(from = 1, to = 12) month: Int, @IntRange(from = 0, to = 9999) year: Int)

Set the expiration date. This invokes the completion listener and changes focus to the CVC field if a valid date is entered