- Preview
- Cards, wallet and pay-later approvals measured over the same hour.
- Inputs
- Provide period and methods with id, label, attempted, approved, and optional targetPercent from 0 to 100.
- Source options
- Aggregate unique authorisation attempts and approvals in the payment system for each method and the same period.
- Actions
- Use dots, arrow keys or a horizontal swipe to compare methods.
- Integration requirements
- A valid rate divides approved by positive attempted. Counts are integers or null; zero attempts or inconsistent counts leave the rate unavailable.
import type { PaymentApprovalsSnapshot } from "@lumo/widgets/catalog/ecommerce/payment-approvals";
type Attempt = { id: string; approved: boolean };
type Method = { id: string; label: string; attempts: Attempt[] | null };
// Use final authorisation outcomes filtered to the same reporting window.
export function adapt(period: string, methods: Method[]): PaymentApprovalsSnapshot {
return { period, methods: methods.map(({ id, label, attempts }) => {
const outcomes = attempts && new Map(attempts.map(attempt => [attempt.id, attempt.approved]));
return { id, label, attempted: outcomes?.size ?? null,
approved: outcomes ? [...outcomes.values()].filter(Boolean).length : null };
}) };
}