Skip to navigation

Price breakdown

AfterpayPriceBreakdown shows how a price splits into four interest-free payments, followed by the logo and a link to more information. For US merchants, it shows the Cash App Afterpay lockup.

Text reading or 4 interest-free payments of $25.00 with, followed by the Cash App Afterpay lockup and an info icon

Before you add the price breakdown, set the merchant configuration. The component uses it to format the amounts and to check your order limits. See UI components.

Add the price breakdown

Add the view in XML or Kotlin, then set totalAmount in code. The total is a BigDecimal and defaults to zero.

<com.afterpay.android.view.AfterpayPriceBreakdown
android:id="@+id/price_breakdown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:afterpayStyle="alt" />
findViewById<AfterpayPriceBreakdown>(R.id.price_breakdown)
.totalAmount = BigDecimal("100.00")

app:afterpayStyle is the only XML attribute. Set the other options in code.

The text uses your theme’s android:textColorPrimary, and the text link uses android:textColorSecondary. The component sets a content description that reads out the full sentence.

What the component shows

The content depends on the total and on the minimum and maximum order amounts in your configuration.

When the total is within your order limits, the component shows the installment amount:

Price breakdown reading or 4 interest-free payments of $25.00 with Cash App Afterpay

When the total is below the minimum or above the maximum, the component shows the range of order amounts that you accept:

Price breakdown reading Cash App Afterpay available for orders between $1 and $4,000

When you haven’t set a configuration, the component hides itself.

The component refreshes when you change totalAmount or any other property, and when the configuration changes.

Styles

Set app:afterpayStyle in XML or style in Kotlin to change the logo colors. The default is Default. The logo has no background, so choose a style that contrasts with the color behind it.

StyleXML valueUse onAppearance
AfterpayWidgetStyle.Defaultdefault_styleDark backgroundsPrice breakdown on black with a white Afterpay wordmark
AfterpayWidgetStyle.AltaltLight backgroundsPrice breakdown on white with a black Afterpay wordmark
AfterpayWidgetStyle.MonochromeDarkmonochromeDarkDark backgroundsPrice breakdown on black with a white lockup
AfterpayWidgetStyle.MonochromeLightmonochromeLightLight backgroundsPrice breakdown on white with a black lockup

On a dark background, also use a theme whose android:textColorPrimary is light, so the text stays legible.

Logo type

logoType sets which logo appears in the sentence. It takes an AfterpayLogoType: LOCKUP, BADGE, or COMPACT_BADGE.

For US merchants, the default is LOCKUP, and it’s the only supported value.

Use the lockup for US merchants

With a US configuration, setting logoType to BADGE or COMPACT_BADGE throws an IllegalStateException in the sandbox environment. In production, the component hides itself instead.

For merchants in other regions, the default is BADGE. With LOCKUP, the SDK applies only the foreground color of the color scheme.

Intro text

introText sets the word or words before the installment amount. It takes an AfterpayIntroText and defaults to OR.

ValueRenders as
ORor
OR_TITLEOr
MAKEmake
MAKE_TITLEMake
PAYpay
PAY_TITLEPay
INin
IN_TITLEIn
PAY_INpay in
PAY_IN_TITLEPay in
EMPTYNo intro text
breakdown.introText = AfterpayIntroText.MAKE_TITLE
Price breakdown reading Make 4 interest-free payments of $25.00 with Cash App Afterpay

Optional words

Two Boolean properties control optional words in the sentence. Both default to true.

  • showInterestFreeText: shows “interest-free” before the word payments. The SDK always leaves out this word for UK merchants and when the configured currency is British pounds (GBP).
  • showWithText: shows “with” before the logo.
breakdown.showInterestFreeText = false
breakdown.showWithText = false
Price breakdown reading or 4 payments of $25.00 followed by the Cash App Afterpay lockup

Tapping the link at the end of the sentence opens a page with more information about Afterpay inside your app. Configure the link with moreInfoOptions, which takes an AfterpayMoreInfoOptions.

AfterpayMoreInfoOptions has two constructors:

  • AfterpayMoreInfoOptions(modalTheme, isCbtEnabled, modalLinkStyle): all parameters are optional.
    • modalTheme: an AfterpayModalTheme, either MINT (default) or WHITE.
    • isCbtEnabled: whether the page shows cross-border trade details. Defaults to false. Not every combination of locale and cross-border trade has a page.
    • modalLinkStyle: the link style. See Link styles.
  • AfterpayMoreInfoOptions(modalId, modalLinkStyle):
    • modalId: the filename, without the .html extension, of a page hosted at https://static.afterpay.com/modal/.
    • modalLinkStyle: optional. The link style.

With the first constructor, the SDK picks the page for the configured locale and the customer’s language.

breakdown.moreInfoOptions = AfterpayMoreInfoOptions(
modalTheme = AfterpayModalTheme.WHITE,
)

modalLinkStyle takes an AfterpayModalLinkStyle. The default is CircledInfoIcon.

ValueLink
CircledInfoIconA circled “i” character
MoreInfoTextThe underlined text “More Info”
LearnMoreTextThe underlined text “Learn More”
CircledQuestionIconA circled question mark icon
CircledLogoA small circled Afterpay logo
CustomContent that you provide
NoneNo link
Four price breakdowns that end with More Info, Learn More, a circled question mark, and a circled logo
breakdown.moreInfoOptions = AfterpayMoreInfoOptions(
modalLinkStyle = AfterpayModalLinkStyle.LearnMoreText,
)

To use your own link content, call AfterpayModalLinkStyle.Custom.setContent with a CharSequence before you set the options:

val content = SpannableStringBuilder().apply {
append("Tap ")
append("here", StyleSpan(Typeface.BOLD), SPAN_EXCLUSIVE_EXCLUSIVE)
}
AfterpayModalLinkStyle.Custom.setContent(content)
breakdown.moreInfoOptions = AfterpayMoreInfoOptions(
modalLinkStyle = AfterpayModalLinkStyle.Custom,
)

Custom is a single shared object, so its content applies to every price breakdown that uses it.

Attributes and properties

PropertyXML attributeTypeDefault
totalAmountNoneBigDecimal0
styleapp:afterpayStyleAfterpayWidgetStyleDefault
logoTypeNoneAfterpayLogoTypeLOCKUP in the US, BADGE elsewhere
introTextNoneAfterpayIntroTextOR
showInterestFreeTextNoneBooleantrue
showWithTextNoneBooleantrue
moreInfoOptionsNoneAfterpayMoreInfoOptionsMint theme, CircledInfoIcon link