Flutter — API reference
The Flutter SDK exports its public surface from
lib/pdirect_pay.dart.
Everything below is exported; anything in lib/src/... that isn’t
re-exported from the barrel is private and may change without
notice.
Classes
Section titled “Classes”PdirectPay
Section titled “PdirectPay”Process-wide singleton. Initialise once at app startup.
| Member | Signature |
|---|---|
static PdirectPay init(PdirectPayConfig config) | Locks the config for the process lifetime. Throws StateError if called twice. |
static PdirectPay get instance | Active singleton. Throws StateError if not yet initialised. |
static bool get isInitialized | Cheap check. |
@visibleForTesting static void debugReset() | Resets the singleton — debug/profile builds only. |
final PdirectPayConfig config | The locked config. |
Future<String?> getPlatformVersion() | Native version probe (used in the example app). |
→ Maps to the API: not directly. Indirectly drives every
/payments/* call by way of session-token plumbing.
PdirectPayConfig
Section titled “PdirectPayConfig”Immutable, process-wide configuration.
const PdirectPayConfig({ required PdirectPayEnvironment environment, String defaultLocale = 'fr', Duration? requestTimeout, void Function(String message)? logger, String? googlePayMerchantId, String? googlePayGatewayMerchantId, String? applePayMerchantId,});Computed getters: isProduction, effectiveTimeout, apiBaseUrl,
apiVersion, apiUrl, pinnedSpkiSha256, debugMode,
defaultHeaders. See Configuration.
PdirectPayConfigs
Section titled “PdirectPayConfigs”Per-checkout configuration.
PdirectPayConfigs({ String? sessionToken, @Deprecated('Use sessionToken (Auth-v3). Removed in 4.x.') String? token, Duration? timeout, String acceptLanguage = 'fr', String? googlePayMerchantId, String? googlePayGatewayMerchantId, String? applePayMerchantId,});PdirectPaymentBody
Section titled “PdirectPaymentBody”The collect-payment request body. With Auth-v3,
customerReference, amount, and currency are bound to the
session_token at mint time — leave them unset and the SDK omits
them on the wire. They remain on the type as optional fields for
legacy callers that still want to echo the bound values; the
gateway soft-checks any value sent and returns 400 on drift.
Defaults: paymentMethod = 'wallet', userInfo = 'full',
paymentMethodInfo = 'full', feeCoveredBy = 'buyer',
deliveryBehaviour = 'direct_delivery'.
Method-specific fields are optional at the type level — the gateway
enforces presence based on the chosen paymentMethod. See
Payment methods for the conditional
table.
→ Maps to the API:
POST /payments/collect.
PdirectPayCheckout (widget)
Section titled “PdirectPayCheckout (widget)”PdirectPayCheckout({ Key? key, required PdirectPayConfigs configs, required PdirectPaymentBody paymentBody, required Function(PdirectPayOnResponse response) onResponse, required Function(PdirectPayOnError error) onError, PdirectPayThemeConfig? themeConfig, PdirectPayLanguage? language, Color? backgroundColor,})Drop-in checkout widget. Pushes through method selection → method form → confirmation → processing → result internally. You only need to handle the two callbacks.
PdirectPayOnResponse
Section titled “PdirectPayOnResponse”Returned to onResponse on success. Fields: message, title,
customRef, amount, apiResponseCode, currency,
paymentStatus, systemRef, transactionId, identifier,
customerReference, successRedirectUrl, failRedirectUrl,
timestamp.
PdirectPayOnError
Section titled “PdirectPayOnError”Returned to onError. Fields: message, title, errorCode,
identifier, customerReference, systemReference, amount,
currency, successRedirectUrl, failRedirectUrl, timestamp.
PdirectPayThemeConfig
Section titled “PdirectPayThemeConfig”Theming primitives.
const PdirectPayThemeConfig({ PdirectPayTheme theme = PdirectPayTheme.light, Color? primaryColor, Color? secondaryColor, Color? tertiaryColor, Color? backgroundColor, Color? surfaceColor, Color? textColor, Color? secondaryTextColor, Color? borderColor, Color? errorColor, Color? successColor, double? borderRadius, EdgeInsetsGeometry? inputPadding,});Factory constructors: .light(), .dark(), .system(),
.lightPdirectBrand(). The instance method
buildThemeData(BuildContext) returns a Material 3 ThemeData.
PdirectMerchantInfo
Section titled “PdirectMerchantInfo”Branding shown in the checkout chrome.
const PdirectMerchantInfo({ required String name, String? url, String? logo,});Direct services
Section titled “Direct services”When the drop-in widget isn’t enough, drive the flow yourself:
PdirectHttpClient
Section titled “PdirectHttpClient”Singleton wrapping Dio. Auto-attaches Idempotency-Key (UUID v4) on
every POST and X-Device-Fingerprint on every authenticated request.
| Method | Notes |
|---|---|
static PdirectHttpClient get instance | |
void setSessionToken(String token) | Sets Authorization: Bearer …. |
void clearSessionToken() | |
void setAcceptLanguage(String lang) | |
Future<PdirectHttpResponse<T>> get<T>(String path, {...}) | |
Future<PdirectHttpResponse<T>> post<T>(String path, {dynamic data, ...}) | |
Future<PdirectHttpResponse<T>> put<T>(String path, {...}) | |
Future<PdirectHttpResponse<T>> delete<T>(String path, {...}) | |
Dio get dio | Escape hatch. |
Deprecated v2 aliases (setAppKey, setAuthToken, etc.) still work
in 3.x with a deprecation warning.
PdirectPaymentService
Section titled “PdirectPaymentService”Higher-level orchestration. Each method maps to one HTTP endpoint.
| Method | API endpoint |
|---|---|
createPayment(request) | POST /payments/collect |
getTransactionDetails(id) | GET /payments/transaction/{id} |
submitPaymentDetails(request) | POST /payments/submit |
verifyOtp(request) | POST /payments/verify-otp |
resendOtp(request) | POST /payments/resend-otp |
PdirectEWalletService
Section titled “PdirectEWalletService”Convenience wrapper around PdirectPaymentService for e-wallet
flows. Same five methods, same endpoint mappings.
PdirectCommonService
Section titled “PdirectCommonService”Reactive state singleton (RxDart streams) plus a few utility calls.
| Method | API endpoint |
|---|---|
fetchAvailableBanks() | GET /payments/get-config-bank |
Streams (BehaviorSubject):
Stream<bool> spinnerStreamStream<PdirectPayRequestResponse?> paymentProcessInfoStreamStream<PdirectPayResponseMessage?> paymentMessageStreamStream<PdirectPayScreenNavigation> paymentScreenStream
PdirectPayEnvironment
Section titled “PdirectPayEnvironment”sandbox, staging, production.
PdirectPayChannel
Section titled “PdirectPayChannel”Payment-method channels (close to but not identical to the API’s
payment_method literal):
none, all, eflash, ewallet, card, mobileMoney,
ewalletOtp, pdirectWallet, virtualCard, bankTransfer,
googlePay, applePay. Extension PdirectPayChannelExtension
adds displayName and iconPath.
PdirectPayFillingInfo
Section titled “PdirectPayFillingInfo”none, full, partial.
PdirectPaymentStatus
Section titled “PdirectPaymentStatus”pending, processing, approved, declined, failed,
cancelled, expired, refunded, pendingBankProofUpload.
Extension PdirectPaymentStatusExtension adds isSuccess,
isFailure, isPending, plus a fromString(String) static.
PdirectPayApiResponseCode
Section titled “PdirectPayApiResponseCode”The summary classification (one of nine):
lok000 (Success), lok001 (General error),
lok002 (Invalid params), lok003 (Auth failed),
lok004 (Method unavailable), lok005 (Insufficient funds),
lok006 (Limit exceeded), lok007 (Network error),
lok008 (Timeout), lok009 (Service unavailable).
For the underlying four-digit gateway codes
(1001–1599), use PdirectHttpClient directly and read the
response envelope. See Errors.
PdirectPayLanguage
Section titled “PdirectPayLanguage”english (en), french (fr), spanish (es),
russian (ru), chinese (zh), lingala (ln).
Static helpers: fromCode(String), supportedLocales,
getAllLanguages().
PdirectPayTheme
Section titled “PdirectPayTheme”light, dark, system.
PdirectPayResultScreen
Section titled “PdirectPayResultScreen”successScreen, errorScreen, warningScreen, infoScreen.
PdirectPayScreenNavigation
Section titled “PdirectPayScreenNavigation”Internal navigation states. Useful only if you’re driving the SDK
without the drop-in widget. Full enum:
defaultScreen, loadingScreen, paymentMethodSelectionScreen,
paymentFormScreen, ewalletFormScreen,
mobilemoneyFormScreen, cardFormScreen,
flashFormScreen, bankTransferFormScreen, nativePayScreen,
paymentConfirmationScreen, processingScreen,
mobileMoneyProcessingScreen, ewalletOtpScreen,
successScreen, errorScreen, warningScreen, infoScreen.
Utilities
Section titled “Utilities”PdirectPayUtils
Section titled “PdirectPayUtils”Static helpers for amount formatting, card validation (Luhn), and basic email regex.
PdirectPayLog
Section titled “PdirectPayLog”Tagged logger. Calls into PdirectPayConfig.logger if set; bodies
are never logged.
PdirectDeviceFingerprint
Section titled “PdirectDeviceFingerprint”static Future<String> get();SHA-256 hex of stable device attributes. Cached after first
computation. Used internally by PdirectHttpClient to attach
X-Device-Fingerprint. You don’t normally call this yourself.