GooglePayButton

class GooglePayButton @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : ConstraintLayout

Convenience view that wraps Google's PayButton

This view provides all styling and customization options provided by Google's PayButton but also adds the following extra functionality:

  • Styling via XML attributes

  • Use of android:onClick attribute in XML files

  • Ability to update button options after view creation

Important:

It is possible to use Google's PayButton directly. However, when doing so it is important to ensure that your app uses the same version of com.google.android.gms:play-services-wallet as the Olo Pay SDK. Version mismatches could cause unexpected behavior.


Styling

This view provides all styling options provided by Google's PayButton. Styling can be done via XML attributes, or by calling updateButton.

XML attributes can be set directly on the view or they can be defined in a style that gets applied to the view. THe following examples each produce the same result:

Customizations applied directly to the view:

// NOTE: This example assumes a namespace definition of `app`. Replace
// this with your own namespace qualifier if using something different
<com.olo.olopay.googlepay.GooglePayButton
app:googlePayButtonTheme="dark"
app:googlePayButtonType="checkout"
app:googlePayCornerRadius="4dp"
/>

Customizations applied in a style:

// Style definition
<style name="GooglePayButtonStyle">
<item name="googlePayButtonTheme">dark</item>
<item name="googlePayButtonType">checkout</item>
<item name="googlePayCornerRadius">4dp</item>
</style>

//Layout file
<com.olo.olopay.googlepay.GooglePayButton
style="@style/GooglePayButtonStyle"
/>

Constructors

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

Creates a new instance of GooglePayButton. Default styling uses ButtonConstants.ButtonTheme.DARK, ButtonConstants.ButtonType.CHECKOUT, and a corner radius of 8dp

Functions

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

Set the enabled/clickable state of the button

Link copied to clipboard
open override fun setOnClickListener(listener: View.OnClickListener?)

Set a callback to handle click events.

Link copied to clipboard
fun updateButton(theme: GooglePayButtonTheme, type: GooglePayButtonType, cornerRadiusPx: Int)

Update the button with new options