Skip to main content

CartPaymethods

Displays available payment methods for a shopping cart and lets the user select one. Filters out invalid methods and hides "on account" options for guest users by default.

Usage

import CartPaymethods from '@/components/propeller/CartPaymethods';

// Minimal — render payment methods from the cart
<CartPaymethods
cart={cart}
user={user}
onPaymethodSelect={(method) => setSelectedPayment(method)}
/>
// Custom price formatting and labels
<CartPaymethods
cart={cart}
user={user}
onPaymethodSelect={(method) => handlePaymentSelect(method)}
formatPrice={(price) => `USD ${price.toFixed(2)}`}
labels={{ noMethods: 'No payment options found for your order.' }}
/>
// Allow guest users to see "on account" payment methods
<CartPaymethods
cart={cart}
user={null}
showOnAccountForGuests={true}
onPaymethodSelect={(method) => handlePaymentSelect(method)}
/>
// Custom container class for styling
<CartPaymethods
cart={cart}
user={user}
paymentsContainerClass="my-custom-payments"
onPaymethodSelect={(method) => handlePaymentSelect(method)}
/>

Configuration

Required

PropTypeDescription
cartCartShopping cart object. Payment methods are read from cart.payMethods.
userContact | Customer | nullAuthenticated user. Pass null for guest checkout. Used to determine guest vs. logged-in filtering.

Display

PropTypeDefaultDescription
paymentsContainerClassstring'cart-paymethods'CSS class applied to the outer container.
showOnAccountForGuestsbooleanfalseWhen true, "on account" methods remain visible for unauthenticated users.

Callbacks

PropTypeDescription
onPaymethodSelect(paymethod: CartPaymethod) => voidFired when the user clicks a payment method card. Receives the full CartPaymethod object.

Formatting and Labels

PropTypeDefaultDescription
formatPrice(price: number) => stringFormats as €X.XXOverride the default price formatter for method surcharges.
labelsRecord<string, string>Label overrides. Supported keys: noMethods (empty-state message, default: "No payment methods available.").

Labels

KeyDefault value
noMethods"No payment methods available."

Behavior

  • Filtering: Methods without a code are excluded. "On account" variants (on_account, onaccount, on-account) are hidden for guest users unless showOnAccountForGuests is true.
  • Guest detection: A user is considered a guest when user is null.
  • Selection highlight: The selected method card receives a border-secondary border and a light background tint. Only one method can be selected at a time.
  • Price badge: Methods with price > 0 display a formatted surcharge badge. The default format is €X.XX; override with formatPrice.
  • Empty state: When no methods pass filtering, a configurable message is shown (label key: noMethods).
  • Layout: Methods render in a responsive grid — 1 column on mobile, 2 on sm, 3 on lg.

SDK Services

CartPaymethods reads payment methods from the Cart object, which is populated by the Propeller SDK. The relevant services are:

Fetching payment methods

Payment methods are included in the cart response when you fetch or start a cart via CartService:

import { CartService } from 'propeller-sdk-v2';

const cartService = new CartService(graphqlClient);
const cart = await cartService.getCart({ cartId: 'abc-123' });

// cart.payMethods contains CartPaymethod[]
// Each CartPaymethod has: code, name, price, externalCode, type

Setting the selected payment method

After the user selects a method (via onPaymethodSelect), persist it to the cart:

import { CartService } from 'propeller-sdk-v2';

const cartService = new CartService(graphqlClient);
await cartService.updateCart({
cartId: 'abc-123',
paymentData: {
method: selectedMethod.code,
},
});

GraphQL Queries and Mutations

Query — cart with payment methods

query Cart($cartId: String!) {
cart(cartId: $cartId) {
cartId
payMethods {
code
name
price
externalCode
type
}
}
}

Mutation — set payment method on cart

mutation CartUpdate($cartId: String!, $input: CartUpdateInput!) {
cartUpdate(cartId: $cartId, input: $input) {
cartId
payMethods {
code
name
price
}
}
}

Variables:

{
"cartId": "abc-123",
"input": {
"paymentData": {
"method": "ideal"
}
}
}