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.
| Key | English | Arabic |
|---|---|---|
title | Your order | طلبك |
bundle | Bundle | الباقة |
price | Price | السعر |
payWith | Pay with | هتدفع بإيه |
wallet | Your TRNDR wallet | محفظة TRNDR بتاعتك |
walletSub | Paid at once from the money available. | بيتخصم على طول من المتاح. |
short | Not enough available in your wallet for this bundle. | المتاح في محفظتك مش مكفّي الباقة دي. |
unknown | We can't read your wallet's balance right now. Pay by card, or try again later. | مش قادرين نقرا رصيد محفظتك دلوقتي. ادفع بالكارت أو جرّب تاني بعدين. |
available | Available now | المتاح دلوقتي |
card | Card | كارت |
cardSub | You pay on Paymob. The credits arrive once the payment is confirmed. | هتدفع على Paymob. الرصيد بيوصل أول ما الدفع يتأكد. |
availableAfter | Available after you buy | المتاح بعد الشرا |
confirm | Buy now | اشتري دلوقتي |
confirmCard | Continue to payment | كمّل للدفع |
pending | Working… | شغالين… |
cancel | Cancel | إلغاء |
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
- Summary:
.kit-blk-sum, rows "Bundle · Growth" and "Price · EGP 4,800.00" (bold). - Pay with:
fieldset.kit-blk-optswith legend "Pay with":- Wallet option
label.kit-blk-opt(radio): "Your TRNDR wallet" + "Paid at once from the money available." (or the reason it is off); - Available now:
MoneyNote wallet_available+ amount; - Card option: "Card" + "You pay on Paymob. The credits arrive once the payment is confirmed."
- Wallet option
- After (wallet chosen and covered): "Available after you buy" + amount,
aria-live="polite". - Error (optional):
p.kit-blk-err[role=alert]. - Actions: Cancel + rasp confirm ("Buy now" for wallet, "Continue to payment" for card, "Working…" while pending).
Variants
| Setup | Look | When to use |
|---|---|---|
available set, card true (default) | Wallet + card options | Normal. |
available={null} | Card only, no wallet figures | Wallet not readable or not offered. |
card={false} | Wallet only | Card payments switched off. |
States
| State | Trigger |
|---|---|
| Wallet covers | available ≥ price: wallet enabled, "after" line shown. |
| Not enough | available < price: wallet disabled with "Not enough available in your wallet for this bundle." |
| Unknown balance | available not a 2-dp amount: wallet disabled with the "can't read" reason. |
| Card chosen | confirm reads "Continue to payment". |
| Pending | pending: all inputs and buttons disabled, aria-busy, "Working…". |
| Error | error: alert line above the actions. |
| Blocked confirm | chosen 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
methodto 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
fieldsetwith 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 arerole="alert"(mounted with the text); pending setsaria-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.
Related
BundleCard,BundleGrid,BundleResultBanner.TopUpAmountPicker: the same wallet / card choice for top-ups.Modal: its container.
See also: MoneyNote · Button · Money · useLanguage · useMoneyDisplay
Source
src/blocks/bundles/BundlePurchaseSummary.tsx (line 107) on GitHub.