Skip to Content
BBRICKSv0.7.4
BlocksBundles

BundlePurchaseSummary

The bundle checkout's body (inside the kit Modal): the bundle and its price, how to pay (the wallet, with what is available, or a card on Paymob) as a native radio group, what stays available after a wallet purchase, and Cancel / confirm. A wallet that cannot cover the price is a disabled choice that says why.

import { BundlePurchaseSummary } from '@ergasti/bricks';

Examples

Confirm a bundle purchase

The bundle, what the wallet has available, and the choice of paying from the wallet or by card; the wallet option is off when the balance is too low.

Code
import { useState } from 'react';
import { BundlePurchaseSummary, type BundlePayMethod } from '@ergasti/bricks';

function Summary() {
  const [method, setMethod] = useState<BundlePayMethod>('wallet');
  return (
    <div style={{ maxWidth: 460 }}>
      <BundlePurchaseSummary
        bundle={{ id: 2, name: 'Growth', videos: 15, price: '6000.00', perVideo: '400.00', includes: ['15 creator videos', '2 revisions each'] }}
        available="43390.00" method={method} onMethodChange={setMethod} card onConfirm={() => {}} onCancel={() => {}}
      />
    </div>
  );
}

Paying, and a failed payment

pending locks the summary while the payment goes through; error says why it failed. card={false} hides the card option (wallet only); figure adds the price's money "?".

Code
import { BundlePurchaseSummary } from '@ergasti/bricks';

function States() {
  const bundle = { id: 2, name: 'Growth', videos: 15, price: '6000.00', perVideo: '400.00' };
  return (
    <div style={{ display: 'grid', gap: 16, gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))' }}>
      <BundlePurchaseSummary bundle={bundle} available="43390.00" method="wallet" onMethodChange={() => {}} card={false} pending figure="program_cost" onConfirm={() => {}} onCancel={() => {}} />
      <BundlePurchaseSummary bundle={bundle} available="43390.00" method="card" onMethodChange={() => {}} error="The payment was declined. Nothing was charged." onConfirm={() => {}} onCancel={() => {}} />
    </div>
  );
}

Props

Prop

Type

Labels

Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key bundlePurchaseSummary, or with the component's own prop where it has one. A {name} is a value the component fills in.

bundlePurchaseSummary
KeyEnglishArabic
titleYour orderطلبك
bundleBundleالباقة
pricePriceالسعر
payWithPay withهتدفع بإيه
walletYour TRNDR walletمحفظة TRNDR بتاعتك
walletSubPaid at once from the money available.بيتخصم على طول من المتاح.
shortNot enough available in your wallet for this bundle.المتاح في محفظتك مش مكفّي الباقة دي.
unknownWe can't read your wallet's balance right now. Pay by card, or try again later.مش قادرين نقرا رصيد محفظتك دلوقتي. ادفع بالكارت أو جرّب تاني بعدين.
availableAvailable nowالمتاح دلوقتي
cardCardكارت
cardSubYou pay on Paymob. The credits arrive once the payment is confirmed.هتدفع على Paymob. الرصيد بيوصل أول ما الدفع يتأكد.
availableAfterAvailable after you buyالمتاح بعد الشرا
confirmBuy nowاشتري دلوقتي
confirmCardContinue to paymentكمّل للدفع
pendingWorking…شغالين…
cancelCancelإلغاء

Design guidance

How the BRICKS design system uses BundlePurchaseSummary. Written in docs/content/components/BundlePurchaseSummary.md; the props above are read from the code, which wins where the two disagree.

The bundle checkout's body, shown inside a Modal: the bundle and its price, how to pay (TRNDR wallet or card on Paymob), what stays available after a wallet purchase, and Cancel / confirm.

It checks the wallet against the price with exact cents: a wallet that cannot cover the price, or whose balance cannot be read, is a disabled choice that says why, so the brand pays by card instead. After a wallet choice it shows "Available after you buy" (a polite live line). Bundles are not in the v3 mock; this was built for the live console.

Anatomy

  1. Summary: .kit-blk-sum, rows "Bundle · Growth" and "Price · EGP 4,800.00" (bold).
  2. Pay with: fieldset.kit-blk-opts with legend "Pay with":
    1. Wallet option label.kit-blk-opt (radio): "Your TRNDR wallet" + "Paid at once from the money available." (or the reason it is off);
    2. Available now: MoneyNote wallet_available + amount;
    3. Card option: "Card" + "You pay on Paymob. The credits arrive once the payment is confirmed."
  3. After (wallet chosen and covered): "Available after you buy" + amount, aria-live="polite".
  4. Error (optional): p.kit-blk-err[role=alert].
  5. Actions: Cancel + rasp confirm ("Buy now" for wallet, "Continue to payment" for card, "Working…" while pending).

Variants

SetupLookWhen to use
available set, card true (default)Wallet + card optionsNormal.
available={null}Card only, no wallet figuresWallet not readable or not offered.
card={false}Wallet onlyCard payments switched off.

States

StateTrigger
Wallet coversavailable ≥ price: wallet enabled, "after" line shown.
Not enoughavailable < price: wallet disabled with "Not enough available in your wallet for this bundle."
Unknown balanceavailable not a 2-dp amount: wallet disabled with the "can't read" reason.
Card chosenconfirm reads "Continue to payment".
Pendingpending: all inputs and buttons disabled, aria-busy, "Working…".
Errorerror: alert line above the actions.
Blocked confirmchosen method cannot pay: confirm disabled.

Usage

const [method, setMethod] = useState<BundlePayMethod>('wallet');

<Modal open title="Buy a UGC bundle" onClose={close}>
  <BundlePurchaseSummary
    bundle={{ id: 2, name: 'Growth', videos: 12, price: '4800.00', perVideo: '400.00', bestValue: true }}
    available="43390.00"
    method={method} onMethodChange={setMethod}
    onConfirm={(m) => buy.run({ bundleId: 2, method: m })} onCancel={close}
    pending={buy.pending} error={buy.error?.message}
  />
</Modal>

Where it appears

  • Not in the v3 mocks (blocks inventory: built). Shown in the missing-brand gallery in two modal frames (wallet covers / not enough in wallet).

Guidelines

Do

  • Default method to wallet when it covers the price, else card.
  • Pass the server's balance string; let the block compare.

Don't

  • Don't hide the wallet option when it is short; the reason teaches the brand to top up.
  • Don't add your own footer buttons in the modal.

RTL and Arabic

  • Mirrors; amounts stay LTR. Arabic: "طلبك", "هتدفع بإيه", "محفظة TRNDR بتاعتك", "اشتري دلوقتي", "كمّل للدفع".

Tokens

--card, --line, --soft, --ink, --ink-3, --rasp, --rasp-50, --bad, --focus-ring, --font-family-display.

Accessibility

  • A native radio group in a fieldset with a legend; each radio is named by its title and described by its sub line or reason.
  • The "after" line is aria-live="polite", but it mounts with its text when a covered wallet is chosen, so that first appearance may not be read; it is in the reading order right after the options. Errors are role="alert" (mounted with the text); pending sets aria-busy.

Found in the source

  • Roles in the markup: alert.
  • ARIA attributes set: aria-labelledby, aria-describedby, aria-busy, aria-live.

Read from the component's source and tests. See Accessibility for the patterns the library follows.

See also: MoneyNote · Button · Money · useLanguage · useMoneyDisplay

Source

src/blocks/bundles/BundlePurchaseSummary.tsx (line 107) on GitHub.

On this page