!open && handleClose()} > Take Payment {#if status === 'idle'}
Services
{#each booking.services ?? [] as service, i (service.service_id ?? `svc-${i}`)}
{service.service_name || 'Unknown Service'}
£ handlePriceInput(service.service_id, e.currentTarget.value)} /> {#if serviceOverrides[service.service_id] && Math.abs(parseFloat(serviceOverrides[service.service_id].price) - serviceOverrides[service.service_id].originalPrice) > 0.01} (was £{serviceOverrides[service.service_id].originalPrice.toFixed(2)}) {/if}
{/each}
{#if booking.discounts && booking.discounts.length > 0}
Applied Discounts
{((discountSum / subtotal) * 100).toFixed(0)}% Off Total
{#each booking.discounts as d}
{#if d.discount_source === 'loyalty'} Loyalty Stamp Card (10% Off) {:else if d.campaign_name} {d.campaign_name} {:else} Promo Campaign ({d.discount_percent}% Off) {/if}
-{formatCurrency(d.discount_amount)}
{/each}
{/if}
Total
{#if discountSum > 0.01} {formatCurrency(subtotal)} {/if} {formatCurrency(totalDue)}
{#if tipEnabled}
Total with Tip ({tipDisplay}) {formatCurrency(totalWithTip)}
{/if}
{#if savedCardList.length > 0} {/if}
{#if savedCardList.length > 0} {/if}
{:else if status === 'selecting'}
Total {formatCurrency(totalDue)}
Add a Tip
{#each tipPercentages as tip (tip.pct)} {/each}
£
{#if tipEnabled}
Total with Tip ({tipDisplay}) {formatCurrency(totalWithTip)}
{/if}
{:else if status === 'card-processing' || status === 'card-polling'}

Waiting for customer to tap card...

This may take a few moments

{:else if status === 'cash-entering'}
Total Due {formatCurrency(totalDue)}
£
{#if cashAmountNum >= totalDue}
Change Due {formatCurrency(changeDue)}
{#if changeDue > 0}
{/if}
{/if}
{:else if status === 'cash-confirming'}

Processing cash payment...

{:else if status === 'gift-entering'}
Total Due {formatCurrency(totalDue)}
{#if booking.user_id && customerBalance > 0}
Source
{/if} {#if useAccountBalance}
giftCardPaymentAmount = (e.target as HTMLInputElement).value} class="mt-1 font-mono text-lg" />

Available balance: {formatCurrency(customerBalance)}. Maximum of total due or balance can be used.

{:else}

Enter the 12-character code printed on the gift card

{/if}
{:else if status === 'gift-confirming'}

Processing gift card...

{:else if status === 'saved-card-selecting'}
Total Due {formatCurrency(totalDue)}
{#if loadingSavedCards}
{:else if savedCards.length === 0}

No saved cards found for this customer.

Add a card via Square Dashboard or use another payment method.

{:else}
Select a Saved Card {#each savedCards as card (card.id)} {/each}

This card may require bank app confirmation to complete. Ensure the customer has their phone ready.

{/if}
{:else if status === 'saved-card-processing'}

Processing saved card payment...

{:else if status === 'error' && error}

{error}

{:else if status === 'success' && paymentResult}

Payment Successful

Amount {formatCurrency(paymentResult.amount)}
{#if paymentResult.card_brand}
Card {paymentResult.card_brand} ****{paymentResult.last4}
{/if}
Status Completed
{/if}