Search documentation v0.10.1

Select Payment

Allow users to select a payment method

Source Report Issue

Use the SelectPayment component to allow users to choose a preferred payment method during checkout or transactions. They simplify the payment process with a clear, intuitive interface for selecting payment options, reducing friction along the way, leading to higher completed purchases. Payment logos are available on Figma.

Preview
Unlock code
How to use the SelectPayment component in Astro
---
const payments = [
{
method: 'visa',
name: 'Visa ending in 1234',
subText: 'Expires on 01/2025'
},
{
method: 'mastercard',
name: 'Mastercard ending in 5678',
subText: 'Expired on 01/2024',
disabled: true
},
{
method: 'paypal',
name: 'PayPal',
subText: 'Pay with PayPal',
selected: true
}
]
---
<SelectPayment
title="Preview"
payments={payments}
buttons={[
{ text: 'Cancel', theme: 'secondary' },
{ text: 'Continue' }
]}
/>

The SelectPayment component expects a payments prop that should be an array of payment objects, with the following available properties:

You can also specify CTA buttons at the end of the list using the buttons prop which expects an array of ButtonProps objects, along with a text and icon properties to set the text or the icon for the button.

The above example also sets a title prop. This is specific to the Card component and can be omitted.

States

The component supports the use of the following two states to customize your payment options:

Card Types

The SelectPayment component extends the Card component, meaning you can use card-specific props with your component. You can use the compact and secondary props to get visually different types of cards:

Compact
Secondary
Unlock code
Card types with SelectPayment
<SelectPayment
title="Compact"
payments={payments}
buttons={[ ... ]}
compact={true}
/>
Unlock code
Card types with SelectPayment
<SelectPayment
title="Secondary"
payments={payments}
buttons={[ ... ]}
secondary={true}
/>

API

Unlock code
Component API reference
type SelectPaymentProps = {
payments: {
method: 'alipay'
| 'amazon'
| 'amex'
| 'apple'
| 'bancontact'
| 'bitcoin'
| 'discover'
| 'google'
| 'ideal'
| 'klarna'
| 'maestro'
| 'mastercard'
| 'paypal'
| 'payoneer'
| 'samsung'
| 'skrill'
| 'sofort'
| 'stripe'
| 'venmo'
| 'visa'
| 'wechat'
| 'wise'
name: string
subText?: string
selected?: boolean
disabled?: boolean
}[]
buttons?: ({
text: string
icon?: string
} & ButtonProps)[]
[key: string]: any
} & CardProps
Please see the documentation of the Button and Card components for the ButtonProps type and CardProps types.
PropPurpose
payments Sets the list of available payment methods.
payments.method Sets the payment method for the item.
payments.name Sets a name for the payment method.
payments.subText Sets additional text under the payment's name.
payments.selected Sets the payment option as selected.
payments.disabled Sets the payment option as disabled.
buttons Sets CTA buttons at the bottom of the payment options.
buttons.text Sets the label for the CTA.
buttons.icon Sets an icon for the CTA. You can pass SVG strings, or an icon type for Astro components.