init static method
- required String merchantKey,
- required String merchantSecret,
- required PayorcEnvironment environment,
- String? tabbyApiKey,
- String tabbyMerchantCode = 'ae',
- PayorcLanguage language = PayorcLanguage.english,
- String? appId,
- String? appVersion,
- String? deviceId,
- String? deviceOs,
- String? deviceModel,
- String? deviceBrand,
- String? browserToken,
Initializes the SDK with merchant credentials and environment.
Optionally provide logoPath (asset path or URL), primaryColor, and
secondaryColor to customize the payment gateway UI.
Apple Pay / Google Pay JSON for the pay package is built from
checkout customization (buildApplePayConfigurationJson / buildGooglePayConfigurationJson).
Host apps do not supply wallet JSON; ensure checkout customization has been fetched.
Provide tabbyApiKey to enable Tabby Buy Now Pay Later.
tabbyMerchantCode is required by Tabby - get it from your Tabby integration manager.
Use 'ae' for UAE, 'sa' for KSA, or your custom merchant code.
Optional deviceModel overrides auto-detected X-Device-Model from device_info_plus.
Optional deviceBrand overrides auto-detected X-DEVICE-BRAND.
Checkout customization (/sdk/checkout/customization) runs in the background
when fetchCheckoutCustomizationOnInit is true (default), using
checkoutCustomizationCurrency and checkoutCustomizationAmount, against the
same production service-sdk host as payment/add-card (not dev-gateway).
Parsed merchant_details colors are applied via PayorcSdkUiConstants.
Call this once at app startup (or before first payment). After that, use instance to get the SDK.
To show SDK toasts (e.g. from shared base alert helpers), the host app
must enable BotToast. The SDK has no MaterialApp of its own: wrap your
app with PayorcRoot at runApp, and add botToastNavigatorObservers to
your MaterialApp. Alternatively, use wrapMaterialAppBuilder as
MaterialApp.builder.
Implementation
static PayorcSdk init({
required String merchantKey,
required String merchantSecret,
required PayorcEnvironment environment,
String? tabbyApiKey,
String tabbyMerchantCode = 'ae',
PayorcLanguage language = PayorcLanguage.english,
String? appId,
String? appVersion,
String? deviceId,
String? deviceOs,
String? deviceModel,
String? deviceBrand,
String? browserToken,
}) {
PayorcSdkUiConstants.clear();
_clearHostCustomizationOverrides();
_applyUiColorOverrides();
_language = language;
uiCustomizationRevision.value++;
_instance = PayorcSdk._(
merchantKey: merchantKey,
merchantSecret: merchantSecret,
environment: environment,
tabbyApiKey: tabbyApiKey,
tabbyMerchantCode: tabbyMerchantCode,
appId: appId,
appVersion: appVersion,
deviceId: deviceId,
deviceOs: deviceOs,
deviceModel: deviceModel,
deviceBrand: deviceBrand,
browserToken: browserToken,
checkoutCustomizationCurrency: 'AED',
checkoutCustomizationAmount: 1,
fetchCheckoutCustomizationOnInit: true,
initialLanguage: language,
);
unawaited(PayorcGeoContext.refreshFromIpApi());
final created = _instance!;
if (created.fetchCheckoutCustomizationOnInit) {
unawaited(_loadCheckoutCustomization(created));
}
return created;
}