ElebneElebneDocs
SDKs

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.0

elebne_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.

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 ElebnePay channel is only a hint; the SDK calls GET /checkout/session and fires onPaid only when the server confirms a terminal PAID.
  • No secret leakage — the clientSecret travels only in the WebView URL fragment (#cs=); no sk_ key ever touches the SDK.
  • Fallback poll — if the channel message never arrives, a 3 s poll of GET /checkout/session still settles the checkout (disable with poll: 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

Was this page helpful?

On this page