diff --git a/.changeset/kkiapay-widget-flow.md b/.changeset/kkiapay-widget-flow.md index 9d5669f..031d49c 100644 --- a/.changeset/kkiapay-widget-flow.md +++ b/.changeset/kkiapay-widget-flow.md @@ -9,6 +9,7 @@ Kkiapay, and payments started by the customer in a widget. - `@payenv/core`: `nextAction.type === 'widget'`, `supportedWidgets` and `Capability.widget` for providers whose payments start in a widget; `payenv.confirm` verifies the provider transaction's merchant reference and amount before linking it. - New error code `REFERENCE_MISMATCH`. + New error code `REFERENCE_MISMATCH`. `toE164` converts phone numbers typed by customers + to E.164. - `@payenv/connector-kkiapay` (new): Kkiapay widget payments in Benin (MTN, Moov), server-side verification, webhook verification and parsing. diff --git a/CHANGELOG.md b/CHANGELOG.md index dfd342b..d557ad7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ Before `1.0.0`, minor versions may contain breaking changes. ## [Unreleased] ### Added +- 2026-10-06 — `@payenv/core`: `toE164(phone, country)` converts numbers typed by customers + (e.g. `61 00 00 00` in Benin) to E.164, with per-country trunk-prefix rules. - 2026-10-05 — `@payenv/core`: payments started by the customer in a widget (`nextAction.type === 'widget'`, `supportedWidgets`, `Capability.widget`) and `payenv.confirm`, which verifies the provider transaction's merchant reference and diff --git a/docs/GETTING_STARTED.md b/docs/GETTING_STARTED.md index 570fdeb..128af8b 100644 --- a/docs/GETTING_STARTED.md +++ b/docs/GETTING_STARTED.md @@ -48,6 +48,14 @@ console.log(payment.status); // 'pending': the customer confirms on their phone In the FedaPay sandbox, `+22964000001` and `+22966000001` succeed; any other number simulates a failed payment. In live mode, the customer receives a USSD prompt and confirms with their PIN. +Payenv only accepts E.164 phone numbers. Convert what the customer typed with `toE164`: + +```ts +import { toE164 } from '@payenv/core'; + +toE164('61 00 00 00', 'BJ'); // '+22961000000' +``` + Invalid requests throw a `PayenvError` (`INVALID_PHONE`, `NO_ROUTE`, …). Everything that happens with the provider is returned in the payment instead. diff --git a/examples/fedapay-demo/page.ts b/examples/fedapay-demo/page.ts new file mode 100644 index 0000000..77245a1 --- /dev/null +++ b/examples/fedapay-demo/page.ts @@ -0,0 +1,139 @@ +/** The demo page. Kept apart from the server so a test can check its inline script. */ +export interface PageOptions { + live: boolean; + maxLiveAmount: number; + withKkiapay: boolean; +} + +export function page({ live, maxLiveAmount, withKkiapay }: PageOptions): string { + return ` + +
+ + +Paiement mobile money via FedaPay${withKkiapay ? ' et Kkiapay' : ''} (${live ? 'LIVE' : 'sandbox'})
+${live ? `⚠️ Mode LIVE : vrai argent. Montant plafonné à ${maxLiveAmount} XOF.
` : ''} + +Paiement mobile money via FedaPay${withKkiapay ? ' et Kkiapay' : ''} (${live ? 'LIVE' : 'sandbox'})
-${live ? `⚠️ Mode LIVE : vrai argent. Montant plafonné à ${maxLiveAmount} XOF.
` : ''} - -