Flutter SDK
Flutter SDK for Elebne Pay checkout — render the hosted embed in a WebView, re-verify server-side, and show a native success screen.
Flutter SDK
elebne_pay_flutter is the client SDK for Elebne Pay on Flutter — the counterpart of @elebne/pay-react and @elebne/pay-react-native. It loads the hosted /embed surface in a webview_flutter WebView, listens on the ElebnePay JavaScript channel, re-verifies the result server-side, and shows a native success screen.
Install
Add the package and webview_flutter to your pubspec.yaml:
dependencies:
elebne_pay_flutter:
path: ../packages/elebne_pay_flutter # or a pub / git ref
webview_flutter: ^4.8.0elebne_pay_flutter is not yet on pub.dev. Depend on it via a path: or Git reference for now — request the Git coordinates from dev@elebne.ai.
Flow A — merchant backend (recommended)
Your server mints the intent with its sk_ key (PHP / Java) and returns the clientSecret. The SDK never sees a secret key.
Inline widget:
ElebneCheckout(
config: const ElebneConfig(env: ElebneEnv.production),
options: CheckoutOptions.fetchClientSecret(
() async => (await createIntentOnMyServer()).clientSecret,
),
onPaid: (session) => print('paid ${session.referenceNumber}'),
onCancelled: (_) {},
onError: (e) => print(e.code),
)Full-screen instead of inline:
ElebneCheckout.show(
context,
config: const ElebneConfig(env: ElebneEnv.production),
options: CheckoutOptions.fetchClientSecret(fetchClientSecret),
onPaid: (s) => print('paid ${s.referenceNumber}'),
cancelOnClose: true,
);Flow B — no backend (stored price)
ElebneCheckout(
config: const ElebneConfig(env: ElebneEnv.production),
options: const CheckoutOptions.price(
publishableKey: 'pk_live_…',
priceId: 'abc123',
quantity: 2,
),
onPaid: handlePaid,
)Flow C — verify callback (legacy)
CheckoutOptions.verify(publishableKey: 'pk_live_…', merchantOrderId: 'ORDER-1')Guarantees
- Server re-verification — a message on the
ElebnePaychannel is only a hint; the SDK callsGET /checkout/sessionand firesonPaidonly when the server confirms a terminalPAID. - No secret leakage — the
clientSecrettravels only in the WebView URL fragment (#cs=); nosk_key ever touches the SDK. - Fallback poll — if the channel message never arrives, a 3 s poll of
GET /checkout/sessionstill settles the checkout (disable withpoll: false).
Success screen & imperative control
SuccessScreen renders by default on a confirmed terminal status. Override it with successBuilder, or disable it with showSuccess: false. Pass an ElebneCheckoutController to read live status / session / error and call cancel(). ElebneCheckout.show also accepts showSuccess to control the full-screen flow.
Environments & sandbox
const ElebneConfig(env: ElebneEnv.production) // https://api.elebne.ai/api/v1 + https://elebne.ai/embed
const ElebneConfig(env: ElebneEnv.staging) // https://api.staging.elebne.ai/api/v1 + https://pay.staging.elebne.ai/embed
// Local dev only — override both endpoints
const ElebneConfig(baseUrl: 'http://localhost:3000/api/v1', embedUrl: 'http://localhost:3100/embed')Sandbox vs live is decided by the key: a pk_test_ / sk_test_ key yields a sandbox intent, surfaced as session.sandbox. There is no separate sandbox hostname.
Next steps
- React SDK — the full props reference (shared API)
- React Native SDK — the same checkout for React Native
- PHP SDK / Java SDK — mint the
clientSecretfor Flow A - Webhooks — confirm payments server-side
Was this page helpful?