diff --git a/data/providers/hub2.json b/data/providers/hub2.json index 9e198e0..a1b7671 100644 --- a/data/providers/hub2.json +++ b/data/providers/hub2.json @@ -7,30 +7,5 @@ ], "website": "https://www.hub2.io", "summary": "Payment infrastructure provider offering an API to collect and disburse funds through mobile money and other local methods.", - "sources": { - "umoa-ep-register-2026-08": { - "url": "https://www.bceao.int/sites/default/files/2026-10/LISTE_DES_ETABLISSEMENTS_DE_PAIEMENT_AGR%C3%89%C3%89S_DANS_L-UMOA_au_31_ao%C3%BBt_2026.pdf", - "kind": "regulator_register", - "observed_at": "2026-10-20", - "note": "UMOA list of licensed payment institutions, as of 2026-08-31." - }, - "umoa-register-2026-06": { - "url": "https://www.cb-umoa.org/sites/default/files/Liste%20%20des%20EME%20ET%20EP%20de%20l%27UMOA%202026.pdf", - "kind": "regulator_register", - "observed_at": "2026-10-20", - "note": "UMOA list of e-money and payment institutions, as of 2026-06-29." - } - }, - "not_found_in": [ - { - "regulator": "bceao", - "checked_at": "2026-10-20", - "source": "umoa-ep-register-2026-08" - }, - { - "regulator": "bceao", - "checked_at": "2026-10-20", - "source": "umoa-register-2026-06" - } - ] + "sources": {} } diff --git a/docs/architecture.md b/docs/architecture.md index 2496c56..4e5a304 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -86,6 +86,8 @@ A provider belongs to one or more families: - **integration**: public docs, test mode, webhook signature, official SDKs, public pricing, status page. - **onboarding**: individuals allowed, documents, delay, deposit. +- **operations**: amount limits per payment, recurring payments, e-commerce plugins, what a payout needs, activities + the terms refuse. - **incidents**: dated and sourced outages, breaches, sanctions. ## Glossary diff --git a/src/components/provider/ProviderPage.astro b/src/components/provider/ProviderPage.astro index 6728080..266d5e0 100644 --- a/src/components/provider/ProviderPage.astro +++ b/src/components/provider/ProviderPage.astro @@ -13,7 +13,7 @@ import SourceRef from '../SourceRef.astro'; import type { Locale } from '../../i18n/locales'; import { dataText, localePath, providerStrings } from '../../i18n/translate'; import type { Provider } from '../../schema/provider'; -import { integrationFacts, onboardingFacts } from '../../lib/site-facts'; +import { integrationFacts, onboardingFacts, operationsFacts } from '../../lib/site-facts'; import { flagUrl, formatDate, initial } from '../../lib/site-format'; import { disputedCountries, settlementFacts } from '../../lib/site-settlements'; import { sectionSourceKeys } from '../../lib/site-sources'; @@ -55,6 +55,7 @@ const regulators = ownRegulators(provider); const hq = provider.headquarters; const transparency = integrationFacts(provider, strings); const onboarding = onboardingFacts(provider, strings); +const operations = operationsFacts(provider, strings); const settlements = settlementFacts(provider, strings); const disputes = disputedCountries(provider, strings).map((place) => (place === '' ? strings.settlements.noCountry : place)); const empty = { @@ -62,11 +63,12 @@ const empty = { fees: provider.fees.length === 0, settlements: settlements.length === 0, onboarding: onboarding.every((fact) => fact.value === null), + operations: operations.every((fact) => fact.value === null), integration: transparency.every((fact) => fact.value === null), licences: provider.licences.length + provider.not_found_in.length === 0, }; -const sourceKeys = sectionSourceKeys(provider, onboarding, transparency); -const sections = (['coverage', 'fees', 'settlements', 'onboarding', 'integration', 'licences'] as const).map((id) => ({ id, title: strings.sections[id] })); +const sourceKeys = sectionSourceKeys(provider, onboarding, operations, transparency); +const sections = (['coverage', 'fees', 'settlements', 'onboarding', 'operations', 'integration', 'licences'] as const).map((id) => ({ id, title: strings.sections[id] })); --- @@ -138,6 +140,11 @@ const sections = (['coverage', 'fees', 'settlements', 'onboarding', 'integration {empty.onboarding ? : } +
+

{strings.sections.operations}

