Skip to navigation

Payment button

AfterpayPaymentButton is a branded button that customers tap to pay with Clearpay.

Mint payment button with the text Pay now with and a black Clearpay wordmark

Before you add the button, set the merchant configuration. See UI components.

Add the button

<com.afterpay.android.view.AfterpayPaymentButton
android:id="@+id/afterpay_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:afterpayButtonText="checkout"
app:afterpayStyle="default_style" />

The button scales its artwork to fit the width you give it and keeps the aspect ratio. Set the width and use wrap_content for the height.

The button sets a content description for screen readers, so you don’t need to add one. The description always reads “Pay now with Clearpay”, whatever the button text. If you use BUY, CHECKOUT, or CONTINUE, set contentDescription to match.

Start checkout when the customer taps the button

AfterpayPaymentButton extends AppCompatImageButton. It doesn’t start checkout by itself, so set a click listener that starts your checkout:

findViewById<AfterpayPaymentButton>(R.id.afterpay_button)
.setOnClickListener {
// Start checkout, for example with Checkout V2.
checkoutLauncher.launch(Afterpay.createCheckoutV2Intent(this))
}

For the full flow, see the Android implementation guide.

Button text

Choose the text that suits the purchase. The default is payNow in XML, or ButtonText.PAY in Kotlin.

XML app:afterpayButtonTextKotlin ButtonTextText
payNowPAYPay now with
buyNowBUYBuy now with
checkoutCHECKOUTCheckout with
placeOrderCONTINUEPlace order with

In Kotlin, the full enum name is AfterpayPaymentButton.ButtonText.

Mint payment button with the text Pay now with Clearpay Mint payment button with the text Buy now with Clearpay Mint payment button with the text Checkout with Clearpay Mint payment button with the text Place order with Clearpay

Styles

Set app:afterpayStyle in XML or style in Kotlin. The default is Default.

StyleXML valueAppearance
AfterpayWidgetStyle.Defaultdefault_styleMint button with black text and a black Clearpay wordmark
AfterpayWidgetStyle.AltaltBlack button with mint text and a mint Clearpay wordmark
AfterpayWidgetStyle.MonochromeDarkmonochromeDarkBlack button with white text and a white Clearpay wordmark
AfterpayWidgetStyle.MonochromeLightmonochromeLightWhite button with no outline, black text, and a black Clearpay wordmark

For the color schemes behind each style, see Styles and color schemes.

Visibility

The button hides itself when the SDK isn’t enabled for the current configuration, for example when the customer’s language isn’t supported. It rechecks its visibility when the configuration changes. See When components are hidden.

Attributes and properties

XML attributeKotlin propertyTypeDefault
app:afterpayButtonTextbuttonTextAfterpayPaymentButton.ButtonTextpayNow (PAY)
app:afterpayStylestyleAfterpayWidgetStyledefault_style (Default)