+ {empty.operations ? : } + +

{strings.sections.integration}

{ diff --git a/src/i18n/provider-en.ts b/src/i18n/provider-en.ts index 6a286c8..5a6092d 100644 --- a/src/i18n/provider-en.ts +++ b/src/i18n/provider-en.ts @@ -7,7 +7,7 @@ export const PROVIDER_EN: ProviderStrings = { breadcrumbLabel: 'Breadcrumb', providers: 'Providers', sectionsLabel: 'Sections', - sections: { coverage: 'Coverage', fees: 'Fees', settlements: 'Settlement', integration: 'Integration', onboarding: 'Opening an account', licences: 'Licences' }, + sections: { coverage: 'Coverage', fees: 'Fees', settlements: 'Settlement', integration: 'Integration', onboarding: 'Opening an account', operations: 'Operations', licences: 'Licences' }, integrationIntro: 'The six points of the transparency index: what the provider publishes and anyone can check.', basedIn: (country) => `Based in ${country}`, checkedOn: (date) => `Checked against its sources on ${date}`, @@ -20,6 +20,7 @@ export const PROVIDER_EN: ProviderStrings = { no: 'No', none: 'None', days: (min, max) => (min === max ? `${min} days` : `${min} to ${max} days`), + inCountry: (country, value) => `${country}: ${value}`, facts: { publicDocs: 'Public documentation', testMode: 'Sandbox (test mode)', @@ -32,6 +33,11 @@ export const PROVIDER_EN: ProviderStrings = { documents: 'Documents asked', timeToOpen: 'Time to open an account', securityDeposit: 'Security deposit', + limits: 'Amount per payment', + recurring: 'Recurring payments', + plugins: 'E-commerce plugins', + payoutRequirements: 'Before sending money', + prohibited: 'Activities refused', }, coverage: { country: 'Country', diff --git a/src/i18n/provider-fr.ts b/src/i18n/provider-fr.ts index dd761bd..9d2e70c 100644 --- a/src/i18n/provider-fr.ts +++ b/src/i18n/provider-fr.ts @@ -7,7 +7,7 @@ export const PROVIDER_FR: ProviderStrings = { breadcrumbLabel: 'Fil d’Ariane', providers: 'Services', sectionsLabel: 'Sections', - sections: { coverage: 'Couverture', fees: 'Frais', settlements: 'Reversement', integration: 'Intégration', onboarding: 'Ouverture de compte', licences: 'Licences' }, + sections: { coverage: 'Couverture', fees: 'Frais', settlements: 'Reversement', integration: 'Intégration', onboarding: 'Ouverture de compte', operations: 'Fonctionnement', licences: 'Licences' }, integrationIntro: 'Les six points de l’indice de transparence : ce que le service publie et que chacun peut vérifier.', basedIn: (country) => `Siège : ${country}`, checkedOn: (date) => `Vérifié auprès de ses sources le ${date}`, @@ -20,6 +20,7 @@ export const PROVIDER_FR: ProviderStrings = { no: 'Non', none: 'Aucun', days: (min, max) => (min === max ? `${min} ${min > 1 ? 'jours' : 'jour'}` : `${min} à ${max} jours`), + inCountry: (country, value) => `${country} : ${value}`, facts: { publicDocs: 'Documentation publique', testMode: 'Sandbox (mode test)', @@ -32,6 +33,11 @@ export const PROVIDER_FR: ProviderStrings = { documents: 'Documents demandés', timeToOpen: 'Délai d’ouverture du compte', securityDeposit: 'Dépôt de garantie', + limits: 'Montant par paiement', + recurring: 'Paiements récurrents', + plugins: 'Plugins e-commerce', + payoutRequirements: 'Avant d’envoyer de l’argent', + prohibited: 'Activités refusées', }, coverage: { country: 'Pays', diff --git a/src/i18n/provider-types.ts b/src/i18n/provider-types.ts index c0dc8d7..1614bef 100644 --- a/src/i18n/provider-types.ts +++ b/src/i18n/provider-types.ts @@ -28,6 +28,8 @@ export interface ProviderStrings { readonly no: string; readonly none: string; readonly days: (min: number, max: number) => string; + /** A value that holds in one country only: `Ghana: up to 5,000 GHS`. */ + readonly inCountry: (country: string, value: string) => string; readonly facts: FactStrings; readonly coverage: CoverageStrings; /** The fold that hides a section's sources: `Sources (3)`. */ @@ -52,10 +54,11 @@ export interface SectionStrings { readonly settlements: string; readonly integration: string; readonly onboarding: string; + readonly operations: string; readonly licences: string; } -/** Labels of the lines of the integration and onboarding sections. */ +/** Labels of the lines of the integration, onboarding and operations sections. */ export interface FactStrings { readonly publicDocs: string; readonly testMode: string; @@ -68,6 +71,11 @@ export interface FactStrings { readonly documents: string; readonly timeToOpen: string; readonly securityDeposit: string; + readonly limits: string; + readonly recurring: string; + readonly plugins: string; + readonly payoutRequirements: string; + readonly prohibited: string; } export interface CoverageStrings { diff --git a/src/lib/check-references.ts b/src/lib/check-references.ts index 80cf451..cf2215c 100644 --- a/src/lib/check-references.ts +++ b/src/lib/check-references.ts @@ -11,6 +11,7 @@ export function checkReferences(provider: Provider, ctx: ReferenceContext): void checkAbsenceReferences(provider, ctx); checkFeeReferences(provider, ctx); checkSettlementReferences(provider, ctx); + checkOperationsReferences(provider, ctx); checkIncidentReferences(provider, ctx); } @@ -69,6 +70,16 @@ function checkSettlementReferences(provider: Provider, ctx: ReferenceContext): v provider.settlements.forEach((delay, i) => requireCountry(ctx, delay.country, `settlements.${i}.country`)); } +function checkOperationsReferences(provider: Provider, ctx: ReferenceContext): void { + provider.operations.transaction_limits?.value.forEach((limit, i) => { + const path = `operations.transaction_limits.value.${i}`; + + requireCountry(ctx, limit.country, `${path}.country`); + requireCurrency(ctx, limit.minimum?.currency, `${path}.minimum.currency`); + requireCurrency(ctx, limit.maximum?.currency, `${path}.maximum.currency`); + }); +} + function checkIncidentReferences(provider: Provider, ctx: ReferenceContext): void { provider.incidents.forEach((incident, i) => { incident.countries.forEach((code, j) => requireCountry(ctx, code, `incidents.${i}.countries.${j}`)); diff --git a/src/lib/data-texts.ts b/src/lib/data-texts.ts index 6fcddae..33fb837 100644 --- a/src/lib/data-texts.ts +++ b/src/lib/data-texts.ts @@ -1,6 +1,6 @@ import type { Provider } from '../schema/provider'; -/** Free text of a provider that its sheet shows as is: summary, coverage notes, fee plans and notes, settlement notes, fact notes, onboarding documents. */ +/** Free text of a provider that its sheet shows as is: summary, coverage notes, fee plans and notes, settlement notes, fact notes, onboarding documents, payout requirements and refused activities. */ export function displayedTexts(provider: Provider): string[] { const texts: string[] = []; @@ -19,11 +19,13 @@ export function displayedTexts(provider: Provider): string[] { pushDefined(texts, delay.note); } - const { integration, onboarding } = provider; + const { integration, onboarding, operations } = provider; const facts = [ integration.public_docs, integration.sandbox, integration.webhook_signature, integration.official_sdks, integration.public_pricing, integration.status_page, onboarding.signup, onboarding.individuals_allowed, onboarding.documents, onboarding.days, onboarding.security_deposit, + operations.transaction_limits, operations.recurring_payments, operations.ecommerce_plugins, + operations.payout_requirements, operations.prohibited_activities, ]; for (const fact of facts) { @@ -31,6 +33,8 @@ export function displayedTexts(provider: Provider): string[] { } texts.push(...(onboarding.documents?.value ?? [])); + texts.push(...(operations.payout_requirements?.value ?? [])); + texts.push(...(operations.prohibited_activities?.value ?? [])); return [...new Set(texts)]; } diff --git a/src/lib/site-facts.ts b/src/lib/site-facts.ts index 0aa306c..e145054 100644 --- a/src/lib/site-facts.ts +++ b/src/lib/site-facts.ts @@ -1,6 +1,9 @@ import type { ProviderStrings } from '../i18n/provider-types'; +import { countryName } from '../i18n/country-names'; import { dataText } from '../i18n/translate'; import type { Provider } from '../schema/provider'; +import type { TransactionLimit } from '../schema/amount-types'; +import { formatMoney } from './site-format'; import { transparency } from './transparency'; import type { PointLevel } from './transparency-types'; import { sourceLabel } from './site-sources'; @@ -53,6 +56,40 @@ export function onboardingFacts(provider: Provider, strings: ProviderStrings): F ]; } +export function operationsFacts(provider: Provider, strings: ProviderStrings): Fact[] { + const { operations } = provider; + const { facts } = strings; + const texts = (values: string[]): string => values.map((text) => dataText(strings.locale, text)).join(', '); + + return [ + fact(facts.limits, operations.transaction_limits, (limits) => limits.map((limit) => limitLine(limit, strings)).join(' · '), strings), + fact(facts.recurring, operations.recurring_payments, (value) => yesNo(value, strings), strings, operations.recurring_payments?.value === true ? 'good' : 'bad'), + fact(facts.plugins, operations.ecommerce_plugins, (value) => (value.length === 0 ? strings.none : value.join(', ')), strings, operations.ecommerce_plugins?.value.length === 0 ? 'bad' : undefined), + fact(facts.payoutRequirements, operations.payout_requirements, texts, strings), + fact(facts.prohibited, operations.prohibited_activities, texts, strings), + ]; +} + +/** `200 XOF to 9,999,999 XOF`, prefixed with the country when the limit holds in one country only. */ +function limitLine(limit: TransactionLimit, strings: ProviderStrings): string { + const amounts = limitAmounts(limit, strings); + + return limit.country === undefined ? amounts : strings.inCountry(countryName(strings.locale, limit.country), amounts); +} + +/** Smallest and largest amount as one phrase; the schema guarantees at least one bound. */ +function limitAmounts({ minimum, maximum }: TransactionLimit, { locale, fees }: ProviderStrings): string { + if (maximum === undefined) { + return minimum === undefined ? '' : fees.from(formatMoney(minimum, locale)); + } + + if (minimum === undefined) { + return fees.upTo(formatMoney(maximum, locale)); + } + + return fees.range(formatMoney(minimum, locale), formatMoney(maximum, locale)); +} + /** `pill` shows the value as a pill of that tone; without it the value is plain text. */ function fact(label: string, sourced: Sourced | undefined, show: (value: T) => string, strings: ProviderStrings, pill?: Pill): Fact { if (sourced === undefined) { diff --git a/src/lib/site-sources.ts b/src/lib/site-sources.ts index 1e5cfb8..db6f5d1 100644 --- a/src/lib/site-sources.ts +++ b/src/lib/site-sources.ts @@ -7,12 +7,13 @@ import type { Fact, RecapLink, SectionSources, SourceGroup } from './site-types' const MAX_SEGMENTS = 2; /** Source keys of each section of a sheet, in the order the section uses them. */ -export function sectionSourceKeys(provider: Provider, onboarding: Fact[], integration: Fact[]): SectionSources { +export function sectionSourceKeys(provider: Provider, onboarding: Fact[], operations: Fact[], integration: Fact[]): SectionSources { return { coverage: [...provider.coverage.map((entry) => entry.source), ...provider.capabilities.map((capability) => capability.source)], fees: provider.fees.map((fee) => fee.source), settlements: provider.settlements.map((delay) => delay.source), onboarding: factSources(onboarding), + operations: factSources(operations), integration: factSources(integration), licences: [...provider.licences.map((licence) => licence.source), ...provider.not_found_in.map((absence) => absence.source)], }; diff --git a/src/lib/site-types.ts b/src/lib/site-types.ts index f634a9e..9726e60 100644 --- a/src/lib/site-types.ts +++ b/src/lib/site-types.ts @@ -114,7 +114,7 @@ export interface RecapLink { } /** Source keys of each section of a sheet. */ -export type SectionSources = Record<'coverage' | 'fees' | 'settlements' | 'onboarding' | 'integration' | 'licences', string[]>; +export type SectionSources = Record<'coverage' | 'fees' | 'settlements' | 'onboarding' | 'operations' | 'integration' | 'licences', string[]>; /** A piece of a data note: plain text, or a link written as a short label. */ export type NotePart = { kind: 'text'; text: string } | { kind: 'link'; url: string; label: string }; diff --git a/src/schema/amount-types.ts b/src/schema/amount-types.ts index a377705..79e1446 100644 --- a/src/schema/amount-types.ts +++ b/src/schema/amount-types.ts @@ -18,6 +18,17 @@ export interface AmountBand { to?: Money | undefined; } +/** Smallest and largest amount of one payment. */ +export interface AmountLimits { + minimum?: Money | undefined; + maximum?: Money | undefined; +} + +/** Payment limits, for every country or for the one named. */ +export interface TransactionLimit extends AmountLimits { + country?: string | undefined; +} + /** A rule violation, located relative to the object the rule checked. */ export interface RuleProblem { path: string[]; diff --git a/src/schema/provider-parts.ts b/src/schema/provider-parts.ts index a73725d..5de2713 100644 --- a/src/schema/provider-parts.ts +++ b/src/schema/provider-parts.ts @@ -16,7 +16,7 @@ import { WEBHOOK_SIGNATURES, } from './constants'; import { countryCodeSchema as countryCode, currencyCodeSchema as currencyCode, isoDateSchema, slugSchema, webUrlSchema } from './primitives'; -import { addRuleProblems, bandProblems, feeAmountProblems } from './rules'; +import { addRuleProblems, bandProblems, feeAmountProblems, limitListProblems, limitProblems } from './rules'; import { sourceKeySchema } from './source'; import { sourcedFact } from './sourced-fact'; @@ -128,16 +128,43 @@ export const integrationSchema = z.strictObject({ docs_url: webUrlSchema.optional(), }); +/** A delay in days, from the shortest to the longest the source gives. */ +export const dayRangeSchema = z + .strictObject({ min: z.number().int().nonnegative(), max: z.number().int().nonnegative() }) + .refine((days) => days.min <= days.max, { message: '`min` must not exceed `max`', path: ['max'] }); + export const onboardingSchema = z.strictObject({ signup: sourcedFact(z.enum(SIGNUP_ROUTES)).optional(), individuals_allowed: sourcedFact(z.boolean()).optional(), documents: sourcedFact(z.array(z.string().min(1))).optional(), - days: sourcedFact( + days: sourcedFact(dayRangeSchema).optional(), + security_deposit: sourcedFact(z.boolean()).optional(), +}); + +/** Smallest and largest amount of one payment, for one country when the source narrows it. */ +export const transactionLimitSchema = z + .strictObject({ + country: countryCode.optional(), + minimum: moneySchema.optional(), + maximum: moneySchema.optional(), + }) + .superRefine((limit, ctx) => addRuleProblems(limitProblems(limit), ctx)); + +/** How an account works once open: limits, payout requirements, what it may sell. */ +export const operationsSchema = z.strictObject({ + transaction_limits: sourcedFact( z - .strictObject({ min: z.number().int().nonnegative(), max: z.number().int().nonnegative() }) - .refine((days) => days.min <= days.max, { message: 'Onboarding `min` must not exceed `max`', path: ['max'] }), + .array(transactionLimitSchema) + .min(1) + .superRefine((limits, ctx) => addRuleProblems(limitListProblems(limits), ctx)), ).optional(), - security_deposit: sourcedFact(z.boolean()).optional(), + recurring_payments: sourcedFact(z.boolean()).optional(), + /** E-commerce plugins the provider publishes. An empty list means none. */ + ecommerce_plugins: sourcedFact(z.array(z.string().min(1))).optional(), + /** What a merchant must set up before sending money, such as an allowlisted server address. */ + payout_requirements: sourcedFact(z.array(z.string().min(1)).min(1)).optional(), + /** Activities the terms refuse, in the provider's own words. */ + prohibited_activities: sourcedFact(z.array(z.string().min(1)).min(1)).optional(), }); export const incidentSchema = z.strictObject({ diff --git a/src/schema/provider.ts b/src/schema/provider.ts index 2fdb28f..7bc0e94 100644 --- a/src/schema/provider.ts +++ b/src/schema/provider.ts @@ -10,6 +10,7 @@ import { integrationSchema, licenceSchema, onboardingSchema, + operationsSchema, registerAbsenceSchema, settlementSchema, } from './provider-parts'; @@ -48,6 +49,7 @@ export const providerSchema = z settlements: z.array(settlementSchema).default([]), integration: integrationSchema.default({}), onboarding: onboardingSchema.default({}), + operations: operationsSchema.default({}), incidents: z.array(incidentSchema).default([]), }) .refine((provider) => provider.status === 'draft' || provider.verified_at !== undefined, { diff --git a/src/schema/rules.ts b/src/schema/rules.ts index 0b9d019..b1b800d 100644 --- a/src/schema/rules.ts +++ b/src/schema/rules.ts @@ -1,6 +1,6 @@ import type { z } from 'zod'; -import type { AmountBand, FeeAmounts, Money, RuleProblem } from './amount-types'; +import type { AmountBand, AmountLimits, FeeAmounts, Money, RuleProblem, TransactionLimit } from './amount-types'; /** True for a real calendar day written `YYYY-MM-DD`, so `2026-02-30` is refused. */ export function isCalendarDate(value: string): boolean { @@ -38,6 +38,39 @@ export function bandProblems(band: AmountBand): RuleProblem[] { return []; } +/** A payment limit needs a bound; both bounds share a currency and stay in order. */ +export function limitProblems(limit: AmountLimits): RuleProblem[] { + const { minimum, maximum } = limit; + + if (minimum === undefined && maximum === undefined) { + return [{ path: [], message: 'A limit needs `minimum`, `maximum`, or both' }]; + } + + if (minimum !== undefined && maximum !== undefined && minimum.currency !== maximum.currency) { + return [{ path: ['maximum', 'currency'], message: 'Limit bounds must use the same currency' }]; + } + + return exceeds(minimum, maximum) ? [{ path: ['maximum', 'amount'], message: '`minimum` must not exceed `maximum`' }] : []; +} + +/** One limit per country at most, the limit without a country counting as its own entry. */ +export function limitListProblems(limits: TransactionLimit[]): RuleProblem[] { + const seen = new Set(); + const problems: RuleProblem[] = []; + + limits.forEach((limit, i) => { + const key = limit.country ?? ''; + + if (seen.has(key)) { + problems.push({ path: [String(i), 'country'], message: 'Only one limit per country, and one without a country' }); + } + + seen.add(key); + }); + + return problems; +} + /** Cap and minimum bound a percentage, so they need one and must stay consistent. */ export function feeAmountProblems(fee: FeeAmounts): RuleProblem[] { const problems: RuleProblem[] = []; diff --git a/src/search/section-look.ts b/src/search/section-look.ts index e72cb92..c49b86a 100644 --- a/src/search/section-look.ts +++ b/src/search/section-look.ts @@ -9,6 +9,7 @@ const LOOKS: Readonly>; diff --git a/src/search/vocabulary.ts b/src/search/vocabulary.ts index 24cea99..0d04668 100644 --- a/src/search/vocabulary.ts +++ b/src/search/vocabulary.ts @@ -9,6 +9,7 @@ export const SECTIONS: readonly SectionDeclaration[] = [ { id: 'settlements', label: { en: 'Settlement', fr: 'Reversement' }, words: ['délai', 'délais'] }, { id: 'integration', label: { en: 'Integration', fr: 'Intégration' }, words: ['intégration', 'intégrer', 'integration'] }, { id: 'onboarding', label: { en: 'Opening an account', fr: 'Ouverture de compte' }, words: ['ouvrir un compte', 'ouverture de compte', 'inscription', 'documents', 'kyc', 'open an account', 'signup'] }, + { id: 'operations', label: { en: 'Operations', fr: 'Fonctionnement' }, words: ['fonctionnement', 'plafond', 'paiements récurrents', 'activités interdites', 'transaction limit', 'recurring payments', 'prohibited activities'] }, { id: 'licences', label: { en: 'Licences', fr: 'Licences' }, words: ['licences'] }, ]; diff --git a/tests/provider-strings.test.ts b/tests/provider-strings.test.ts index 6c49636..a2372c6 100644 --- a/tests/provider-strings.test.ts +++ b/tests/provider-strings.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; import { providerStrings } from '../src/i18n/translate'; -import { integrationFacts, onboardingFacts } from '../src/lib/site-facts'; +import { integrationFacts, onboardingFacts, operationsFacts } from '../src/lib/site-facts'; import { bandText, formatMoney, sourceLink } from '../src/lib/site-format'; import { providerSchema } from '../src/schema/provider'; import { provider } from './fixtures/build'; @@ -55,3 +55,38 @@ describe('provider sheet strings', () => { expect(bandText(fee, providerStrings('fr')).startsWith('À partir de')).toBe(true); }); }); + +describe('operations facts', () => { + const record = providerSchema.parse( + provider({ + sources: { evidence: SOURCE }, + operations: { + transaction_limits: { value: [{ minimum: { amount: 200, currency: 'XOF' }, maximum: { amount: 1000000, currency: 'XOF' } }, { country: 'GH', maximum: { amount: 5000, currency: 'GHS' } }], source: 'evidence' }, + ecommerce_plugins: { value: [], source: 'evidence' }, + }, + }), + ); + + it('reads each line in French', () => { + const facts = operationsFacts(record, providerStrings('fr')); + + expect(valueOf(facts, 'Montant par paiement')).toBe('200 XOF à 1\u202f000\u202f000 XOF · Ghana : Jusqu’à 5\u202f000 GHS'); + expect(valueOf(facts, 'Plugins e-commerce')).toBe('Aucun'); + expect(valueOf(facts, 'Paiements récurrents')).toBeNull(); + }); + + it('marks a sourced absence of plugins in red', () => { + expect(operationsFacts(record, providerStrings('en')).find((fact) => fact.label === 'E-commerce plugins')?.pill).toBe('bad'); + }); + + it('rejects a limit without bound or with bounds out of order', () => { + const limits = (value: unknown[]) => providerSchema.safeParse(provider({ sources: { evidence: SOURCE }, operations: { transaction_limits: { value, source: 'evidence' } } })).success; + + expect(limits([{ country: 'GH' }])).toBe(false); + expect(limits([{ minimum: { amount: 500, currency: 'XOF' }, maximum: { amount: 100, currency: 'XOF' } }])).toBe(false); + expect(limits([{ minimum: { amount: 500, currency: 'XOF' }, maximum: { amount: 100, currency: 'XAF' } }])).toBe(false); + expect(limits([{ maximum: { amount: 100, currency: 'XOF' } }, { maximum: { amount: 200, currency: 'XOF' } }])).toBe(false); + expect(limits([{ country: 'GH', maximum: { amount: 1, currency: 'GHS' } }, { country: 'GH', minimum: { amount: 1, currency: 'GHS' } }])).toBe(false); + expect(limits([{ maximum: { amount: 100, currency: 'XOF' } }, { country: 'GH', maximum: { amount: 1, currency: 'GHS' } }])).toBe(true); + }); +}); diff --git a/tests/references.test.ts b/tests/references.test.ts index 5d654c9..4e32a83 100644 --- a/tests/references.test.ts +++ b/tests/references.test.ts @@ -68,6 +68,19 @@ describe('claim references', () => { ); }); + it('flags unknown country and currencies in payment limits', () => { + const value = [{ country: 'SN', minimum: { amount: 1, currency: 'ZZZ' }, maximum: { amount: 9, currency: 'ZZZ' } }]; + const issues = issuesFor({ operations: { transaction_limits: { value, source: 'evidence' } } }); + + expect(paths(issues)).toEqual( + expect.arrayContaining([ + 'operations.transaction_limits.value.0.country', + 'operations.transaction_limits.value.0.minimum.currency', + 'operations.transaction_limits.value.0.maximum.currency', + ]), + ); + }); + it('flags an unknown licence country and regulator', () => { const licences = [{ country: 'SN', regulator: 'cbn', type: 'bank', holder: 'Acme', source: 'evidence' }]; diff --git a/tests/site-sources.test.ts b/tests/site-sources.test.ts index 05ef0e1..3c7303c 100644 --- a/tests/site-sources.test.ts +++ b/tests/site-sources.test.ts @@ -36,14 +36,14 @@ describe('sourceLabel', () => { describe('sectionSourceKeys', () => { it('collects coverage and capability sources for the coverage section', () => { - const keys = sectionSourceKeys(RECORD, [], []); + const keys = sectionSourceKeys(RECORD, [], [], []); expect(keys.coverage).toEqual(['terms', 'docs', 'docs']); expect(keys.licences).toEqual(['register']); }); it('skips facts without a sourced value', () => { - const keys = sectionSourceKeys(RECORD, [{ label: 'a', value: null, source: 'terms' }, { label: 'b', value: 'Oui', source: 'docs' }], []); + const keys = sectionSourceKeys(RECORD, [{ label: 'a', value: null, source: 'terms' }, { label: 'b', value: 'Oui', source: 'docs' }], [], []); expect(keys.onboarding).toEqual(['docs']); });